@vector-im/compound-design-tokens 10.2.2 → 10.2.4

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.
@@ -339,6 +339,8 @@ export const cpdIconFolder = "icons/folder.svg";
339
339
  export const cpdIconSave = "icons/save.svg";
340
340
  export const cpdIconUnsave = "icons/unsave.svg";
341
341
  export const cpdIconSaveSolid = "icons/save-solid.svg";
342
+ export const cpdIconHourglassSolid = "icons/hourglass-solid.svg";
343
+ export const cpdIconHourglass = "icons/hourglass.svg";
342
344
  export const cpdColorThemeBg = "#ffffff";
343
345
  export const cpdColorGray100 = "#f7f9fa";
344
346
  export const cpdColorGray200 = "#f0f2f5";
@@ -654,6 +656,7 @@ export const cpdColorTextSecondary = "#474a51";
654
656
  export const cpdColorTextDisabled = "#6c737e";
655
657
  export const cpdColorTextActionPrimary = "#1a1c21";
656
658
  export const cpdColorTextActionAccent = "#00553d";
659
+ export const cpdColorTextActionSuccess = "#00553d";
657
660
  export const cpdColorTextLinkExternal = "#043088";
658
661
  export const cpdColorTextCriticalPrimary = "#99001a";
659
662
  export const cpdColorTextSuccessPrimary = "#00553d";
@@ -667,8 +670,10 @@ export const cpdColorTextDecorative5 = "#72003a";
667
670
  export const cpdColorTextDecorative6 = "#770000";
668
671
  export const cpdColorTextBadgeAccent = "#00402b";
669
672
  export const cpdColorTextBadgeInfo = "#043088";
673
+ export const cpdColorTextWarningPrimary = "#931700";
670
674
  export const cpdColorBgSubtlePrimary = "#d7dce3";
671
675
  export const cpdColorBgSubtleSecondary = "#e1e6ec";
676
+ export const cpdColorBgSubtleTertiary = "#f7f9fa";
672
677
  export const cpdColorBgCanvasDefault = "#ffffff";
673
678
  export const cpdColorBgCanvasDisabled = "#f0f2f5";
674
679
  export const cpdColorBgCanvasDefaultLevel1 = "#ffffff";
@@ -687,6 +692,9 @@ export const cpdColorBgCriticalHovered = "#8b000c";
687
692
  export const cpdColorBgCriticalSubtle = "#ffefec";
688
693
  export const cpdColorBgCriticalSubtleHovered = "#ffdfda";
689
694
  export const cpdColorBgSuccessSubtle = "#e3f7ed";
695
+ export const cpdColorBgSuccessRest = "#00553d";
696
+ export const cpdColorBgSuccessHovered = "#004d36";
697
+ export const cpdColorBgSuccessPressed = "#00402b";
690
698
  export const cpdColorBgInfoSubtle = "#e9f2ff";
691
699
  export const cpdColorBgDecorative1 = "#c8f1ba";
692
700
  export const cpdColorBgDecorative2 = "#c7ecf0";
@@ -698,6 +706,7 @@ export const cpdColorBgAccentRest = "#00553d";
698
706
  export const cpdColorBgAccentHovered = "#004d36";
699
707
  export const cpdColorBgAccentPressed = "#00402b";
700
708
  export const cpdColorBgAccentSelected = "hsla(151, 93%, 37%, 0.23)";
709
+ export const cpdColorBgAccentSubtle = "#e3f7ed";
701
710
  export const cpdColorBgBadgeAccent = "#afe8ce";
702
711
  export const cpdColorBgBadgeInfo = "#c8ddfd";
703
712
  export const cpdColorBgBadgeDefault = "#ffffff";
@@ -714,6 +723,7 @@ export const cpdColorBorderCriticalPrimary = "#99001a";
714
723
  export const cpdColorBorderCriticalHovered = "#8b000c";
715
724
  export const cpdColorBorderCriticalSubtle = "#ffafa5";
716
725
  export const cpdColorBorderSuccessSubtle = "#71d7ae";
726
+ export const cpdColorBorderSuccessPrimary = "#00553d";
717
727
  export const cpdColorBorderInfoSubtle = "#4a8ef0";
718
728
  export const cpdColorBorderAccentSubtle = "#00a27c";
