Skip to content

Commit 88856f7

Browse files
committed
Merge branch 'main' into layout-components-beta
2 parents bbbd721 + 8a6c323 commit 88856f7

File tree

19 files changed

+251
-83
lines changed

19 files changed

+251
-83
lines changed

.changeset/cyan-months-think.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris': patch
3+
---
4+
5+
Added `id` prop to `Text` and `Box`

.changeset/mean-elephants-nail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris-tokens': patch
3+
---
4+
5+
Refactored exported alias and scale types in `breakpoints`, `depth`, `font`, `motion`, `shape`, `spacing`, and `zIndex`.

polaris-react/src/components/Box/Box.tsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,8 @@ export interface BoxProps {
8989
children: ReactNode;
9090
/** Color of children */
9191
color?: ColorTokenScale;
92+
/** HTML id attribute */
93+
id?: string;
9294
/** Spacing outside of container */
9395
maxWidth?: string;
9496
/** Spacing around children */
@@ -122,6 +124,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
122124
borderRadiusTopRight,
123125
children,
124126
color,
127+
id,
125128
maxWidth,
126129
padding,
127130
paddingBottom,
@@ -218,6 +221,7 @@ export const Box = forwardRef<HTMLElement, BoxProps>(
218221
as,
219222
{
220223
className,
224+
id,
221225
ref,
222226
style: sanitizeCustomProperties(style),
223227
},

polaris-react/src/components/Text/Text.tsx

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ export interface TextProps {
5050
color?: Color;
5151
/** Adjust weight of text */
5252
fontWeight?: FontWeight;
53+
/** HTML id attribute */
54+
id?: string;
5355
/** Truncate text overflow with ellipsis */
5456
truncate?: boolean;
5557
/** Typographic style of text */
@@ -64,6 +66,7 @@ export const Text = ({
6466
children,
6567
color,
6668
fontWeight,
69+
id,
6770
truncate = false,
6871
variant,
6972
visuallyHidden = false,
@@ -81,5 +84,9 @@ export const Text = ({
8184
visuallyHidden && styles.visuallyHidden,
8285
);
8386

84-
return <Component className={className}>{children}</Component>;
87+
return (
88+
<Component className={className} {...(id ? id : null)}>
89+
{children}
90+
</Component>
91+
);
8592
};

polaris-tokens/src/token-groups/breakpoints.ts

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,10 +31,5 @@ export const breakpoints = {
3131
export type BreakpointsTokenGroup = TokenGroup<typeof breakpoints>;
3232
export type BreakpointsTokenName = keyof BreakpointsTokenGroup;
3333

34-
// e.g. "xs" | "sm" | "md" | "lg" | "xl"
35-
export type BreakpointsAlias = Extract<
36-
BreakpointsTokenName,
37-
`breakpoints-${string}`
38-
> extends `breakpoints-${infer Alias}`
39-
? Alias
40-
: never;
34+
export const breakpointsAlias = ['xs', 'sm', 'md', 'lg', 'xl'] as const;
35+
export type BreakpointsAlias = typeof breakpointsAlias[number];

polaris-tokens/src/token-groups/depth.ts

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,16 @@ export const depth = {
4545
export type DepthTokenGroup = TokenGroup<typeof depth>;
4646
export type DepthTokenName = keyof DepthTokenGroup;
4747

48-
// temporary until shadows prefix is removed
49-
type ShadowsTokenName = Exclude<DepthTokenName, `shadows-${string}`>;
50-
51-
// e.g. "transparent" | "faint" | "base" | "deep" | ...
52-
export type DepthShadowAlias = ShadowsTokenName extends `shadow-${infer Scale}`
53-
? Scale
54-
: never;
48+
export const depthShadowAlias = [
49+
'base',
50+
'transparent',
51+
'faint',
52+
'deep',
53+
'button',
54+
'top-bar',
55+
'card',
56+
'popover',
57+
'layer',
58+
'modal',
59+
] as const;
60+
export type DepthShadowAlias = typeof depthShadowAlias[number];

polaris-tokens/src/token-groups/font.ts

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -71,26 +71,25 @@ export const font = {
7171
export type FontTokenGroup = TokenGroup<typeof font>;
7272
export type FontTokenName = keyof FontTokenGroup;
7373

74-
// e.g. "400" | "500" | "600" | "700" | "100" | ...
75-
export type FontSizeScale = Extract<
76-
FontTokenName,
77-
`font-size-${number}`
78-
> extends `font-size-${infer Scale}`
79-
? Scale
80-
: never;
74+
export const fontSizeScale = [
75+
'75',
76+
'100',
77+
'200',
78+
'300',
79+
'400',
80+
'500',
81+
'600',
82+
'700',
83+
] as const;
84+
export type FontSizeScale = typeof fontSizeScale[number];
8185

82-
// e.g. "1" | "2" | "3" | "4" | "5" | "6" | "7"
83-
export type FontLineHeightScale = Extract<
84-
FontTokenName,
85-
`font-line-height-${number}`
86-
> extends `font-line-height-${infer Scale}`
87-
? Scale
88-
: never;
86+
export const fontLineHeightScale = ['1', '2', '3', '4', '5', '6', '7'] as const;
87+
export type FontLineHeightScale = typeof fontLineHeightScale[number];
8988

90-
// e.g. "bold" | "regular" | "medium" | "semibold"
91-
export type FontWeightAlias = Extract<
92-
FontTokenName,
93-
`font-weight-${string}`
94-
> extends `font-weight-${infer Alias}`
95-
? Alias
96-
: never;
89+
export const fontWeightAlias = [
90+
'regular',
91+
'medium',
92+
'semibold',
93+
'bold',
94+
] as const;
95+
export type FontWeightAlias = typeof fontWeightAlias[number];

polaris-tokens/src/token-groups/motion.ts

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,26 @@ export const motion = {
7171
export type MotionTokenGroup = TokenGroup<typeof motion>;
7272
export type MotionTokenName = keyof MotionTokenGroup;
7373

74-
// e.g. "0" | "50" | "100" | "150" | ...
75-
export type MotionDurationScale = Extract<
76-
MotionTokenName,
77-
`duration-${number}`
78-
> extends `duration-${infer Scale}`
79-
? Scale
80-
: never;
74+
export const motionDurationScale = [
75+
'0',
76+
'50',
77+
'100',
78+
'150',
79+
'200',
80+
'250',
81+
'300',
82+
'350',
83+
'400',
84+
'450',
85+
'500',
86+
'5000',
87+
] as const;
88+
export type MotionDurationScale = typeof motionDurationScale[number];
8189

82-
// e.g. "bounce" | "fade-in" | "pulse" | "spin"
83-
export type MotionKeyframesAlias = Extract<
84-
MotionTokenName,
85-
`keyframes-${string}`
86-
> extends `keyframes-${infer Alias}`
87-
? Alias
88-
: never;
90+
export const motionKeyframesAlias = [
91+
'bounce',
92+
'fade-in',
93+
'pulse',
94+
'spin',
95+
] as const;
96+
export type MotionKeyframesAlias = typeof motionKeyframesAlias[number];

polaris-tokens/src/token-groups/shape.ts

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -66,23 +66,16 @@ export const shape = {
6666
export type ShapeTokenGroup = TokenGroup<typeof shape>;
6767
export type ShapeTokenName = keyof ShapeTokenGroup;
6868

69-
type ShapeBorderRadiusTokenName = Extract<
70-
ShapeTokenName,
71-
`border-radius-${string}`
72-
>;
69+
export const shapeBorderRadiusScale = [
70+
'05',
71+
'1',
72+
'2',
73+
'3',
74+
'4',
75+
'5',
76+
'6',
77+
] as const;
78+
export type ShapeBorderRadiusScale = typeof shapeBorderRadiusScale[number];
7379

74-
// e.g. "05" | "1" | "2" | "3" | "4" | "5" | "6"
75-
export type ShapeBorderRadiusScale = Extract<
76-
ShapeBorderRadiusTokenName,
77-
`border-radius-${number}`
78-
> extends `border-radius-${infer Scale}`
79-
? Scale
80-
: never;
81-
82-
// e.g. "base" | "large" | "half"
83-
export type ShapeBorderRadiusAlias = Exclude<
84-
ShapeBorderRadiusTokenName,
85-
`border-radius-${number}`
86-
> extends `border-radius-${infer Alias}`
87-
? Alias
88-
: never;
80+
export const shapeBorderRadiusAlias = ['base', 'large', 'half'] as const;
81+
export type ShapeBorderRadiusAlias = typeof shapeBorderRadiusAlias[number];

polaris-tokens/src/token-groups/spacing.ts

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,10 +57,23 @@ export const spacing = {
5757
export type SpacingTokenGroup = TokenGroup<typeof spacing>;
5858
export type SpacingTokenName = keyof SpacingTokenGroup;
5959

60-
// e.g. "0" | "025" | "05" | "1" | "2" | "3" | ...
61-
export type SpacingSpaceScale = Extract<
62-
SpacingTokenName,
63-
`space-${number}`
64-
> extends `space-${infer Scale}`
65-
? Scale
66-
: never;
60+
export const spacingSpaceScale = [
61+
'0',
62+
'025',
63+
'05',
64+
'1',
65+
'2',
66+
'3',
67+
'4',
68+
'5',
69+
'6',
70+
'8',
71+
'10',
72+
'12',
73+
'16',
74+
'20',
75+
'24',
76+
'28',
77+
'32',
78+
] as const;
79+
export type SpacingSpaceScale = typeof spacingSpaceScale[number];

0 commit comments

Comments
 (0)