@astryxdesign/theme-y2k 0.7.3 → 0.7.4-canary.1a552f2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,257 @@
1
+ // Copyright (c) Meta Platforms, Inc. and affiliates.
2
+
3
+ /** Y2K's original mode-independent palette API. */
4
+ export const y2kPalettes = {
5
+ neutral: {
6
+ hue: 75,
7
+ chroma: 8,
8
+ 0: '#000000',
9
+ 5: '#190f00',
10
+ 10: '#221a10',
11
+ 15: '#2d241b',
12
+ 20: '#382f25',
13
+ 25: '#433a30',
14
+ 30: '#4f453b',
15
+ 35: '#5b5146',
16
+ 40: '#675d52',
17
+ 45: '#73695e',
18
+ 50: '#80756a',
19
+ 55: '#8d8276',
20
+ 60: '#9a8f83',
21
+ 65: '#a79c90',
22
+ 70: '#b5a99d',
23
+ 75: '#c3b7ab',
24
+ 80: '#d1c5b8',
25
+ 85: '#dfd2c6',
26
+ 90: '#ede0d4',
27
+ 95: '#fbefe2',
28
+ 100: '#ffffff',
29
+ },
30
+ green: {
31
+ hue: 120,
32
+ chroma: 60,
33
+ 0: '#000000',
34
+ 5: '#061800',
35
+ 10: '#132200',
36
+ 15: '#152d00',
37
+ 20: '#173900',
38
+ 25: '#1e4500',
39
+ 30: '#285100',
40
+ 35: '#355d00',
41
+ 40: '#426900',
42
+ 45: '#4f7600',
43
+ 50: '#5c830b',
44
+ 55: '#69901d',
45
+ 60: '#779d2c',
46
+ 65: '#84aa39',
47
+ 70: '#92b847',
48
+ 75: '#a0c654',
49
+ 80: '#aed461',
50
+ 85: '#bce26e',
51
+ 90: '#caf07b',
52
+ 95: '#d9fe89',
53
+ 100: '#ffffff',
54
+ },
55
+ red: {
56
+ hue: 25,
57
+ chroma: 55,
58
+ 0: '#000000',
59
+ 5: '#480000',
60
+ 10: '#540000',
61
+ 15: '#620002',
62
+ 20: '#700012',
63
+ 25: '#7f001b',
64
+ 30: '#8e1126',
65
+ 35: '#9c2330',
66
+ 40: '#ab313b',
67
+ 45: '#ba3f47',
68
+ 50: '#c94d52',
69
+ 55: '#d95b5e',
70
+ 60: '#e8686b',
71
+ 65: '#f87677',
72
+ 70: '#ff8787',
73
+ 75: '#ff9d9b',
74
+ 80: '#ffb2af',
75
+ 85: '#ffc6c3',
76
+ 90: '#ffd9d7',
77
+ 95: '#ffeceb',
78
+ 100: '#ffffff',
79
+ },
80
+ yellow: {
81
+ hue: 85,
82
+ chroma: 65,
83
+ 0: '#000000',
84
+ 5: '#270c00',
85
+ 10: '#301800',
86
+ 15: '#3b2200',
87
+ 20: '#472c00',
88
+ 25: '#533700',
89
+ 30: '#604200',
90
+ 35: '#6d4d00',
91
+ 40: '#7b5900',
92
+ 45: '#896500',
93
+ 50: '#977100',
94
+ 55: '#a67e00',
95
+ 60: '#b58b01',
96
+ 65: '#c39819',
97
+ 70: '#d2a52a',
98
+ 75: '#e2b239',
99
+ 80: '#f1c047',
100
+ 85: '#ffcd55',
101
+ 90: '#ffde9b',
102
+ 95: '#ffeecf',
103
+ 100: '#ffffff',
104
+ },
105
+ blue: {
106
+ hue: 250,
107
+ chroma: 40,
108
+ 0: '#000000',
109
+ 5: '#001939',
110
+ 10: '#002244',
111
+ 15: '#002c4d',
112
+ 20: '#003759',
113
+ 25: '#004266',
114
+ 30: '#004e74',
115
+ 35: '#005a83',
116
+ 40: '#006693',
117
+ 45: '#0073a3',
118
+ 50: '#0080b4',
119
+ 55: '#008ec4',
120
+ 60: '#0e9bd2',
121
+ 65: '#2fa8e0',
122
+ 70: '#45b6ef',
123
+ 75: '#57c3fd',
124
+ 80: '#7ed0ff',
125
+ 85: '#a3dbff',
126
+ 90: '#c4e7ff',
127
+ 95: '#e1f3ff',
128
+ 100: '#ffffff',
129
+ },
130
+ pink: {
131
+ hue: 350,
132
+ chroma: 45,
133
+ 0: '#000000',
134
+ 5: '#3d001d',
135
+ 10: '#490027',
136
+ 15: '#560032',
137
+ 20: '#64003d',
138
+ 25: '#711248',
139
+ 30: '#7f2154',
140
+ 35: '#8c2f60',
141
+ 40: '#9a3c6c',
142
+ 45: '#a84979',
143
+ 50: '#b75685',
144
+ 55: '#c56392',
145
+ 60: '#d371a0',
146
+ 65: '#e27ead',
147
+ 70: '#f18bbb',
148
+ 75: '#ff99c8',
149
+ 80: '#ffaed3',
150
+ 85: '#ffc3de',
151
+ 90: '#ffd7e9',
152
+ 95: '#ffebf4',
153
+ 100: '#ffffff',
154
+ },
155
+ purple: {
156
+ hue: 300,
157
+ chroma: 40,
158
+ 0: '#000000',
159
+ 5: '#020840',
160
+ 10: '#11144b',
161
+ 15: '#1f1e57',
162
+ 20: '#2c2864',
163
+ 25: '#393370',
164
+ 30: '#453e7d',
165
+ 35: '#524a8a',
166
+ 40: '#5f5697',
167
+ 45: '#6c62a4',
168
+ 50: '#796eb2',
169
+ 55: '#867bc0',
170
+ 60: '#9387ce',
171
+ 65: '#a194dc',
172
+ 70: '#afa2ea',
173
+ 75: '#bdaff8',
174
+ 80: '#cbbeff',
175
+ 85: '#d9ceff',
176
+ 90: '#e6deff',
177
+ 95: '#f3eeff',
178
+ 100: '#ffffff',
179
+ },
180
+ cyan: {
181
+ hue: 185,
182
+ chroma: 35,
183
+ 0: '#000000',
184
+ 5: '#001e14',
185
+ 10: '#00261f',
186
+ 15: '#003029',
187
+ 20: '#003b34',
188
+ 25: '#00473f',
189
+ 30: '#00534a',
190
+ 35: '#005f56',
191
+ 40: '#006c62',
192
+ 45: '#00796f',
193
+ 50: '#00867b',
194
+ 55: '#0f9488',
195
+ 60: '#29a195',
196
+ 65: '#3bafa2',
197
+ 70: '#4cbcb0',
198
+ 75: '#5bcabd',
199
+ 80: '#6ad8cb',
200
+ 85: '#79e7d9',
201
+ 90: '#87f5e7',
202
+ 95: '#a6fff5',
203
+ 100: '#ffffff',
204
+ },
205
+ orange: {
206
+ hue: 60,
207
+ chroma: 60,
208
+ 0: '#000000',
209
+ 5: '#340000',
210
+ 10: '#420500',
211
+ 15: '#520b00',
212
+ 20: '#601700',
213
+ 25: '#6d2400',
214
+ 30: '#7b3000',
215
+ 35: '#893c00',
216
+ 40: '#984800',
217
+ 45: '#a75409',
218
+ 50: '#b66019',
219
+ 55: '#c56d26',
220
+ 60: '#d47a33',
221
+ 65: '#e48740',
222
+ 70: '#f3944c',
223
+ 75: '#ffa25c',
224
+ 80: '#ffb682',
225
+ 85: '#ffc9a3',
226
+ 90: '#ffdbc3',
227
+ 95: '#ffede1',
228
+ 100: '#ffffff',
229
+ },
230
+ teal: {
231
+ hue: 165,
232
+ chroma: 30,
233
+ 0: '#000000',
234
+ 5: '#001d00',
235
+ 10: '#00240f',
236
+ 15: '#002f1a',
237
+ 20: '#003a24',
238
+ 25: '#00462f',
239
+ 30: '#00513a',
240
+ 35: '#115e45',
241
+ 40: '#226a51',
242
+ 45: '#30775d',
243
+ 50: '#3d8469',
244
+ 55: '#4a9175',
245
+ 60: '#589e82',
246
+ 65: '#65ab8f',
247
+ 70: '#72b99c',
248
+ 75: '#7fc7a9',
249
+ 80: '#8dd5b7',
250
+ 85: '#9be3c5',
251
+ 90: '#a9f2d3',
252
+ 95: '#b6ffe1',
253
+ 100: '#ffffff',
254
+ },
255
+ } as const;
256
+
257
+ export default y2kPalettes;
@@ -1,9 +1,31 @@
1
1
  // Copyright (c) Meta Platforms, Inc. and affiliates.
