Compose css classes
A small utility function to make react components that use css modules to have extensible styles.
Example
import * as css from './Foo.css'
import composeClasses from 'compose-css-classes'
type Props = {
css?: Partial<typeof css>
}
export const Foo = (props: Props) => {
const classes = composeClasses(css, props)
return <div {...classes('container')}></div>
}
import * as css from './Bar.css'
export const Bar = () => {
return <Foo css={{container: css.fooContainer}} />
}
.container {
background: black;
}
.fooContainer {
color: white;
}
Look at src/index.test.ts
for more examples.