Skip to content

Commit 7d1c4f1

Browse files
authored
Add new shadow tokens (#8572)
### WHY are these changes introduced? Part of #8571 This PR introduces new `shadow` tokens. These new token name have no conflicts with the existing `depth` tokens, which means the new values can temporarily coexist with the legacy values. In addition to being able to ship these semantic alias tokens now, we can start migrating to the new tokens in Polaris and in Web, before removing legacy tokens in the Polaris v11 release. ### WHAT is this pull request doing? Adds the following tokens to a new `shadow` token group (based on [this Figma file](https://www.figma.com/file/Z5cnrNV7Ild1pGSOM5bRSC/New-Polaris-Shadow-Tokens?node-id=148%3A50776&t=CZA7A9DIaerRS1Qb-11)): | Name | Value | | ------------------------- | ------------------------ | | `--p-shadow-inset-lg` |`inset 0px 0px 7px 2px rgba(31, 33, 36, 0.18)` | | `--p-shadow-inset-md` | `inset 0px 2px 4px rgba(31, 33, 36, 0.32)`| | `--p-shadow-inset-sm` |`inset 0px 0px 3px rgba(31, 33, 36, 0.56)`| | `--p-shadow-none` |`none`| | `--p-shadow-xs` |`0px 0px 2px rgba(31, 33, 36, 0.24)`| | `--p-shadow-sm` |`0px 1px 1px rgba(31, 33, 36, 0.1)`| | `--p-shadow-md` |`0px 2px 4px rgba(31, 33, 36, 0.1), 0px 1px 6px rgba(31, 33, 36, 0.05)`| | `--p-shadow-lg` |`0px 4px 12px rgba(31, 33, 36, 0.2), 0px 2px 6px rgba(31, 33, 36, 0.05)`| | `--p-shadow-xl` |`0px 4px 18px -2px rgba(31, 33, 36, 0.08), 0px 12px 18px -2px rgba(31, 33, 36, 0.15)`| | `--p-shadow-2xl` |`0px 32px 32px rgba(31, 33, 36, 0.15), 0px 32px 56px -2px rgba(31, 33, 36, 0.16)`|
1 parent a0e52a3 commit 7d1c4f1

File tree

6 files changed

+81
-4
lines changed

6 files changed

+81
-4
lines changed

.changeset/thick-plants-fail.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'polaris-for-vscode': minor
3+
---
4+
5+
Added completions for new `shadow` token group

.changeset/wet-balloons-whisper.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@shopify/polaris-tokens': minor
3+
---
4+
5+
Added a new `shadow` token group

polaris-for-vscode/src/server.ts

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,13 @@ const groupedCompletionItemPatterns: GroupedCompletionItemPatterns = {
7070
/color|background|shadow|border|column-rule|filter|opacity|outline|text-decoration/,
7171
colors:
7272
/color|background|shadow|border|column-rule|filter|opacity|outline|text-decoration/,
73-
spacing: /margin|padding|gap|top|left|right|bottom/,
74-
font: /font|line-height/,
75-
zIndex: /z-index/,
76-
shape: /border/,
7773
depth: /shadow/,
74+
font: /font|line-height/,
7875
motion: /animation/,
76+
shadow: /shadow/,
77+
shape: /border/,
78+
spacing: /margin|padding|gap|top|left|right|bottom/,
79+
zIndex: /z-index/,
7980
};
8081

8182
connection.onInitialize((params: InitializeParams) => {

polaris-tokens/src/index.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,12 @@ export type {
5656
MotionKeyframesAlias,
5757
} from './token-groups/motion';
5858

59+
export type {
60+
ShadowTokenGroup,
61+
ShadowTokenName,
62+
ShadowAlias,
63+
} from './token-groups/shadow';
64+
5965
export type {
6066
ShapeTokenGroup,
6167
ShapeTokenName,

polaris-tokens/src/metadata.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {legacy} from './token-groups/legacy';
77
import {color} from './token-groups/color';
88
import {colors} from './token-groups/colors';
99
import {motion} from './token-groups/motion';
10+
import {shadow} from './token-groups/shadow';
1011
import {shape} from './token-groups/shape';
1112
import {spacing} from './token-groups/spacing';
1213
import {zIndex} from './token-groups/zIndex';
@@ -19,6 +20,7 @@ export const metadata = createMetadata({
1920
font: tokensToRems(font),
2021
legacy: tokensToRems(legacy),
2122
motion,
23+
shadow: tokensToRems(shadow),
2224
shape: tokensToRems(shape),
2325
spacing: tokensToRems(spacing),
2426
zIndex,
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import type {MetadataProperties} from '../types';
2+
3+
export type ShadowAlias =
4+
| 'inset-lg'
5+
| 'inset-md'
6+
| 'inset-sm'
7+
| 'none'
8+
| 'xs'
9+
| 'sm'
10+
| 'md'
11+
| 'lg'
12+
| 'xl'
13+
| '2xl';
14+
15+
export type ShadowTokenName = `shadow-${ShadowAlias}`;
16+
17+
export type ShadowTokenGroup = {
18+
[TokenName in ShadowTokenName]: string;
19+
};
20+
21+
export const shadow: {
22+
[TokenName in ShadowTokenName]: MetadataProperties;
23+
} = {
24+
'shadow-inset-lg': {
25+
value: 'inset 0px 0px 7px 2px rgba(31, 33, 36, 0.18)',
26+
},
27+
'shadow-inset-md': {
28+
value: 'inset 0px 2px 4px rgba(31, 33, 36, 0.32)',
29+
},
30+
'shadow-inset-sm': {
31+
value: 'inset 0px 0px 3px rgba(31, 33, 36, 0.56)',
32+
},
33+
'shadow-none': {
34+
value: 'none',
35+
},
36+
'shadow-xs': {
37+
value: '0px 0px 2px rgba(31, 33, 36, 0.24)',
38+
},
39+
'shadow-sm': {
40+
value: '0px 1px 1px rgba(31, 33, 36, 0.1)',
41+
},
42+
'shadow-md': {
43+
value:
44+
'0px 2px 4px rgba(31, 33, 36, 0.1), 0px 1px 6px rgba(31, 33, 36, 0.05)',
45+
},
46+
'shadow-lg': {
47+
value:
48+
'0px 4px 12px rgba(31, 33, 36, 0.2), 0px 2px 6px rgba(31, 33, 36, 0.05)',
49+
},
50+
'shadow-xl': {
51+
value:
52+
'0px 4px 18px -2px rgba(31, 33, 36, 0.08), 0px 12px 18px -2px rgba(31, 33, 36, 0.15)',
53+
},
54+
'shadow-2xl': {
55+
value:
56+
'0px 32px 32px rgba(31, 33, 36, 0.15), 0px 32px 56px -2px rgba(31, 33, 36, 0.16)',
57+
},
58+
};

0 commit comments

Comments
 (0)