2
2
 
3
+ import {readFileSync} from 'node:fs';
3
4
  import {describe, expect, it} from 'vitest';
4
5
  import {generateThemeCSS} from '@astryxdesign/core/theme';
6
+ import {palette as y2kModePalettes} from './y2kPalettes.generated';
5
7
  import {y2kTheme} from './y2kTheme';
6
8
 
9
+ function luminance(color: string): number {
10
+ const channels = [1, 3, 5]
11
+ .map(index => Number.parseInt(color.slice(index, index + 2), 16) / 255)
12
+ .map(channel =>
13
+ channel <= 0.04045
14
+ ? channel / 12.92
15
+ : Math.pow((channel + 0.055) / 1.055, 2.4),
16
+ );
17
+ return channels[0] * 0.2126 + channels[1] * 0.7152 + channels[2] * 0.0722;
18
+ }
19
+
20
+ function contrast(foreground: string, background: string): number {
21
+ const [lighter, darker] = [luminance(foreground), luminance(background)].sort(
22
+ (left, right) => right - left,
23
+ );
24
+ return (lighter + 0.05) / (darker + 0.05);
25
+ }
26
+
27
+ const source = readFileSync(new URL('./y2kTheme.ts', import.meta.url), 'utf8');
28
+
7
29
  describe('y2k secondary ComplexSelector', () => {
8
30
  it('keeps the hover fill off a disabled trigger in either form', () => {
9
31
  expect(generateThemeCSS(y2kTheme).component).toMatch(
@@ -11,3 +33,41 @@ describe('y2k secondary ComplexSelector', () => {
11
33
  );
12
34
  });
13
35
  });
36
+
37
+ describe('Y2K color token mapping completeness', () => {
38
+ it('does not redefine the data-visualization color system', () => {
39
+ expect(
40
+ Object.keys(y2kTheme.tokens).filter(name =>
41
+ name.startsWith('--color-data-'),
42
+ ),
43
+ ).toEqual([]);
44
+ });
45
+
46
+ it('keeps every root color value concrete', () => {
47
+ for (const [name, value] of Object.entries(y2kTheme.tokens)) {
48
+ if (!name.startsWith('--color-')) {
49
+ continue;
50
+ }
51
+ expect(typeof value, name).toBe('string');
52
+ expect(value, name).toMatch(
53
+ /^(?:transparent|#[0-9a-f]{6}(?:[0-9a-f]{2})?|light-dark\(#[0-9a-f]{6}(?:[0-9a-f]{2})?, #[0-9a-f]{6}(?:[0-9a-f]{2})?\)|color-mix\(.+\)|var\(.+\))$/i,
54
+ );
55
+ }
56
+ });
57
+
58
+ it('uses no one-off color literals in the maintained theme source', () => {
59
+ expect(source).not.toMatch(
60
+ /#[0-9a-f]{3,8}\b|\brgba?\(|\bhsl[a]?\(|\boklch\(|\bblack\b|\bwhite\b/i,
61
+ );
62
+ });
63
+
64
+ it('keeps the necessary dark control outline above non-text contrast', () => {
65
+ const outline = y2kModePalettes.neutral.dark[45];
66
+ const surface = y2kModePalettes.neutral.dark[10];
67
+
68
+ expect(y2kTheme.tokens['--color-border-emphasized']).toBe(
69
+ `light-dark(${y2kModePalettes.neutral.light[20]}, ${outline})`,
70
+ );
71
+ expect(contrast(outline, surface)).toBeGreaterThanOrEqual(3);
72
+ });
73
+ });