Skip to content

Dynamic values (proof of concept) - #24

Closed
geelen wants to merge 3 commits into
masterfrom
dynamic-values
Closed

geelen wants to merge 3 commits into
masterfrom
dynamic-values

Conversation

@geelen

@geelen geelen commented Sep 14, 2016

Copy link
Copy Markdown
Member

Messssssssy atm but this is what I've been wanting to demonstrate the whole time. I think this is why we need tagged template literals, rather than just strings that are concatenated-at-definition-time

This now works:

const A = styled.div`
  margin-top: 2rem;
  ${({hasBorder}) => hasBorder && 'border: 1px solid blue;'}
  color: ${props => props.color || 'black'};
  ${css`font-weight: bold;`}
  &:hover {
    text-transform: uppercase;
  }
`
<A color="red">Omfg</A>
<A color="orange">Look</A>
<A hasBorder>At this shit</A>

image

Now... that props that we pass in... what if that merged both React context and props. Looks for, say, a theme object on context then Object.applys everything in props over the top. Basically turning the whole theming/contextual overrides into one simple conventional mechanism.

The implementation needs work but I like this an alot

@geelen geelen mentioned this pull request Sep 14, 2016
@mxstbr mxstbr mentioned this pull request Sep 20, 2016
@geelen geelen mentioned this pull request Sep 21, 2016
@geelen

geelen commented Sep 26, 2016

Copy link
Copy Markdown
Member Author

The spirit of this lives on in #29 but with a much simpler implementation!

@geelen geelen closed this Sep 26, 2016
@mxstbr
mxstbr deleted the dynamic-values branch September 26, 2016 22:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants