I have a bit of a condrum I can't seem to solve I am querying colors from a graphQL database from DatoCMS and want to change the color of a Pseudo element in my Gatsby js app I can do so just fine like this with a regular selector
<p style={{color: pricing.packageBorderColor.hex}} className="price-session">
<span>${pricing.priceAmount}</span> | <span>{pricing.lengthOfSession}</span>
</p>
However I am not sure how to introduce sudo selector like :after
into the mix.
const ListItem = styled.li`
list-style-type: none;
font-size: 20px;
display: inline-block;
width: 330px;
&:before {
content: url(data:image/svg+xml,${encodeURIComponent(renderToString(<FontAwesomeIcon icon={faCheck} />))});
width: 20px;
display: block;
float: left;
position: absolute;
margin-left: -31px;
color: {pricing.packageBorderColor.hex} // This is what I'd ideally like to do, but doesnt seem doable
}
span{
display:block;
float:left;
margin-top:3px;
}
`
I have thought maybe styled components and This works, however I then Can't add my variables because styled components seems to live outside there scope before my loop and react component.
Updated Attempt
const CircleSave = styled.div`
&:after{
background: ({color}) => color
}
`
<CircleSave color={pricing.packageBorderColor.hex} className="circle-save">
<p>${pricing.packageSavings}</p>
<p>savings</p>
</CircleSave>
I get the following error in my rendered css
.chrVyZ:after {
background: ({color}) => color;
}