So, I played with type systems in JavaScript and, for the most part, everything works, but there is a problem with stylized components. I canβt find a good way to apply the flow to the details of a stylized component. So far, the only solution that I see is:
export type ButtonPropTypes = ReactPropTypes & {
styleType: 'safe' | 'info' | 'warning' | 'danger' | 'link',
isPill: boolean,
isThin: boolean,
};
export const ButtonStyled = styled.button`
${generateBaseStyles}
${hoverStyles}
${fillStyles}
${thinStyles}
${linkStyles}
`;
export const Button = (props: ButtonPropTypes) => <ButtonStyled {...props} />;
It seems pretty excessive that I have to create 2 components for each stylized component.
I hope my google skills are just crap, and I'm missing something, but is there a better way to do this besides a few components for each stylized component?
source
share