Last active
September 18, 2020 21:23
-
-
Save Marcisbee/510d89f4aa2c073a2434816393d79f8c to your computer and use it in GitHub Desktop.
Idea of CSS in JS lib syntax
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
import { css, hover, setTheme, theme } from 'csx'; | |
import { dark, light } from './themes'; | |
setTheme(light); | |
const highlight = css({ | |
color: 'red', | |
backgroundColor: theme.background, | |
hover: { | |
color: 'orangered', | |
}, | |
}); | |
function App() { | |
return ( | |
<div> | |
<h1 className={highlight}> | |
Hello world | |
</h1> | |
<button onClick={() => setTheme(dark)}></button> | |
</div> | |
); | |
} |
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
export const dark = { | |
background: '#333', | |
}; | |
export const light = { | |
background: '#fff', | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment