@vector-im/compound-design-tokens 10.2.3 → 11.0.0
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.
- package/assets/web/icons/hourglass-solid.cjs +21 -0
- package/assets/web/icons/hourglass-solid.d.ts +11 -0
- package/assets/web/icons/hourglass-solid.js +21 -0
- package/assets/web/icons/hourglass.cjs +21 -0
- package/assets/web/icons/hourglass.d.ts +11 -0
- package/assets/web/icons/hourglass.js +21 -0
- package/assets/web/icons/index.cjs +2 -0
- package/assets/web/icons/index.d.ts +2 -0
- package/assets/web/icons/index.js +2 -0
- package/assets/web/js/cpdDark.d.ts +2 -0
- package/assets/web/js/cpdDark.js +2 -0
- package/assets/web/js/cpdDarkHc.d.ts +2 -0
- package/assets/web/js/cpdDarkHc.js +2 -0
- package/assets/web/js/cpdLight.d.ts +2 -0
- package/assets/web/js/cpdLight.js +2 -0
- package/assets/web/js/cpdLightHc.d.ts +2 -0
- package/assets/web/js/cpdLightHc.js +2 -0
- package/icons/$icons.json +8 -0
- package/icons/hourglass-solid.svg +1 -0
- package/icons/hourglass.svg +1 -0
- package/package.json +13 -4
- package/src/colors/alphredo.js +139 -0
- package/src/colors/applet.html +40 -0
- package/src/colors/applet.js +510 -0
- package/src/colors/styles.css +258 -0
- package/src/colors/theme.js +239 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var _reactJsxRuntime = require("react/jsx-runtime");
|
|
2
|
+
var React = require("react");
|
|
3
|
+
function HourglassSolidIcon(props, ref) {
|
|
4
|
+
return /*#__PURE__*/_reactJsxRuntime.jsx("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
fill: "currentColor",
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
ref: ref,
|
|
11
|
+
...props,
|
|
12
|
+
children: /*#__PURE__*/_reactJsxRuntime.jsx("path", {
|
|
13
|
+
fillRule: "evenodd",
|
|
14
|
+
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",
|
|
15
|
+
clipRule: "evenodd"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
|
+
HourglassSolidIcon.displayName = "HourglassSolidIcon";
|
|
21
|
+
module.exports = React.forwardRef(HourglassSolidIcon);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* hourglass-solid.svg
|
|
5
|
+
*/
|
|
6
|
+
declare const HourglassSolidIcon: React.ForwardRefExoticComponent<
|
|
7
|
+
Omit<React.SVGProps<SVGSVGElement>, "ref" | "children"> &
|
|
8
|
+
React.RefAttributes<SVGSVGElement>
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export default HourglassSolidIcon;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
function HourglassSolidIcon(props, ref) {
|
|
4
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
fill: "currentColor",
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
ref: ref,
|
|
11
|
+
...props,
|
|
12
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
13
|
+
fillRule: "evenodd",
|
|
14
|
+
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",
|
|
15
|
+
clipRule: "evenodd"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
|
+
HourglassSolidIcon.displayName = "HourglassSolidIcon";
|
|
21
|
+
export default forwardRef(HourglassSolidIcon);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
var _reactJsxRuntime = require("react/jsx-runtime");
|
|
2
|
+
var React = require("react");
|
|
3
|
+
function HourglassIcon(props, ref) {
|
|
4
|
+
return /*#__PURE__*/_reactJsxRuntime.jsx("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
fill: "currentColor",
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
ref: ref,
|
|
11
|
+
...props,
|
|
12
|
+
children: /*#__PURE__*/_reactJsxRuntime.jsx("path", {
|
|
13
|
+
fillRule: "evenodd",
|
|
14
|
+
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",
|
|
15
|
+
clipRule: "evenodd"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
|
+
HourglassIcon.displayName = "HourglassIcon";
|
|
21
|
+
module.exports = React.forwardRef(HourglassIcon);
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* hourglass.svg
|
|
5
|
+
*/
|
|
6
|
+
declare const HourglassIcon: React.ForwardRefExoticComponent<
|
|
7
|
+
Omit<React.SVGProps<SVGSVGElement>, "ref" | "children"> &
|
|
8
|
+
React.RefAttributes<SVGSVGElement>
|
|
9
|
+
>;
|
|
10
|
+
|
|
11
|
+
export default HourglassIcon;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { forwardRef } from "react";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
function HourglassIcon(props, ref) {
|
|
4
|
+
return /*#__PURE__*/_jsx("svg", {
|
|
5
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
6
|
+
width: "1em",
|
|
7
|
+
height: "1em",
|
|
8
|
+
fill: "currentColor",
|
|
9
|
+
viewBox: "0 0 24 24",
|
|
10
|
+
ref: ref,
|
|
11
|
+
...props,
|
|
12
|
+
children: /*#__PURE__*/_jsx("path", {
|
|
13
|
+
fillRule: "evenodd",
|
|
14
|
+
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",
|
|
15
|
+
clipRule: "evenodd"
|
|
16
|
+
})
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
;
|
|
20
|
+
HourglassIcon.displayName = "HourglassIcon";
|
|
21
|
+
export default forwardRef(HourglassIcon);
|
|
@@ -87,6 +87,8 @@ module.exports = {
|
|
|
87
87
|
HomeSolidIcon: require("./home-solid.cjs"),
|
|
88
88
|
HomeIcon: require("./home.cjs"),
|
|
89
89
|
HostIcon: require("./host.cjs"),
|
|
90
|
+
HourglassSolidIcon: require("./hourglass-solid.cjs"),
|
|
91
|
+
HourglassIcon: require("./hourglass.cjs"),
|
|
90
92
|
ImageErrorIcon: require("./image-error.cjs"),
|
|
91
93
|
ImageIcon: require("./image.cjs"),
|
|
92
94
|
IndentDecreaseIcon: require("./indent-decrease.cjs"),
|
|
@@ -86,6 +86,8 @@ export { default as HistoryIcon } from "./history.js";
|
|
|
86
86
|
export { default as HomeSolidIcon } from "./home-solid.js";
|
|
87
87
|
export { default as HomeIcon } from "./home.js";
|
|
88
88
|
export { default as HostIcon } from "./host.js";
|
|
89
|
+
export { default as HourglassSolidIcon } from "./hourglass-solid.js";
|
|
90
|
+
export { default as HourglassIcon } from "./hourglass.js";
|
|
89
91
|
export { default as ImageErrorIcon } from "./image-error.js";
|
|
90
92
|
export { default as ImageIcon } from "./image.js";
|
|
91
93
|
export { default as IndentDecreaseIcon } from "./indent-decrease.js";
|
|
@@ -86,6 +86,8 @@ export { default as HistoryIcon } from "./history.js";
|
|
|
86
86
|
export { default as HomeSolidIcon } from "./home-solid.js";
|
|
87
87
|
export { default as HomeIcon } from "./home.js";
|
|
88
88
|
export { default as HostIcon } from "./host.js";
|
|
89
|
+
export { default as HourglassSolidIcon } from "./hourglass-solid.js";
|
|
90
|
+
export { default as HourglassIcon } from "./hourglass.js";
|
|
89
91
|
export { default as ImageErrorIcon } from "./image-error.js";
|
|
90
92
|
export { default as ImageIcon } from "./image.js";
|
|
91
93
|
export { default as IndentDecreaseIcon } from "./indent-decrease.js";
|
|
@@ -311,6 +311,8 @@ export const cpdIconFolder: string;
|
|
|
311
311
|
export const cpdIconSave: string;
|
|
312
312
|
export const cpdIconUnsave: string;
|
|
313
313
|
export const cpdIconSaveSolid: string;
|
|
314
|
+
export const cpdIconHourglassSolid: string;
|
|
315
|
+
export const cpdIconHourglass: string;
|
|
314
316
|
export const cpdColorThemeBg: string;
|
|
315
317
|
export const cpdColorGray100: string;
|
|
316
318
|
export const cpdColorGray200: string;
|
package/assets/web/js/cpdDark.js
CHANGED
|
@@ -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 = "#101317";
|
|
343
345
|
export const cpdColorGray100 = "#14171b";
|
|
344
346
|
export const cpdColorGray200 = "#181a1f";
|
|
@@ -311,6 +311,8 @@ export const cpdIconFolder: string;
|
|
|
311
311
|
export const cpdIconSave: string;
|
|
312
312
|
export const cpdIconUnsave: string;
|
|
313
313
|
export const cpdIconSaveSolid: string;
|
|
314
|
+
export const cpdIconHourglassSolid: string;
|
|
315
|
+
export const cpdIconHourglass: string;
|
|
314
316
|
export const cpdColorThemeBg: string;
|
|
315
317
|
export const cpdColorGray100: string;
|
|
316
318
|
export const cpdColorGray200: string;
|
|
@@ -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 = "#101317";
|
|
343
345
|
export const cpdColorGray100 = "#181a1f";
|
|
344
346
|
export const cpdColorGray200 = "#1d1f24";
|
|
@@ -311,6 +311,8 @@ export const cpdIconFolder: string;
|
|
|
311
311
|
export const cpdIconSave: string;
|
|
312
312
|
export const cpdIconUnsave: string;
|
|
313
313
|
export const cpdIconSaveSolid: string;
|
|
314
|
+
export const cpdIconHourglassSolid: string;
|
|
315
|
+
export const cpdIconHourglass: string;
|
|
314
316
|
export const cpdColorThemeBg: string;
|
|
315
317
|
export const cpdColorGray100: string;
|
|
316
318
|
export const cpdColorGray200: string;
|
|
@@ -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 = "#fbfcfd";
|
|
344
346
|
export const cpdColorGray200 = "#f7f9fa";
|
|
@@ -311,6 +311,8 @@ export const cpdIconFolder: string;
|
|
|
311
311
|
export const cpdIconSave: string;
|
|
312
312
|
export const cpdIconUnsave: string;
|
|
313
313
|
export const cpdIconSaveSolid: string;
|
|
314
|
+
export const cpdIconHourglassSolid: string;
|
|
315
|
+
export const cpdIconHourglass: string;
|
|
314
316
|
export const cpdColorThemeBg: string;
|
|
315
317
|
export const cpdColorGray100: string;
|
|
316
318
|
export const cpdColorGray200: string;
|
|
@@ -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";
|
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,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vector-im/compound-design-tokens",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "11.0.0",
|
|
4
4
|
"description": "Compound design tokens",
|
|
5
|
-
"packageManager": "pnpm@11.
|
|
5
|
+
"packageManager": "pnpm@11.22.0+sha512.1ff870c4c6133dfd88fb2afc46dd13d47f09c9794b438c6fdb47ca98caf3bc16381ee0be93a091b8e3824cf01f889f46d7d9e20910fb0be1ab0fb5baa80dd621",
|
|
6
6
|
"sideEffects": false,
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "vite build && tsx ./build.ts",
|
|
@@ -22,7 +22,8 @@
|
|
|
22
22
|
],
|
|
23
23
|
"files": [
|
|
24
24
|
"./assets/web/**/*",
|
|
25
|
-
"./icons/**/*"
|
|
25
|
+
"./icons/**/*",
|
|
26
|
+
"./src/colors/**/*"
|
|
26
27
|
],
|
|
27
28
|
"main": "assets/web/js/index.js",
|
|
28
29
|
"type": "module",
|
|
@@ -82,16 +83,24 @@
|
|
|
82
83
|
"style-dictionary": "^5.0.0",
|
|
83
84
|
"svgo": "^4.0.0",
|
|
84
85
|
"tsx": "^4.15.6",
|
|
85
|
-
"typescript": "^
|
|
86
|
+
"typescript": "^7.0.0",
|
|
86
87
|
"undici": "^8.0.0",
|
|
87
88
|
"vite": "^8.0.0",
|
|
88
89
|
"zod": "^4.0.0"
|
|
89
90
|
},
|
|
90
91
|
"peerDependencies": {
|
|
92
|
+
"@adobe/leonardo-contrast-colors": "^1.0.0",
|
|
91
93
|
"@types/react": "*",
|
|
94
|
+
"chroma-js": "^3.0.0",
|
|
92
95
|
"react": "^17 || ^18 || ^19.0.0"
|
|
93
96
|
},
|
|
94
97
|
"peerDependenciesMeta": {
|
|
98
|
+
"@adobe/leonardo-contrast-colors": {
|
|
99
|
+
"optional": true
|
|
100
|
+
},
|
|
101
|
+
"chroma-js": {
|
|
102
|
+
"optional": true
|
|
103
|
+
},
|
|
95
104
|
"react": {
|
|
96
105
|
"optional": true
|
|
97
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>
|