Repository navigation
Rebuild number... four? - #29
Conversation
|
OH BTW I just implemented context so you can do this const Half = styled.div`
padding: 1rem;
> h2 {
margin: 0;
padding: 1rem;
}
`
const SecondHalf = styled(Half)`
background: #ccc;
${define({
fg: 'white',
bg: '#444'
})}
`
const Button = styled.div`
color: ${inherit('fg', 'black')}
background: ${inherit('bg', 'none')}
cursor: pointer;
padding: 0.5em 1em;
border: 1px solid;
`
export default () => (
<Container>
<Half>
<h3>This is normal</h3>
<Button>Ok</Button>
</Half>
<SecondHalf>
<h3>This is inverted</h3>
<Button>Ok</Button>
</SecondHalf>
</Container>
)
const SecondHalf = styled(Half)`
background: #ccc;
${(props, context) => {
context.fg = 'white'
context.bg = '#444'
}}
`
const Button = styled.div`
color: ${(props, context) => context.fg || 'black'}
background: ${(props, context) => context.bg || 'none'}
cursor: pointer;
padding: 0.5em 1em;
border: 1px solid;
`I did originally think about merging props and context when these functions get called but idk. Anyway, I think context-passing is going to be the big thing that unlocks theming. |
|
Published at |
|
Changed up the syntax for these function interpolations: const SecondHalf = styled(Half)`
background: #ccc;
${props => props.updateTheme({
fg: 'white',
bg: '#444'
})}
`
const Button = styled.div`
color: ${props => props.theme.fg || 'black'}
background: ${props => props.theme.bg || 'none'}
cursor: pointer;
padding: 0.5em 1em;
border: 1px solid;
`Better than the alternatives, published as |
|
Shipit |
|
@mxstbr can you look into this |
|
Version |
|
🎉 🎉 🎉 🎉 |

I've lost count how many times I've torn this down and started again. But I've had to build a lot less this time around than previously, which is a good thing.
I think we need a good way of testing this end-to-end. Maybe just test
renderToString()or should we use Jest snapshots or something? Anyway, I'm not 100% that there weren't regressions so port your test projects to@nextand try it out.API as described in #27. Using a modified PostCSS parser and postcss nested to do the actual parsing, and deferring all parsing until render time.
ComponentStyleis where the action is, it almost certainly needs breaking up into a few different utils so we can implementglobalandkeyframes.Anyway, if your projects still work with this now we should get this merged and on
latestand build up from here. Apart from perf issues because of the delayed parsing (which might actually not be a real problem in the end) this is going to be a WAY better place to start from.