Skip to content

Instantly share code, notes, and snippets.

@tuchk4
Created February 11, 2017 11:37
Show Gist options
  • Save tuchk4/f375ffe3452558fcc4b1cbac3484a577 to your computer and use it in GitHub Desktop.
Save tuchk4/f375ffe3452558fcc4b1cbac3484a577 to your computer and use it in GitHub Desktop.
Aphrodite as CSS Modules
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>
}
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;
}, {});
};
import css form 'aphrodite-css-helper.js';
export default css({
button: {
color: 'white'
},
primary: {
color: 'blue'
},
});
@tuchk4
Copy link
Author

tuchk4 commented Feb 11, 2017

This is how we use CSS in JS: Aphrodite + little helper.
Use Aphrodite as CSS Modules :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment