I'm trying to style an ordered list with styled components in React.
I've got the following code
const Sublist = styled.ol`
counter-reset: secondItem;
margin: 10px 0 0 25px;
li:before {
content: ${props => props.isDeg ? counter(secondItem) `° ` : `§ ` counter(secondItem)};
counter-increment: secondItem;
}
`
I'm getting an error message for at the second counter Parsing error: Unexpected token, expected "}"
How can I wrap both conditions in a way that counter will be recognized?
Two points here:
counter
is a css function, you cannot use it in the js functioncontent
value must be within quotesTherefore change the line
content: ${props => props.isDeg ? counter(secondItem) `° ` : `§ ` counter(secondItem)};
to
content: '${props => !props.isDeg && "§ "}' counter(secondItem) '${props => props.isDeg && "° "}';