Created
March 21, 2018 23:12
-
-
Save longlho/6c8917830e4c1be4971fa0cc60fc9426 to your computer and use it in GitHub Desktop.
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 * as styles from 'foo.css' | |
type CssMap = typeof styles | |
export const legacyCss: CssMap = { | |
container: 'mc-foo', | |
content: 'mc-content' | |
} | |
export interface Props { | |
css: CssMap | |
} | |
export function Foo (props: Props) { | |
return ( | |
<div className={props.css.container}> | |
<div className={props.css.content}/> | |
</div> | |
) | |
} | |
// Legacy mapping by default | |
Foo.defaultProps = { | |
css: legacyCss | |
} | |
export {CssMap} | |
// Consumer | |
function Bar () { | |
const css: CssMap = { | |
...legacyCss, | |
content: 'custom-content-class' | |
} | |
return <Foo css={css} /> | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment