Skip to content

Instantly share code, notes, and snippets.

@Stahlneckr
Created September 30, 2019 15:38
Show Gist options
  • Select an option

  • Save Stahlneckr/6c3b500b86b275974ed7ddb1c000c356 to your computer and use it in GitHub Desktop.

Select an option

Save Stahlneckr/6c3b500b86b275974ed7ddb1c000c356 to your computer and use it in GitHub Desktop.
Example of Global styles with aphrodite
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