719
729
  export const cpdColorBorderAccentPrimary = "#00553d";
@@ -732,6 +742,7 @@ export const cpdColorIconCriticalPrimary = "#99001a";
732
742
  export const cpdColorIconSuccessPrimary = "#00553d";
733
743
  export const cpdColorIconInfoPrimary = "#043088";
734
744
  export const cpdColorIconOnSolidPrimary = "#ffffff";
745
+ export const cpdColorIconWarningPrimary = "#931700";
735
746
  export const cpdColorGradientSubtleStop1 = "hsla(156, 99%, 36%, 0.56)";
736
747
  export const cpdColorGradientSubtleStop2 = "hsla(153, 95%, 37%, 0.32)";
737
748
  export const cpdColorGradientSubtleStop3 = "hsla(151, 93%, 37%, 0.23)";
package/icons/$icons.json CHANGED
@@ -935,6 +935,14 @@
935
935
  "save-solid": {
936
936
  "value": "icons/save-solid.svg",
937
937
  "type": "icon"
938
+ },
939
+ "hourglass-solid": {
940
+ "value": "icons/hourglass-solid.svg",
941
+ "type": "icon"
942
+ },
943
+ "hourglass": {
944
+ "value": "icons/hourglass.svg",
945
+ "type": "icon"
938
946
  }
939
947
  }
940
948
  }
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M20 2a1 1 0 1 1 0 2h-1v3.146l-.004.124a2 2 0 0 1-.865 1.526L13.458 12l4.673 3.204q.085.06.165.127l.023.02q.022.02.043.042.065.058.122.122.029.031.054.065.05.06.097.123l.047.073q.036.058.07.117.027.048.05.1.028.057.052.115l.033.092a2 2 0 0 1 .087.35q.024.15.026.303V20h1a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2h1v-3.146a2 2 0 0 1 .071-.522 2 2 0 0 1 .041-.132l.034-.092.051-.115q.024-.052.05-.1.034-.06.07-.117l.047-.073q.046-.063.097-.123.026-.033.054-.065.058-.064.122-.122.02-.022.043-.042l.023-.02a2 2 0 0 1 .166-.127L10.541 12 5.869 8.796a2 2 0 0 1-.865-1.526L5 7.146V4H4a1 1 0 0 1 0-2zM7 7.146l5 3.43 5-3.43V4H7z" clip-rule="evenodd"/></svg>
@@ -0,0 +1 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M20 2a1 1 0 1 1 0 2h-1v3.146l-.004.124a2 2 0 0 1-.865 1.526L13.458 12l4.673 3.204a2 2 0 0 1 .865 1.526l.004.123V20h1a1 1 0 1 1 0 2H4a1 1 0 1 1 0-2h1v-3.146l.004-.123a2 2 0 0 1 .865-1.527L10.541 12 5.869 8.796a2 2 0 0 1-.865-1.526L5 7.146V4H4a1 1 0 0 1 0-2zM7 16.854V20h10v-3.146l-5-3.43zm0-9.708 5 3.43 5-3.43V4H7z" clip-rule="evenodd"/></svg>
package/package.json CHANGED
@@ -1,17 +1,18 @@
1
1
  {
2
2
  "name": "@vector-im/compound-design-tokens",
3
- "version": "10.2.2",
3
+ "version": "10.2.4",
4
4
  "description": "Compound design tokens",
5
+ "packageManager": "pnpm@11.13.0+sha512.88d94724d8f2e6c186744a5584c6e59ecac869ec7ba15e9cb4cd628e8dc7066820b2481d8ee3b51ea8da323a7378068aa58c556a3720d32b7c20a051d088363a",
5
6
  "sideEffects": false,
6
7
  "scripts": {
7
8
  "build": "vite build && tsx ./build.ts",
8
9
  "sync:icons": "tsx src/syncIcons.ts",
9
10
  "dev": "http-server .",
10
11
  "dev:colors": "vite --open src/colors/applet.html",
11
- "format": "yarn exec biome -- format",
12
- "lint": "yarn exec biome -- lint",
13
- "check": "yarn exec biome -- check",
14
- "types": "yarn exec tsc -- --noEmit"
12
+ "format": "biome format",
13
+ "lint": "biome lint",
14
+ "check": "biome check",
15
+ "types": "tsc --noEmit"
15
16
  },
16
17
  "keywords": [
17
18
  "compound",
@@ -21,7 +22,8 @@
21
22
  ],
22
23
  "files": [
23
24
  "./assets/web/**/*",
24
- "./icons/**/*"
25
+ "./icons/**/*",
26
+ "./src/colors/**/*"
25
27
  ],
26
28
  "main": "assets/web/js/index.js",
27
29
  "type": "module",
@@ -67,6 +69,7 @@
67
69
  "@svgr/plugin-svgo": "^8.1.0",
68
70
  "@tokens-studio/sd-transforms": "^2.0.0",
69
71
  "@types/babel__core": "^7.20.5",
72
+ "@types/babel__generator": "^7.6.8",
70
73
  "@types/fs-extra": "^11.0.4",
71
74
  "@types/lodash-es": "^4.17.12",
72
75
  "@types/node": "^24.0.0",
@@ -80,17 +83,24 @@
80
83
  "style-dictionary": "^5.0.0",
81
84
  "svgo": "^4.0.0",
82
85
  "tsx": "^4.15.6",
83
- "typescript": "^6.0.0",
86
+ "typescript": "^7.0.0",
84
87
  "undici": "^8.0.0",
85
88
  "vite": "^8.0.0",
86
89
  "zod": "^4.0.0"
87
90
  },
