Created
November 4, 2020 18:53
-
-
Save rattrayalex/e9a0dbc4ba2b24f0795b10661af1fa57 to your computer and use it in GitHub Desktop.
Loose sketch of css-in-js root variables
This file contains 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
const rootCSSVars = { | |
colorPrimary: {name: '--color-primary', value: 'red'}, | |
colorSecondary: {name: '--color-secondary', value: 'orange'}, | |
} | |
writeCSSToDOM(` | |
:root { | |
${_.mapValues(rootCSSVars, (v) => `${v.name}: ${v.value};\n`)} | |
} | |
`) | |
export const vars = _.map(rootCSSVars, (v, k) => ([k,`var(${name})`])); | |
// so you can do this: | |
import {vars} from 'my-styles' | |
css({ | |
color: vars.primaryColor, | |
}) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment