react-base16-styling
Install
npm i -S react-base16-stylingUsage
import { createStyling } from 'react-base16-styling';
import base16Themes from './base16Themes';
function getStylingFromBase16(base16Theme) {
return {
myComponent: {
backgroundColor: base16Theme.base00
},
myComponentToggleColor({ style, className }, clickCount) {
return {
style: {
...style,
backgroundColor: clickCount % 2 ? 'red' : 'blue'
}
}
}
};
}
const createStylingFromTheme = createStyling(getStylingFromBase16, {
defaultBase16: base16Themes.solarized,
base16Themes
});
class MyComponent extends Component {
state = { clickCount: 0 }
render() {
const { theme } = this.props;
const { clickCount } = this.state;
const styling = createStylingFromTheme(theme);
return (
<div {...styling('myComponent')}>
<a onClick={() => this.setState({ clickCount: clickCount + 1 })}>Click Me</a>
<div {...styling('myComponentToggleColor', clickCount)}>
{clickCount}
</div>
</div>
)
}
}createStyling
createStylingArgument
Signature
Description
getBase16Theme
getBase16ThemeinvertTheme
invertThemeLast updated