I would like to create a stylesheet which overrides how something else looks within it's hierarchy.
Something like this maybe?
// button.js
export const styleSheet = createStyleSheet('Button', () => ({
button: {
color: 'black'
}
}));
@withStyleSheet(styleSheet) // I made this decorator
export class Button {
render() {
const { classes, ...props } = this.props;
return <button className={ classes.button } { ...props } />;
}
}
// page.js
import { Button, styleSheet as buttonStyleSheet } from './button';
export const styleSheet = createStyleSheet('Button', [ buttonStyleSheet ], (theme, buttonStyles) => ({
page: {
color: 'black',
`& ${buttonStyles.button}`: {
color: 'pink' // buttons in pages are pink
}
}
}));
@withStyleSheet(styleSheet) // I made this decorator
export class Page {
render() {
const { classes, ...props } = this.props;
return <div className={ classes.page } { ...props } />;
}
}
When you're only working with your own styles this is probably not necessary, however I'm currently trying to override some styles from material-ui, which results in the following mess:
const styleSheet = createStyleSheet('RootAppBar', () => ({
tabs: {
height: '100%',
'& > div': {
height: '100%',
'& > div': {
height: '100%',
'& > div:first-child': {
height: '100%',
alignItems: 'center',
},
},
},
},
}));
It would be a lot better if I could target the divs here by name (especially the :first-child one).
I would like to create a stylesheet which overrides how something else looks within it's hierarchy.
Something like this maybe?
When you're only working with your own styles this is probably not necessary, however I'm currently trying to override some styles from
material-ui, which results in the following mess:It would be a lot better if I could target the divs here by name (especially the
:first-childone).