Skip to content

Commit f2fcebc

Browse files
committed
chore!: make Size & Variant types singular
1 parent ec8ac82 commit f2fcebc

File tree

9 files changed

+29
-27
lines changed

9 files changed

+29
-27
lines changed

.changeset/ninety-spoons-grab.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@strapi/design-system': major
3+
---
4+
5+
chore!: all XXSize & XXVariant types are now singular
6+
7+
This is consistent across the codebase.

docs/stories/Searchbar.stories.tsx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ export const SizeS = {
4848
onChange={(e) => setValue(e.target.value)}
4949
clearLabel="Clearing the plugin search"
5050
placeholder="e.g: strapi-plugin-abcd"
51-
size="S"
5251
>
5352
Searching for a plugin
5453
</Searchbar>

packages/design-system/src/components/Badge/Badge.tsx

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,7 @@ import { css, styled, type DefaultTheme } from 'styled-components';
33
import { Flex, FlexComponent, FlexProps } from '../Flex';
44
import { Typography } from '../Typography';
55

6-
type BadgeSizes = 'S' | 'M';
7-
/**
8-
* @deprecated use `BadgeSizes` instead.
9-
*/
10-
type BadgeSize = BadgeSizes;
6+
type BadgeSize = 'S' | 'M';
117

128
interface BadgeProps extends FlexProps {
139
/**
@@ -18,7 +14,7 @@ interface BadgeProps extends FlexProps {
1814
/**
1915
* @default 'M'
2016
*/
21-
size?: BadgeSizes;
17+
size?: BadgeSize;
2218
textColor?: keyof DefaultTheme['colors'];
2319
}
2420

@@ -52,7 +48,7 @@ const Badge = ({
5248
);
5349
};
5450

55-
const Base = styled<FlexComponent>(Flex)<{ $size: BadgeSizes }>`
51+
const Base = styled<FlexComponent>(Flex)<{ $size: BadgeSize }>`
5652
border-radius: ${({ theme, $size }) => ($size === 'S' ? '2px' : theme.borderRadius)};
5753
${({ $size, theme }) => {
5854
if ($size === 'S') {
@@ -70,4 +66,4 @@ const Base = styled<FlexComponent>(Flex)<{ $size: BadgeSizes }>`
7066
`;
7167

7268
export { Badge };
73-
export type { BadgeProps, BadgeSizes, BadgeSize };
69+
export type { BadgeProps, BadgeSize };

packages/design-system/src/components/Button/Button.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,17 +10,17 @@ import { Box } from '../Box';
1010
import { Flex } from '../Flex';
1111
import { Typography } from '../Typography';
1212

13-
import { BUTTON_SIZES, Variant, ButtonSizes, DEFAULT } from './constants';
13+
import { BUTTON_SIZES, ButtonVariant, ButtonSize, DEFAULT } from './constants';
1414
import { getDisabledStyle, getHoverStyle, getActiveStyle, getVariantStyle } from './utils';
1515

1616
type ButtonProps<C extends React.ElementType = 'button'> = BaseButtonProps<C> & {
1717
endIcon?: React.ReactNode;
1818
fullWidth?: boolean;
1919
loading?: boolean;
2020
onClick?: (event: React.MouseEvent<HTMLButtonElement>) => void;
21-
size?: ButtonSizes;
21+
size?: ButtonSize;
2222
startIcon?: React.ReactNode;
23-
variant?: Variant;
23+
variant?: ButtonVariant;
2424
};
2525

2626
const Button = forwardRef(

packages/design-system/src/components/Button/constants.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,5 @@ export const LIGHT_VARIANTS = [SUCCESS_LIGHT, DANGER_LIGHT] as const;
1111
export const VARIANTS = [DEFAULT, TERTIARY, SECONDARY, DANGER, SUCCESS, GHOST, ...LIGHT_VARIANTS] as const;
1212
export const BUTTON_SIZES = ['S', 'M', 'L'] as const;
1313

14-
export type Variant = (typeof VARIANTS)[number];
15-
export type ButtonSizes = (typeof BUTTON_SIZES)[number];
14+
export type ButtonVariant = (typeof VARIANTS)[number];
15+
export type ButtonSize = (typeof BUTTON_SIZES)[number];

packages/design-system/src/components/Button/utils.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,10 @@ import {
1111
SUCCESS,
1212
DANGER_LIGHT,
1313
SUCCESS_LIGHT,
14-
Variant,
14+
type ButtonVariant,
1515
} from './constants';
1616

17-
export const getVariantColorName = (variant: Variant): 'success' | 'danger' | 'neutral' | 'primary' => {
17+
export const getVariantColorName = (variant: ButtonVariant): 'success' | 'danger' | 'neutral' | 'primary' => {
1818
if (variant === SUCCESS_LIGHT || variant === DANGER_LIGHT) {
1919
return `${variant.substring(0, variant.lastIndexOf('-'))}` as 'success' | 'danger';
2020
}
@@ -37,7 +37,7 @@ export const getDisabledStyle = ({ theme }: { theme: DefaultTheme }) => {
3737
`;
3838
};
3939

40-
export const getHoverStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: Variant }) => {
40+
export const getHoverStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: ButtonVariant }) => {
4141
if ([...LIGHT_VARIANTS, SECONDARY].includes($variant)) {
4242
return css`
4343
background-color: ${theme.colors.neutral0};
@@ -68,7 +68,7 @@ export const getHoverStyle = ({ theme, $variant }: { theme: DefaultTheme; $varia
6868
`;
6969
};
7070

71-
export const getActiveStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: Variant }) => {
71+
export const getActiveStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: ButtonVariant }) => {
7272
if ([...LIGHT_VARIANTS, SECONDARY].includes($variant)) {
7373
return css`
7474
background-color: ${theme.colors.neutral0};
@@ -88,7 +88,7 @@ export const getActiveStyle = ({ theme, $variant }: { theme: DefaultTheme; $vari
8888
`;
8989
};
9090

91-
export const getVariantStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: Variant }) => {
91+
export const getVariantStyle = ({ theme, $variant }: { theme: DefaultTheme; $variant: ButtonVariant }) => {
9292
switch ($variant) {
9393
case DANGER_LIGHT:
9494
case SUCCESS_LIGHT:

packages/design-system/src/components/Card/CardAsset.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import * as React from 'react';
22

33
import { styled } from 'styled-components';
44

5-
type CardAssetSizes = 'S' | 'M';
5+
type CardAssetSize = 'S' | 'M';
66

77
interface CardAssetProps extends React.ImgHTMLAttributes<HTMLImageElement> {
88
/**
99
* @default 'M'
1010
*/
11-
size?: CardAssetSizes;
11+
size?: CardAssetSize;
1212
children?: React.ReactNode;
1313
}
1414

@@ -29,7 +29,7 @@ const CardAssetImg = styled.img`
2929
object-fit: contain;
3030
`;
3131

32-
const CardAssetWrapper = styled.div<{ $size: CardAssetSizes }>`
32+
const CardAssetWrapper = styled.div<{ $size: CardAssetSize }>`
3333
display: flex;
3434
justify-content: center;
3535
height: ${({ $size }) => ($size === 'S' ? '8.8rem' : '16.4rem')};
@@ -41,4 +41,4 @@ const CardAssetWrapper = styled.div<{ $size: CardAssetSizes }>`
4141
`;
4242

4343
export { CardAsset };
44-
export type { CardAssetProps, CardAssetSizes };
44+
export type { CardAssetProps, CardAssetSize };

packages/design-system/src/components/Combobox/Combobox.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -315,7 +315,7 @@ const Trigger = styled(ComboboxPrimitive.Trigger)<TriggerProps>`
315315
justify-content: space-between;
316316
gap: ${({ theme }) => theme.spaces[4]};
317317
318-
s &[data-disabled] {
318+
&[data-disabled] {
319319
color: ${({ theme }) => theme.colors.neutral600};
320320
background: ${({ theme }) => theme.colors.neutral150};
321321
cursor: not-allowed;

packages/design-system/src/components/LinkButton/LinkButton.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,17 @@ import { focus } from '../../styles/buttons';
66
import { PolymorphicRef } from '../../types';
77
import { forwardRef } from '../../utilities/forwardRef';
88
import { BaseLink, BaseLinkComponent, BaseLinkProps } from '../BaseLink';
9-
import { VARIANTS, BUTTON_SIZES } from '../Button/constants';
9+
import { VARIANTS, ButtonSize, ButtonVariant } from '../Button/constants';
1010
import { getDisabledStyle, getHoverStyle, getActiveStyle, getVariantStyle } from '../Button/utils';
1111
import { Flex } from '../Flex';
1212
import { Typography } from '../Typography';
1313

1414
type LinkButtonProps<C extends React.ElementType = 'a'> = BaseLinkProps<C> & {
1515
disabled?: boolean;
1616
endIcon?: React.ReactNode;
17-
size?: (typeof BUTTON_SIZES)[number];
17+
size?: ButtonSize;
1818
startIcon?: React.ReactNode;
19-
variant?: (typeof VARIANTS)[number];
19+
variant?: ButtonVariant;
2020
};
2121

2222
const LinkButton = forwardRef(

0 commit comments

Comments
 (0)