Created
February 20, 2018 20:28
-
-
Save jm2242/e752e828fdebae57a701454e09913f81 to your computer and use it in GitHub Desktop.
Handle Styles in React component
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// — — — — — 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