Often when I use styled-components I define a set of standard components in a globals.js file and export them from there e. g. a standard paragraph style like this:
export const P = styled.p`
font-size: 1.4rem;
`
Every standard style may come with variations e. g. a standard bold paragraph. I wonder what is the best way to achieve this. I can see several approaches:
Way 1 (pass a bold prop):
const P = styled.p`
font-weight: ${({fontWeight}) => fontWeight ? fontWeight : 'normal'}
`
Way 2 (create a component with a bold prop but export a separate component that already has the prop):
export const BoldP = props => <P fontWeight="bold">
Way 3 (Define and export all variations individually):
export const P = styled.p`
font-weight: ${({fontWeight}) => fontWeight ? fontWeight : 'normal'}
`
export const BoldP = styled(P)`
font-weight: bold
`
This question may seem a little profane, but since this is a very standard interface for a lot of apps, I wonder if there is a "right" way to do this.