-
-
Notifications
You must be signed in to change notification settings - Fork 399
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[styled-jss] Styled Primitive Components #341
Comments
Variant 1import styled from 'styled-jss'
const Button = styled('button', {
fontSize: 12,
color: (props) => props.theme.textColor
})
const PrimaryButton = styled(Button, {
color: 'red'
}) |
Variant 2import Styled from 'styled-jss'
import injectSheet from 'react-jss'
// Base styles, like a regular jss object.
const styled = Styled({
root: {
margin: 10
},
baseButton: {
padding: 10
}
})
const NormalButton = styled('button', {
composes: '$baseButton',
border: '1px solid grey'
color: 'black'
})
// Composition over styled() same like styled-components
const PrimaryButton = styled(NormalButton, {
color: 'red'
})
// One can use classes AND styled primitives.
const MyComponent = ({classes}) => (
<div className={classes.root}>
<PrimaryButton>
</div>
)
const MyStyledComponent = injectSheet(styled)(MyComponent) cc @cssinjs/core |
@kof any progress here? |
Yes, me and @lttb are evaluating some interesting interfaces, but its not ready yet. |
@kof Can I help you? |
Yes, we are preparing some syntax variants and will need user feedbacks, we will post the poll here soon cc @lttb |
You see actually already 2 possible syntaxes, what are your thoughts on them? What do you NOT understand? |
All syntaxes is readable. |
Variant 3There are some points about yet another concept:
{
button: {
color: 'red'
}
}
{
App: { padding: '10px' }, // on the top level it turns into <div> with modifier className
button: {
color: 'black',
Primary: {
color: 'red'
}
}
}
{
button: {
color: 'black',
Normal: {
border: '1px solid black'
},
Secondary: {
composes: '$buttonNormal' // -> button.Normal styles
}
}
}
{
button: {
color: 'black',
},
buttonNormal: {
border: '1px solid black'
},
buttonSecondary: {
composes: '$buttonNormal'
}
}
const styles = {
App: { padding: 30px },
button: {
padding: '10px',
Normal: {
border: '1px solid black'
},
Primary: {
color: 'red'
},
Secondary: {
composes: '$buttonNormal',
color: 'green'
}
}
}
const MyComponent = ({ styled }) => (
<styled.App>
<styled.button />
<styled.button.Primary />
</styled.App>
)
const MyStyledComponent = injectStyled(styles)(MyComponent) |
closing, as we got it released https://github.com/cssinjs/styled-jss |
Create a small library that allows to style primitives similar to styled-components. Some pseudo code.
The text was updated successfully, but these errors were encountered: