Last active
September 12, 2018 09:35
-
-
Save iegik/b7f62baa91ad59affada49d16ff7bcc1 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 default styles => Object.keys(styles) | |
.filter((key) => !/^_/.test(key)) | |
.reduce((prev, next) => ({...prev, [next]:styles[next]}), {}); |
This file contains hidden or 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 React from 'react'; | |
import ReactDOM from "react-dom"; | |
import BEM from './BEM'; | |
const styles = { | |
favorites: { | |
color: 'green', | |
_list: { | |
listStyle: 'none', | |
padding: 0, | |
}, | |
_listItem: { | |
color: 'red', | |
__active: { | |
color: 'brown', | |
} | |
}, | |
} | |
}; | |
const Foo = () => ( | |
<div style={BEM(styles.favorites)}> | |
Foo | |
<ul style={BEM(styles.favorites._list)}> | |
<li style={BEM(styles.favorites._listItem)}>Bar</li> | |
<li | |
style={{ | |
...BEM(styles.favorites._listItem), | |
...BEM(styles.favorites._listItem.__active) | |
}} | |
> | |
Tar | |
</li> | |
</ul> | |
</div> | |
); | |
const rootElement = document.body; | |
ReactDOM.render(<Foo />, rootElement); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment