Skip to content

Instantly share code, notes, and snippets.

@jm2242
Created February 20, 2018 20:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jm2242/e752e828fdebae57a701454e09913f81 to your computer and use it in GitHub Desktop.
Save jm2242/e752e828fdebae57a701454e09913f81 to your computer and use it in GitHub Desktop.
Handle Styles in React component
// — — — — — BEGIN handle styles — — — — — — — //
// count the number of buttons we want to show
const numberOfButtons = [canAddColumns, canHideColumns, canRemoveColumns, canSearch, canSort].reduce(
(acc, showButton) => showButton ? acc+1 : acc,
0
)
const totalColumnIconsWidth = numberOfButtons * (sheetsVariables.columnIconsSize + sheetsVariables.columnIconsMargin)
// styles object
const headerCellStyles = {
columnIcons: encodeStyles({
width: totalColumnIconsWidth
}),
columnOptions: encodeStyles({
…(columnHasError ? { pointerEvents: “none” } : hideIfTrue(searching || sorting)),
right: -1 * totalColumnIconsWidth,
}),
}
// — — — — — END handle styles — — — — — — — //
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment