Created
February 11, 2017 11:37
-
-
Save tuchk4/f375ffe3452558fcc4b1cbac3484a577 to your computer and use it in GitHub Desktop.
Aphrodite as CSS Modules
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 styles from './styles.js'; | |
redner() { | |
const props = this.props; | |
const classList = classname(props.className, css.button, { | |
[css.primary]: props.primary | |
}); | |
return <Button className={classList}>{this.props.children}</Button> | |
} |
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 { StyleSheet, css } from 'aphrodite/no-important'; | |
export default stylesheet => { | |
const styles = StyleSheet.create(stylesheet); | |
return Object.keys(stylesheet).reduce((classList, className) => { | |
classList[className] = css(styles[className]); | |
return classList; | |
}, {}); | |
}; |
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 form 'aphrodite-css-helper.js'; | |
export default css({ | |
button: { | |
color: 'white' | |
}, | |
primary: { | |
color: 'blue' | |
}, | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is how we use CSS in JS: Aphrodite + little helper.
Use Aphrodite as CSS Modules :)