diff --git a/README.md b/README.md index ed225eb..eed1f58 100644 --- a/README.md +++ b/README.md @@ -48,6 +48,80 @@ const ButtonContainer = styled(Container)({ }) ``` +## Theming + +`styled-jss` has out of the box support for theme customization with the unified [theming](https://github.com/cssinjs/theming) package. + +```js +import {ThemeProvider} from 'theming' +import styled from 'styled-jss' + +const Button = styled('button')(({theme}) => ({ + color: theme.color, + 'background-color': theme.backgroundColor, + margin: props.margin, +})) + +const currentTheme = { + primary: { + color: 'black', + backgroundColor: 'yellow', + }, +} + +const App = () => ( + + + +) + +export default App +``` + +## Composable styles + +You can compose your style-objects and style-functions. + +```js +import colors from 'my-colors' + +/* let's declare some abstract mixins for example */ + +const theme = ({theme}) => ({ + color: colors[theme], + backgroundColor: colors.accent[theme], +}) + +const font = ({bold}) => ({ + font: {weight: bold ? 'bold' : 'normal', family: 'Arial'} +}) + +const size = ({size}) => ({ + s: { + fontSize: 12, + lineHeight: 15, + }, + m: { + fontSize: 16, + lineHeight: 18 + } +})[size] + +const rounded = ({rounded}) => rounded && {borderRadius: 5} + +/* now we can mix them to our Button Component */ + +const Button = styled('button')(theme, size, font, rounded) + +/* and that's it */ + +