Skip to content

Commit 649d0f5

Browse files
Christianjoshuaellis
andauthored
chore: update styled-components to V6 (#1695)
Co-authored-by: Josh <[email protected]>
1 parent b9646de commit 649d0f5

File tree

164 files changed

+2481
-2727
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

164 files changed

+2481
-2727
lines changed

.changeset/famous-trainers-pretend.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore!: default color for Typography is currentColor

.changeset/tasty-suits-sit.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore: Box/Flex/Grid & Typography are now all react components, they are no longer styled-components.

.changeset/tidy-eggs-sleep.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
'@strapi/design-system': major
3+
'@strapi/icons': major
4+
---
5+
6+
chore: update to use styled-components@6

.changeset/tidy-rats-camp.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore: disallow use of as and instead use tag prop instead

docs/.storybook/preview.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { parse } from 'qs';
66
import { DesignSystemProvider, Box, darkTheme, lightTheme, type BoxProps } from '@strapi/design-system';
77

88
import { DocsContainer, Unstyled } from '@storybook/blocks';
9-
import styled, { DefaultTheme } from 'styled-components';
9+
import { styled, DefaultTheme } from 'styled-components';
1010
import { MARKDOWN_OVERRIDES, Markdown } from '../components/Markdown';
1111

1212
const createCustomTheme = (theme: DefaultTheme, base: 'light' | 'dark' = 'light') => {
@@ -57,7 +57,7 @@ const Theme = ({ children, ...props }: BoxProps) => {
5757

5858
return (
5959
<DesignSystemProvider locale="en" theme={isDark ? darkTheme : lightTheme}>
60-
<Main as="main" background="neutral0" padding="4rem" paddingBottom="8rem" height="100%">
60+
<Main tag="main" background="neutral0" padding="4rem" paddingBottom="8rem" height="100%">
6161
<Box maxWidth="84rem" margin="auto" height="100%" {...props}>
6262
{children}
6363
</Box>
@@ -136,6 +136,7 @@ const preview: Preview = {
136136
'Primitives',
137137
['Overview', '*'],
138138
'Inputs',
139+
'Components',
139140
'Design System',
140141
['Technical Components', 'Components'],
141142
'Utilities',

docs/components/ColorCards.tsx

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,14 @@ const ColorCards = () => {
2727
const { compare } = useCollator(locale);
2828

2929
return (
30-
<Flex as="article" alignItems="stretch" direction="column">
30+
<Flex tag="article" alignItems="stretch" direction="column">
3131
{COLOR_CARD_NAMES.map((colorName) => {
3232
const colorKeys = Object.keys(allColors).filter((colorKey) => colorKey.startsWith(colorName.toLowerCase()));
3333

3434
return (
35-
<Box key={colorName} as="section">
35+
<Box key={colorName} tag="section">
3636
<H2>{`${colorName} colors`}</H2>
37-
<Grid as="ol" gap={6} gridCols={3}>
37+
<Grid tag="ol" gap={6} gridCols={3}>
3838
{colorKeys
3939
.toSorted((a, b) => compare(a, b))
4040
.map((key) => (
@@ -73,9 +73,9 @@ const Card = ({ colorKey, colorName, colorShade }: CardProps) => {
7373
const colorRGB = `${colorRef.toRgb().r}, ${colorRef.toRgb().g}, ${colorRef.toRgb().b}`;
7474

7575
return (
76-
<Box as="article" background="neutral100" borderRadius="8px">
76+
<Box tag="article" background="neutral100" borderRadius="8px">
7777
<Flex
78-
as="dl"
78+
tag="dl"
7979
alignItems="end"
8080
direction="row"
8181
background={colorKey}
@@ -91,7 +91,7 @@ const Card = ({ colorKey, colorName, colorShade }: CardProps) => {
9191
<ContrastInfo backgroundColor={colorHex} isLighter isSmall />
9292
</Flex>
9393
<Grid
94-
as="dl"
94+
tag="dl"
9595
aria-label={`Table properties for ${colorName} ${colorShade}`}
9696
gap={2}
9797
gridCols={2}
@@ -117,10 +117,10 @@ const Card = ({ colorKey, colorName, colorShade }: CardProps) => {
117117
},
118118
].map((props) => (
119119
<Box key={props.label}>
120-
<Typography as="dt" variant="sigma">
120+
<Typography tag="dt" variant="sigma">
121121
{props.label}
122122
</Typography>
123-
<Typography as="dd" variant="pi">
123+
<Typography tag="dd" variant="pi">
124124
{props.content}
125125
</Typography>
126126
</Box>
@@ -142,15 +142,15 @@ const ContrastInfo = ({ backgroundColor = '', isLighter = false, isSmall = false
142142
return (
143143
<Flex alignItems="stretch" direction="column" flex={1} textAlign="center">
144144
<Box
145-
as="dt"
145+
tag="dt"
146146
aria-label={`${isSmall ? 'Small' : 'Large'} font and ${isLighter ? 'lighter' : 'darker'} text.`}
147147
paddingBottom={2}
148148
style={{ color: textColor, fontSize: isSmall ? '12px' : '16px' }}
149149
>
150150
A
151151
</Box>
152152
<Box
153-
as="dd"
153+
tag="dd"
154154
background="neutral1000"
155155
borderRadius="4px"
156156
color="neutral0"

docs/components/DeprecationNotice.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ interface DeprecationNoticeProps {
99

1010
const DeprecationNotice = ({ children, href }: DeprecationNoticeProps) => (
1111
<Flex padding={5} background="danger500" justifyContent="center" marginTop={4} marginBottom={4} hasRadius>
12-
<Typography fontSize={4} fontWeight="bold" as="p">
12+
<Typography fontSize={4} fontWeight="bold" tag="p">
1313
⛔️
1414
<strong>
1515
{' This component has been deprecated. Please use '}

docs/components/Image.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ComponentPropsWithoutRef } from 'react';
22

3-
import styled from 'styled-components';
3+
import { styled } from 'styled-components';
44

55
interface ImageProps extends ComponentPropsWithoutRef<'img'> {}
66

docs/components/Markdown.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Markdown as MarkdownImpl } from '@storybook/blocks';
22
import { BaseLink } from '@strapi/design-system';
3-
import styled, { css } from 'styled-components';
3+
import { styled, css } from 'styled-components';
44

55
import { DeprecationNotice } from './DeprecationNotice';
66
import { Image } from './Image';

docs/components/Typescale.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Typography } from '@strapi/design-system';
2-
import styled from 'styled-components';
2+
import { styled } from 'styled-components';
33

44
const TEXT_VARIANTS = ['alpha', 'beta', 'delta', 'epsilon', 'omega', 'pi', 'sigma'] as const;
55

docs/components/Typography.tsx

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,41 @@
1-
import { Typography, TypographyProps } from '@strapi/design-system';
2-
import styled, { css } from 'styled-components';
1+
import { Typography, TypographyComponent, TypographyProps } from '@strapi/design-system';
2+
import { styled, css } from 'styled-components';
33

44
const H1 = (props: TypographyProps) => (
5-
<Typography as="h1" variant="alpha" textColor="neutral800" marginBottom="0.5em" {...props} />
5+
<Typography {...props} tag="h1" variant="alpha" textColor="neutral800" marginBottom="0.5em" />
66
);
77

88
const H2 = (props: TypographyProps) => (
9-
<Typography as="h2" variant="beta" textColor="neutral800" marginBottom="1em" marginTop="2em" {...props} />
9+
<Typography {...props} tag="h2" variant="beta" textColor="neutral800" marginBottom="1em" marginTop="2em" />
1010
);
1111

1212
const H3 = (props: TypographyProps) => (
13-
<Typography as="h3" variant="delta" textColor="neutral800" marginBottom="1em" marginTop="1.4em" {...props} />
13+
<Typography
14+
{...props}
15+
tag="h3"
16+
variant="delta"
17+
textColor="neutral800"
18+
marginBottom="1em"
19+
marginTop="1.4em"
20+
fontSize={4}
21+
/>
1422
);
1523

1624
const H4 = (props: TypographyProps) => (
1725
<Typography
18-
as="h4"
26+
{...props}
27+
tag="h4"
1928
variant="epsilon"
2029
textColor="neutral800"
2130
marginBottom="1em"
2231
marginTop="1.4em"
23-
fontWeight="bold"
24-
{...props}
32+
fontWeight="semiBold"
2533
/>
2634
);
2735

28-
const P = (props: TypographyProps) => <Paragraph as="p" variant="epsilon" textColor="neutral700" {...props} />;
36+
const P = (props: TypographyProps) => (
37+
<Paragraph {...props} tag="p" variant="epsilon" textColor="neutral700" fontSize={2} />
38+
);
2939

3040
const codeStyles = css`
3141
color: ${({ theme }) => theme.colors.neutral700};
@@ -34,7 +44,7 @@ const codeStyles = css`
3444
padding: 0.6rem;
3545
`;
3646

37-
const Paragraph = styled(Typography)`
47+
const Paragraph = styled<TypographyComponent<'p'>>(Typography)`
3848
& code {
3949
${codeStyles}
4050
}
@@ -44,7 +54,7 @@ const Paragraph = styled(Typography)`
4454
}
4555
`;
4656

47-
const Li = (props: TypographyProps) => <ListItem as="li" variant="epsilon" textColor="neutral700" {...props} />;
57+
const Li = (props: TypographyProps) => <ListItem tag="li" variant="epsilon" textColor="neutral700" {...props} />;
4858

4959
const ListItem = styled(Typography)`
5060
& code {

docs/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
"react": "18.2.0",
1515
"react-dom": "18.2.0",
1616
"storybook-dark-mode": "^3.0.3",
17-
"styled-components": "^5.3.11"
17+
"styled-components": "6.1.8"
1818
},
1919
"devDependencies": {
2020
"@storybook/blocks": "^7.6.17",

docs/public/stories/strapi-img.png

2.47 KB
Loading

docs/stories/Accordion.mdx

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -36,19 +36,6 @@ import { Accordion, AccordionToggle, AccordionContent, AccordionGroup } from '@s
3636

3737
<Canvas of={AccordionStories.Group} />
3838

39-
## Accordion keyboard navigable
40-
41-
The accordion component has two main states: collapsed and expanded. By default it has a collapsed state. If
42-
Call-to-actions are required, use them on the right side and use chevron icon on the left one.
43-
44-
<Canvas of={AccordionStories.Keyboard} />
45-
46-
## Accordion expanded
47-
48-
The Accordion component can also be open by default using the parameter `expanded={true}`.
49-
50-
<Canvas of={AccordionStories.Expanded} />
51-
5239
## Accordion props
5340

5441
<ArgTypes of={Accordion} />

0 commit comments

Comments
 (0)