Created
September 30, 2019 15:38
-
-
Save Stahlneckr/6c3b500b86b275974ed7ddb1c000c356 to your computer and use it in GitHub Desktop.
Example of Global styles with aphrodite
This file contains hidden or 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
| import { StyleSheet } from 'aphrodite/no-important'; | |
| const globalSelectorHandler = (selector, _, generateSubtreeStyles) => { | |
| if (selector[0] !== "*") { | |
| return null; | |
| } | |
| return generateSubtreeStyles(selector.slice(1)); | |
| }; | |
| const globalExtension = {selectorHandler: globalSelectorHandler}; | |
| const { StyleSheet: globalStyleSheet, css: globalCss } = StyleSheet.extend([globalExtension]); | |
| const GlobalStyles = globalStyleSheet.create({ | |
| globals: { | |
| '**': { | |
| boxSizing: 'border-box', | |
| '-webkit-font-smoothing': 'antialiased', | |
| '::before': { | |
| boxSizing: 'inherit', | |
| }, | |
| '::after': { | |
| boxSizing: 'inherit', | |
| }, | |
| }, | |
| '*p': { | |
| margin: 0, | |
| }, | |
| }, | |
| }); | |
| globalCss(GlobalStyles.globals); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment