Created
July 17, 2018 02:46
-
-
Save jxnblk/0de110c211f68fdea230f42f9d0a06cf 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
import React from 'react' | |
import styled, { ThemeProvider } from 'styled-components' | |
export const Base = ({ | |
value, | |
children, | |
...props | |
}) => | |
<React.Fragment> | |
{React.Children.toArray(children) | |
.map(child => typeof child === 'string' ? ( | |
<div {...props}>{child}</div> | |
) : ( | |
React.cloneElement(child, props) | |
) | |
)} | |
</React.Fragment> | |
export const create = prop => styled(Base)([], | |
props => props.value ? ({ | |
[prop]: props.value | |
}) : null | |
) | |
export const FontSize = create('fontSize') | |
export const Color = create('color') | |
export const BackgroundColor = create('backgroundColor') | |
export const Margin = create('margin') | |
export const Padding = create('padding') | |
export default props => | |
<BackgroundColor value='black'> | |
<Color value='tomato'> | |
<Padding value='32px'> | |
<FontSize value='32px'> | |
Hi | |
</FontSize> | |
</Padding> | |
</Color> | |
</BackgroundColor> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment