Created
September 14, 2016 00:02
-
-
Save vdanchenkov/6656dc3e62ce7815a3cfc767680a47f9 to your computer and use it in GitHub Desktop.
Might be useful for glamor... Or not... https://github.com/threepointone/glamor
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
const doSomething = () => {} | |
const S = (...args) => { | |
const [ Component, css, defaultProps ] = | |
typeof args[0] === 'string' ? args : [ 'div', ...args ] | |
return (props) => <Component css={css} {...defaultProps} {...props}/> | |
} | |
const Label = S('label', { display: 'block' }) | |
const Block = S({ margin: '1rem 0' }) | |
const Checkbox = S('input', { color: 'red' }, { type: 'checkbox' }) | |
const Component = () => ( | |
<Block> | |
Text with | |
<Label> | |
<Checkbox onClick={doSomething}/> | |
checkbox | |
</Label> | |
</Block> | |
) | |
// vs | |
const label = { display: 'block' } | |
const block = { margin: '1rem 0' } | |
const checkbox = { color: 'red' } | |
const Component = () => ( | |
<div css={block}> | |
Text with | |
<label css={label}> | |
<input css={checkbox} type="checkbox" onClick={doSomething}/> | |
checkbox | |
</label> | |
</div> | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment