Skip to content

Commit 93e2d42

Browse files
Add experimental colors (#9241)
### WHY are these changes introduced? ### WHAT is this pull request doing? Adds a bit of experimental coloring <!-- ℹ️ Delete the following for small / trivial changes --> ### How to 🎩 🖥 [Local development instructions](https://github.com/Shopify/polaris/blob/main/README.md#local-development) 🗒 [General tophatting guidelines](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md) 📄 [Changelog guidelines](https://github.com/Shopify/polaris/blob/main/.github/CONTRIBUTING.md#changelog) <!-- Give as much information as needed to experiment with the component in the playground. --> <details> <summary>Copy-paste this code in <code>playground/Playground.tsx</code>:</summary> ```jsx import React from 'react'; import {Page} from '../src'; export function Playground() { return ( <Page title="Playground"> {/* Add the code you want to test in here */} </Page> ); } ``` </details> ### 🎩 checklist - [ ] Tested on [mobile](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting.md#cross-browser-testing) - [ ] Tested on [multiple browsers](https://help.shopify.com/en/manual/shopify-admin/supported-browsers) - [ ] Tested for [accessibility](https://github.com/Shopify/polaris/blob/main/documentation/Accessibility%20testing.md) - [ ] Updated the component's `README.md` with documentation changes - [ ] [Tophatted documentation](https://github.com/Shopify/polaris/blob/main/documentation/Tophatting%20documentation.md) changes in the style guide --------- Co-authored-by: Aaron Casanova <32409546+aaronccasanova@users.noreply.github.com>
1 parent 8ea80f0 commit 93e2d42

File tree

5 files changed

+314
-6
lines changed

5 files changed

+314
-6
lines changed

polaris-react/src/components/Button/Button.scss

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,6 @@
215215
--pc-button-color-hover: var(--p-color-bg-primary-hover);
216216
--pc-button-color-active: var(--p-color-bg-primary-active);
217217
--pc-button-color-depressed: var(--p-color-bg-primary-active);
218-
219-
#{$se23} & {
220-
--pc-button-color: var(--p-text);
221-
}
222218
// stylelint-enable
223219

