Skip to content

Commit

Permalink
chore: add failing test
Browse files Browse the repository at this point in the history
This branch will fix #4053
  • Loading branch information
quantizor committed Jun 25, 2023
1 parent 1f771fe commit 68b7466
Showing 1 changed file with 26 additions and 0 deletions.
26 changes: 26 additions & 0 deletions packages/styled-components/src/test/types.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -377,3 +377,29 @@ styled.div<CSSPropTestType>(p => ({

// object styles
styled.div({ color: 'red', '@media (min-width: 500px)': { fontSize: '11px' } });

type TextProps = React.PropsWithChildren<{
color: 'primary' | 'secondary';
size?: 'sm' | 'md' | 'lg';
}>;

const sizeMap = {
sm: '10px',
md: '14px',
lg: '16px',
} as const;

const Text = styled('span')<TextProps>(({ color, size }) => ({
color: color === 'primary' ? '#444' : color === 'secondary' ? 'maroon' : 'black',
fontSize: size && sizeMap[size],
}));

type ExtendingTextProps = React.PropsWithChildren<{ hasResult: boolean }>;
const ExtendingText = styled(Text)<ExtendingTextProps>(({ hasResult }) => ({
opacity: !hasResult ? '100%' : '50%',
}));

const StylingText = styled(Text)({
display: 'block',
margin: '10px 0',
});

0 comments on commit 68b7466

Please sign in to comment.