polished: Mixin not working in styled-components conditional style
In this case, ellipsis will not be working…
import { ellipsis } from 'polished';
export const Subheader = styled.h2`
${props => props.foo && `
${ellipsis('312px')}
color: ${color.blue};
`}
`;
<Subheader foo>
This one is a really long subheader I suppose!
</Subheader>
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15 (6 by maintainers)
@chhuang You are getting that error because you are passing it a function as opposed to just the color prop. It should look like this:
Working example: https://www.webpackbin.com/bins/-Kp-GnOppL8vu1Vya_n7
Hi @vizFlux, your issue is that you are returning an interpolation within an interpolation which requires the
css
helper instyled-components
: https://github.com/styled-components/styled-components/blob/master/docs/api.md#cssOnce you do that, it should work just fine: https://www.webpackbin.com/bins/-KkkT31cIhxnIUZBRrFj
@bhough : sorted it out. This worked.
color: ${props => darken(0.4, getButtonTextColor(props))};
Thanks a lot for your valuable time. Cheers!