88
- "dependencies": {},
89
91
  "peerDependencies": {
92
+ "@adobe/leonardo-contrast-colors": "^1.0.0",
90
93
  "@types/react": "*",
94
+ "chroma-js": "^3.0.0",
91
95
  "react": "^17 || ^18 || ^19.0.0"
92
96
  },
93
97
  "peerDependenciesMeta": {
98
+ "@adobe/leonardo-contrast-colors": {
99
+ "optional": true
100
+ },
101
+ "chroma-js": {
102
+ "optional": true
103
+ },
94
104
  "react": {
95
105
  "optional": true
96
106
  },
@@ -0,0 +1,139 @@
1
+ // https://alphredo.app/js/_calculations.js
2
+
3
+ function roundToTwo(num) {
4
+ return +`${Math.ceil(`${num}e+2`)}e-2`;
5
+ }
6
+
7
+ export const clamp = (num, min, max) => Math.min(Math.max(num, min), max);
8
+
9
+ const hexToRgb = (hex) => {
10
+ const result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
11
+ return [
12
+ Number.parseInt(result[1], 16),
13
+ Number.parseInt(result[2], 16),
14
+ Number.parseInt(result[3], 16),
15
+ ];
16
+ };
17
+
18
+ const rgbToHsl = (r255, g255, b255) => {
19
+ // https://css-tricks.com/converting-color-spaces-in-javascript/
20
+
21
+ // Make r, g, and b fractions of 1
22
+ const r = r255 / 255;
23
+ const g = g255 / 255;
24
+ const b = b255 / 255;
25
+
26
+ // Find greatest and smallest channel values
27
+ const cmin = Math.min(r, g, b);
28
+ const cmax = Math.max(r, g, b);
29
+ const delta = cmax - cmin;
30
+ let h = 0;
31
+ let s = 0;
32
+ let l = 0;
33
+
34
+ // Calculate hue
35
+ // No difference
36
+ if (delta === 0) h = 0;
37
+ // Red is max
38
+ else if (cmax === r) h = ((g - b) / delta) % 6;
39
+ // Green is max
40
+ else if (cmax === g) h = (b - r) / delta + 2;
41
+ // Blue is max
42
+ else h = (r - g) / delta + 4;
43
+
44
+ h = Math.round(h * 60);
45
+
46
+ // Make negative hues positive behind 360°
47
+ if (h < 0) h += 360;
48
+
49
+ // Calculate lightness
50
+ l = (cmax + cmin) / 2;
51
+
52
+ // Calculate saturation
53
+ s = delta === 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
54
+
55
+ // Multiply l and s by 100
56
+ s = +(s * 100).toFixed(1);
57
+ l = +(l * 100).toFixed(1);
58
+
59
+ return [h, s, Math.round(l)];
60
+ };
61
+
62
+ export const hslaToHex = (h, s, l100, alpha) => {
63
+ const l = l100 / 100;
64
+ const a = (s * Math.min(l, 1 - l)) / 100;
65
+ const f = (n) => {
66
+ const k = (n + h / 30) % 12;
67
+ const color = l - a * Math.max(Math.min(k - 3, 9 - k, 1), -1);
68
+ return Math.round(255 * color)
69
+ .toString(16)
70
+ .padStart(2, "0")
71
+ .toUpperCase(); // convert to Hex and prefix "0" if needed
72
+ };
73
+
74
+ const r = f(0);
75
+ const g = f(8);
76
+ const b = f(4);
77
+
78
+ // Clamp alpha to [0,1], convert to 0-255 then to two-digit hex
79
+ const clamp = (v, min, max) => Math.min(Math.max(v, min), max);
80
+ const alphaClamped = clamp(alpha, 0, 1);
81
+ const aHex = Math.round(alphaClamped * 255)
82
+ .toString(16)
83
+ .padStart(2, "0")
84
+ .toUpperCase();
85
+
86
+ return `#${r}${g}${b}${aHex}`;
87
+ };
88
+
89
+ export const getAlphaColor = (colorHex, backgroundHex, strength = 1) => {
90
+ // Convert input HEXes to RGBs (arrays)
91
+ const color = hexToRgb(colorHex);
92
+ const surface = hexToRgb(
93
+ backgroundHex === "white"
94
+ ? "#FFFFFF"
95
+ : backgroundHex === "black"
96
+ ? "#000000"
97
+ : backgroundHex,
98
+ );
99
+
100
+ // Calculate alpha value per channel, pick the highest value
101
+ const alphaPerChannel = color.map((channel, i) => {
102
+ return [
103
+ (channel - surface[i]) / (255 - surface[i]),
104
+ (channel - surface[i]) / (0 - surface[i]),
105
+ ];
106
+ });
107
+
108
+ const alpha = roundToTwo(
109
+ Math.max(
110
+ ...alphaPerChannel.flat().filter((value) => /^-?\d+\.?\d*$/.test(value)),
111
+ ),
112
+ );
113
+
114
+ // Force minimum alpha for opaque colors
115
+ // alpha = Math.min(0.96, alpha);
116
+
117
+ // Calculate new RGB values based on the alpha
118
+ const alphaColor = color.map((channel, i) => {
119
+ return Math.round((channel - surface[i] + surface[i] * alpha) / alpha);
120
+ });
121
+
122
+ // If no alpha color was found, return original, otherwise return alpha color
123
+ if (alphaColor.includes(Number.NaN)) {
124
+ const hsl = rgbToHsl(color[0], color[1], color[2]);
125
+ return {
126
+ h: hsl[0],
127
+ s: Math.round(hsl[1] * strength),
128
+ l: hsl[2],
129
+ a: 1,
130
+ };
131
+ }
132
+ const hsl = rgbToHsl(alphaColor[0], alphaColor[1], alphaColor[2]);
133
+ return {
134
+ h: hsl[0],
135
+ s: Math.round(hsl[1] * strength),
136
+ l: hsl[2],
137
+ a: alpha,
138
+ };
139
+ };
@@ -0,0 +1,40 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <title>Leonardo Color</title>
5
+ <meta charset="UTF-8" />
6
+ <style></style>
7
+ </head>
8
+
9
+ <body>
10
+ <div id="app">
11
+ <h3>Key Colours</h3>
12
+ <div class="key-colors"></div>
13
+ <h3>Themes</h3>
14
+ <div class="themes"></div>
15
+ <details>
16
+ <summary>Show Alpha</summary>
17
+ <div class="themes-alpha"></div>
18
+ </details>
19
+ <div class="tests"></div>
20
+ <h3>Tokens Studio</h3>
21
+ <div class="tokens-studio"></div>
22
+ <h3>CSS Vars</h3>
23
+ <div class="css-vars">
24
+ <details>
25
+ <summary>Show</summary>
26
+ <pre class="css-vars__output"></pre>
27
+ </details>
28
+ </div>
29
+ <h3>Leonardo Editor</h3>
30
+ <div class="leonardo-editor">
31
+ <details>
32
+ <summary>Show</summary>
33
+ <div class="leonardo-editor__links"></div>
34
+ </details>
35
+ </div>
36
+ </div>
37
+
38
+ <script type="module" src="applet.js"></script>
39
+ </body>
40
+ </html>