Closed satispunk closed 7 years ago
What result are you experiencing? It was intended to be supported. But I see now that your sample has invalid red code highlights.
This is because it currently assumes the string to contain a complete declaration.
Could any of the styled-components experts, perhaps @daedlock, since you reviewed my PR when we added initial support clarify: is css`` intended to be used for whole css declarations, including selectors?
const styles2 = css`
div {
color: red
}
another {
margin:5px
}
`
or sets of properties?
const styles = css`
color: red
IIRC correctly I've seen both kinds of usages? Depending on that there either should or should not be a prefix/suffix added to the injected text.
Yes, AFAIK, css
and injectGlobal
selectors should contain complete declaration as . Please confirm @mxstbr
Not quite true. css
is used like styled.x
:
const styleFragment = css`
color: blue;
`
const Button = styled.div`
background: red;
${styleFragment}
`
That is the most widely used usage.
Note though that both can (but don't have to!) also contain full CSS declarations for nesting:
const styleFragment = css`
color: blue;
// Any div within a component that has this style fragment will be red
div {
color: red;
}
`
const Button = styled.div`
background: red;
${styleFragment}
// Any span within this button will be blue
span {
background: blue;
}
`
(excuse the nonsensical example)
Ok, thanks, I assumed it was expected to contain a complete declaration and was wrong. Created a PR to fix this
css is not yet supported?