224220
svg {

polaris-tokens/scripts/toStyleSheet.ts

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import fs from 'fs';
22
import path from 'path';
33

44
import type {Metadata, MetadataGroup} from '../src';
5+
import type {MetadataBase} from '../src/types';
56

67
const cssOutputDir = path.join(__dirname, '../dist/css');
78
const sassOutputDir = path.join(__dirname, '../dist/scss');
@@ -18,6 +19,31 @@ export function getStaticCustomProperties(metadata: Metadata) {
1819
.join('');
1920
}
2021

22+
/**
23+
* Creates static CSS custom properties overrides.
24+
* Note: These values don't vary by color-scheme.
25+
*/
26+
export function getStaticCustomPropertiesExperimental(metadata: MetadataBase) {
27+
return Object.entries(metadata)
28+
.map(([_, tokenGroup]) =>
29+
getCustomProperties(
30+
Object.fromEntries(
31+
Object.entries(tokenGroup)
32+
// Only include tokens with `valueExperimental` prop
33+
.filter(([_, metadataProperties]) =>
34+
Boolean(metadataProperties.valueExperimental),
35+
)
36+
// Move `valueExperimental` to `value` position
37+
.map(([tokenName, metadataProperties]) => [
38+
tokenName,
39+
{value: metadataProperties.valueExperimental!},
40+
]),
41+
),
42+
),
43+
)
44+
.join('');
45+
}
46+
2147
/**
2248
* Creates CSS custom properties for a given metadata object.
2349
*/
@@ -53,7 +79,10 @@ export async function toStyleSheet(metadata: Metadata) {
5379
}
5480

5581
const styles = `
56-
:root{color-scheme:light;${getStaticCustomProperties(metadata)}}
82+
:where(html){color-scheme:light;${getStaticCustomProperties(metadata)}}
83+
:where(html.Polaris-Summer-Editions-2023){${getStaticCustomPropertiesExperimental(
84+
metadata,
85+
)}}
5786
${getKeyframes(metadata.motion)}
5887
`;
5988

Lines changed: 268 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,268 @@
1+
type ColorScale =
2+
| '1'
3+
| '2'
4+
| '3'
5+
| '4'
6+
| '5'
7+
| '6'
8+
| '7'
9+
| '8'
10+
| '9'
11+
| '10'
12+
| '11'
13+
| '12'
14+
| '13'
15+
| '14'
16+
| '15'
17+
| '16';
18+
19+
type Color = {
20+
[Scale in ColorScale]: string;
21+
};
22+
23+
export const gray: Color = {
24+
'1': 'rgba(255, 255, 255, 1)',
25+
'2': 'rgba(253, 253, 253, 1)',
26+
'3': 'rgba(250, 250, 250, 1)',
27+
'4': 'rgba(247, 247, 247, 1)',
28+
'5': 'rgba(243, 243, 243, 1)',
29+
'6': 'rgba(241, 241, 241, 1)',
30+
'7': 'rgba(235, 235, 235, 1)',
31+
'8': 'rgba(227, 227, 227, 1)',
32+
'9': 'rgba(212, 212, 212, 1)',
33+
'10': 'rgba(204, 204, 204, 1)',
34+
'11': 'rgba(181, 181, 181, 1)',
35+
'12': 'rgba(138, 138, 138, 1)',
36+
'13': 'rgba(97, 97, 97, 1)',
37+
'14': 'rgba(74, 74, 74, 1)',
38+
'15': 'rgba(48, 48, 48, 1)',
39+
'16': 'rgba(26, 26, 26, 1)',
40+
};
41+
42+
export const azure: Color = {
43+
'1': 'rgba(251, 253, 255, 1)',
44+
'2': 'rgba(242, 249, 255, 1)',
45+
'3': 'rgba(234, 244, 255, 1)',
46+
'4': 'rgba(224, 240, 255, 1)',
47+
'5': 'rgba(213, 235, 255, 1)',
48+
'6': 'rgba(202, 230, 255, 1)',
49+
'7': 'rgba(192, 225, 255, 1)',
50+
'8': 'rgba(168, 216, 255, 1)',
51+
'9': 'rgba(145, 208, 255, 1)',
52+
'10': 'rgba(81, 192, 255, 1)',
53+
'11': 'rgba(0, 148, 213, 1)',
54+
'12': 'rgba(0, 124, 180, 1)',
55+
'13': 'rgba(0, 103, 155, 1)',
56+
'14': 'rgba(0, 82, 124, 1)',
57+
'15': 'rgba(0, 58, 90, 1)',
58+
'16': 'rgba(0, 33, 51, 1)',
59+
};
60+
61+
export const blue: Color = {
62+
'1': 'rgba(252, 253, 255, 1)',
63+
'2': 'rgba(246, 248, 255, 1)',
64+
'3': 'rgba(240, 242, 255, 1)',
65+
'4': 'rgba(234, 237, 255, 1)',
66+
'5': 'rgba(226, 231, 255, 1)',
67+
'6': 'rgba(219, 225, 255, 1)',
68+
'7': 'rgba(213, 220, 255, 1)',
69+
'8': 'rgba(197, 208, 255, 1)',
70+
'9': 'rgba(186, 199, 255, 1)',
71+
'10': 'rgba(151, 173, 255, 1)',
72+
'11': 'rgba(65, 136, 255, 1)',
73+
'12': 'rgba(0, 113, 233, 1)',
74+
'13': 'rgba(0, 91, 211, 1)',
75+
'14': 'rgba(0, 66, 153, 1)',
76+
'15': 'rgba(0, 46, 106, 1)',
77+
'16': 'rgba(0, 22, 51, 1)',
78+
};
79+
80+
export const cyan: Color = {
81+
'1': 'rgba(250, 255, 254, 1)',
82+
'2': 'rgba(231, 252, 248, 1)',
83+
'3': 'rgba(215, 251, 243, 1)',
84+
'4': 'rgba(192, 249, 239, 1)',
85+
'5': 'rgba(165, 247, 233, 1)',
86+
'6': 'rgba(144, 244, 227, 1)',
87+
'7': 'rgba(146, 237, 222, 1)',
88+
'8': 'rgba(130, 227, 209, 1)',
89+
'9': 'rgba(116, 219, 200, 1)',
90+
'10': 'rgba(23, 199, 167, 1)',
91+
'11': 'rgba(19, 163, 137, 1)',
92+
'12': 'rgba(14, 132, 112, 1)',
93+
'13': 'rgba(8, 107, 90, 1)',
94+
'14': 'rgba(9, 83, 70, 1)',
95+
'15': 'rgba(6, 56, 47, 1)',
96+
'16': 'rgba(5, 36, 30, 1)',
97+
};
98+
99+
export const green: Color = {
100+
'1': 'rgba(248, 255, 251, 1)',
101+
'2': 'rgba(227, 255, 237, 1)',
102+
'3': 'rgba(205, 254, 225, 1)',
103+
'4': 'rgba(180, 254, 210, 1)',
104+
'5': 'rgba(146, 254, 194, 1)',
105+
'6': 'rgba(99, 253, 176, 1)',
106+
'7': 'rgba(56, 250, 163, 1)',
107+
'8': 'rgba(53, 238, 155, 1)',
108+
'9': 'rgba(50, 225, 147, 1)',
109+
'10': 'rgba(46, 211, 137, 1)',
110+
'11': 'rgba(50, 160, 110, 1)',
111+
'12': 'rgba(41, 132, 90, 1)',
112+
'13': 'rgba(19, 111, 69, 1)',
113+
'14': 'rgba(12, 81, 50, 1)',
114+
'15': 'rgba(8, 61, 37, 1)',
115+
'16': 'rgba(9, 42, 27, 1)',
116+
};
117+
118+
export const lime: Color = {
119+
'1': 'rgba(250, 255, 250, 1)',
120+
'2': 'rgba(228, 255, 229, 1)',
121+
'3': 'rgba(208, 255, 209, 1)',
122+
'4': 'rgba(187, 254, 190, 1)',
123+
'5': 'rgba(157, 254, 160, 1)',
124+
'6': 'rgba(119, 254, 122, 1)',
125+
'7': 'rgba(56, 254, 62, 1)',
126+
'8': 'rgba(40, 242, 47, 1)',
127+
'9': 'rgba(37, 232, 43, 1)',
128+
'10': 'rgba(32, 207, 39, 1)',
129+
'11': 'rgba(24, 168, 29, 1)',
130+
'12': 'rgba(17, 135, 21, 1)',
131+
'13': 'rgba(12, 113, 15, 1)',
132+
'14': 'rgba(11, 85, 13, 1)',
133+
'15': 'rgba(3, 61, 5, 1)',
134+
'16': 'rgba(3, 33, 4, 1)',
135+
};
136+
137+
export const magenta: Color = {
138+
'1': 'rgba(255, 253, 255, 1)',
139+
'2': 'rgba(255, 245, 255, 1)',
140+
'3': 'rgba(253, 239, 253, 1)',
141+
'4': 'rgba(254, 231, 254, 1)',
142+
'5': 'rgba(252, 223, 252, 1)',
143+
'6': 'rgba(251, 215, 251, 1)',
144+
'7': 'rgba(251, 207, 251, 1)',
145+
'8': 'rgba(249, 190, 249, 1)',
146+
'9': 'rgba(248, 177, 248, 1)',
147+
'10': 'rgba(246, 141, 246, 1)',
148+
'11': 'rgba(225, 86, 225, 1)',
149+
'12': 'rgba(197, 48, 197, 1)',
150+
'13': 'rgba(159, 38, 159, 1)',
151+
'14': 'rgba(121, 26, 121, 1)',
152+
'15': 'rgba(86, 16, 86, 1)',
153+
'16': 'rgba(52, 6, 52, 1)',
154+
};
155+
156+
export const orange: Color = {
157+
'1': 'rgba(255, 253, 250, 1)',
158+
'2': 'rgba(255, 247, 238, 1)',
159+
'3': 'rgba(255, 241, 227, 1)',
160+
'4': 'rgba(255, 235, 213, 1)',
161+
'5': 'rgba(255, 228, 198, 1)',
162+
'6': 'rgba(255, 221, 182, 1)',
163+
'7': 'rgba(255, 214, 164, 1)',
164+
'8': 'rgba(255, 200, 121, 1)',
165+
'9': 'rgba(255, 184, 0, 1)',
166+
'10': 'rgba(229, 165, 0, 1)',
167+
'11': 'rgba(178, 132, 0, 1)',
168+
'12': 'rgba(149, 111, 0, 1)',
169+
'13': 'rgba(124, 88, 0, 1)',
170+
'14': 'rgba(94, 66, 0, 1)',
171+
'15': 'rgba(65, 45, 0, 1)',
172+
'16': 'rgba(37, 26, 0, 1)',
173+
};
174+
175+
export const purple: Color = {
176+
'1': 'rgba(253, 253, 255, 1)',
177+
'2': 'rgba(248, 247, 255, 1)',
178+
'3': 'rgba(243, 241, 255, 1)',
179+
'4': 'rgba(239, 236, 255, 1)',
180+
'5': 'rgba(233, 229, 255, 1)',
181+
'6': 'rgba(228, 222, 255, 1)',
182+
'7': 'rgba(223, 217, 255, 1)',
183+
'8': 'rgba(212, 204, 255, 1)',
184+
'9': 'rgba(199, 188, 255, 1)',
185+
'10': 'rgba(170, 149, 255, 1)',
186+
'11': 'rgba(148, 116, 255, 1)',
187+
'12': 'rgba(128, 81, 255, 1)',
188+
'13': 'rgba(113, 38, 255, 1)',
189+
'14': 'rgba(87, 0, 209, 1)',
190+
'15': 'rgba(59, 0, 147, 1)',
191+
'16': 'rgba(28, 0, 79, 1)',
192+
};
193+
194+
export const red: Color = {
195+
'1': 'rgba(255, 251, 251, 1)',
196+
'2': 'rgba(255, 246, 246, 1)',
197+
'3': 'rgba(255, 237, 236, 1)',
198+
'4': 'rgba(254, 233, 232, 1)',
199+
'5': 'rgba(254, 226, 225, 1)',
200+
'6': 'rgba(254, 218, 217, 1)',
201+
'7': 'rgba(254, 211, 209, 1)',
202+
'8': 'rgba(254, 195, 193, 1)',
203+
'9': 'rgba(253, 176, 172, 1)',
204+
'10': 'rgba(253, 129, 122, 1)',
205+
'11': 'rgba(239, 77, 47, 1)',
206+
'12': 'rgba(229, 28, 0, 1)',
207+
'13': 'rgba(181, 38, 11, 1)',
208+
'14': 'rgba(142, 31, 11, 1)',
209+
'15': 'rgba(95, 21, 7, 1)',
210+
'16': 'rgba(47, 10, 4, 1)',
211+
};
212+
213+
export const rose: Color = {
214+
'1': 'rgba(255, 253, 253, 1)',
215+
'2': 'rgba(255, 246, 248, 1)',
216+
'3': 'rgba(255, 239, 243, 1)',
217+
'4': 'rgba(255, 232, 238, 1)',
218+
'5': 'rgba(255, 225, 232, 1)',
219+
'6': 'rgba(255, 217, 227, 1)',
220+
'7': 'rgba(254, 209, 221, 1)',
221+
'8': 'rgba(254, 193, 210, 1)',
222+
'9': 'rgba(254, 181, 202, 1)',
223+
'10': 'rgba(254, 142, 177, 1)',
224+
'11': 'rgba(253, 75, 146, 1)',
225+
'12': 'rgba(227, 12, 118, 1)',
226+
'13': 'rgba(185, 7, 95, 1)',
227+
'14': 'rgba(141, 4, 72, 1)',
228+
'15': 'rgba(100, 2, 49, 1)',
229+
'16': 'rgba(62, 1, 28, 1)',
230+
};
231+
232+
export const teal: Color = {
233+
'1': 'rgba(248, 255, 254, 1)',
234+
'2': 'rgba(232, 252, 250, 1)',
235+
'3': 'rgba(215, 250, 247, 1)',
236+
'4': 'rgba(195, 247, 242, 1)',
237+
'5': 'rgba(170, 246, 239, 1)',
238+
'6': 'rgba(137, 245, 236, 1)',
239+
'7': 'rgba(112, 240, 229, 1)',
240+
'8': 'rgba(90, 230, 219, 1)',
241+
'9': 'rgba(44, 224, 212, 1)',
242+
'10': 'rgba(30, 199, 188, 1)',
243+
'11': 'rgba(0, 161, 152, 1)',
244+
'12': 'rgba(18, 131, 124, 1)',
245+
'13': 'rgba(12, 106, 100, 1)',
246+
'14': 'rgba(12, 83, 79, 1)',
247+
'15': 'rgba(3, 60, 57, 1)',
248+
'16': 'rgba(6, 44, 41, 1)',
249+
};
250+
251+
export const yellow: Color = {
252+
'1': 'rgba(255, 253, 246, 1)',
253+
'2': 'rgba(255, 248, 219, 1)',
254+
'3': 'rgba(255, 244, 191, 1)',
255+
'4': 'rgba(255, 239, 157, 1)',
256+
'5': 'rgba(255, 235, 120, 1)',
257+
'6': 'rgba(255, 230, 0, 1)',
258+
'7': 'rgba(247, 223, 0, 1)',
259+
'8': 'rgba(234, 211, 0, 1)',
260+
'9': 'rgba(225, 203, 0, 1)',
261+
'10': 'rgba(197, 178, 0, 1)',
262+
'11': 'rgba(153, 138, 0, 1)',
263+
'12': 'rgba(130, 117, 0, 1)',
264+
'13': 'rgba(105, 95, 0, 1)',
265+
'14': 'rgba(79, 71, 0, 1)',
266+
'15': 'rgba(51, 46, 0, 1)',
267+
'16': 'rgba(31, 28, 0, 1)',
268+
};

0 commit comments

Comments
 (0)