@trackunit/ui-design-tokens 1.0.1 → 1.0.3
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/index.cjs.js +6 -7
- package/index.esm.js +6 -7
- package/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -103,16 +103,15 @@ function rgbToHex(r, g, b) {
|
|
|
103
103
|
* @returns {string} HEX color
|
|
104
104
|
*/
|
|
105
105
|
const getHEX = (variable) => {
|
|
106
|
-
var _a, _b, _c, _d, _e;
|
|
107
106
|
const regex = /rgb\(var\((.*?)\) \/ var\(--tw-bg-opacity\)\)/g;
|
|
108
107
|
const root = document.documentElement;
|
|
109
108
|
const match = regex.exec(variable);
|
|
110
|
-
const colorValue = getComputedStyle(root).getPropertyValue(
|
|
109
|
+
const colorValue = getComputedStyle(root).getPropertyValue(match?.[1]?.trim() ?? variable);
|
|
111
110
|
const RGB = colorValue
|
|
112
111
|
.trim()
|
|
113
112
|
.split(" ")
|
|
114
113
|
.map(channel => Number(channel));
|
|
115
|
-
return rgbToHex(
|
|
114
|
+
return rgbToHex(RGB[0] ?? NaN, RGB[1] ?? NaN, RGB[2] ?? NaN);
|
|
116
115
|
};
|
|
117
116
|
|
|
118
117
|
/**
|
|
@@ -594,13 +593,13 @@ Returns the color value in CSS or HEX format for a given theme color and variant
|
|
|
594
593
|
@returns {string} - Returns a string containing the color value in CSS or HEX format for the provided arguments.
|
|
595
594
|
*/
|
|
596
595
|
function color(ColorKey, arg2, arg3) {
|
|
597
|
-
var _a, _b;
|
|
598
596
|
const colorName = themeColors[ColorKey].name;
|
|
599
597
|
const colorVariants = themeColors[ColorKey].variants;
|
|
600
598
|
// defaultVariant or 600 or the "middel" value available.
|
|
601
|
-
const defaultVariant =
|
|
602
|
-
|
|
603
|
-
|
|
599
|
+
const defaultVariant = themeColors[ColorKey].defaultVariant ??
|
|
600
|
+
// @ts-ignore - suppressImplicitAnyIndexErrors
|
|
601
|
+
(colorVariants[600] && 600) ??
|
|
602
|
+
Object.keys(colorVariants)[Math.floor(Object.keys(colorVariants).length / 2)];
|
|
604
603
|
let variant = defaultVariant;
|
|
605
604
|
let output = "CSS";
|
|
606
605
|
if (isOutputOption(arg2)) {
|
package/index.esm.js
CHANGED
|
@@ -101,16 +101,15 @@ function rgbToHex(r, g, b) {
|
|
|
101
101
|
* @returns {string} HEX color
|
|
102
102
|
*/
|
|
103
103
|
const getHEX = (variable) => {
|
|
104
|
-
var _a, _b, _c, _d, _e;
|
|
105
104
|
const regex = /rgb\(var\((.*?)\) \/ var\(--tw-bg-opacity\)\)/g;
|
|
106
105
|
const root = document.documentElement;
|
|
107
106
|
const match = regex.exec(variable);
|
|
108
|
-
const colorValue = getComputedStyle(root).getPropertyValue(
|
|
107
|
+
const colorValue = getComputedStyle(root).getPropertyValue(match?.[1]?.trim() ?? variable);
|
|
109
108
|
const RGB = colorValue
|
|
110
109
|
.trim()
|
|
111
110
|
.split(" ")
|
|
112
111
|
.map(channel => Number(channel));
|
|
113
|
-
return rgbToHex(
|
|
112
|
+
return rgbToHex(RGB[0] ?? NaN, RGB[1] ?? NaN, RGB[2] ?? NaN);
|
|
114
113
|
};
|
|
115
114
|
|
|
116
115
|
/**
|
|
@@ -592,13 +591,13 @@ Returns the color value in CSS or HEX format for a given theme color and variant
|
|
|
592
591
|
@returns {string} - Returns a string containing the color value in CSS or HEX format for the provided arguments.
|
|
593
592
|
*/
|
|
594
593
|
function color(ColorKey, arg2, arg3) {
|
|
595
|
-
var _a, _b;
|
|
596
594
|
const colorName = themeColors[ColorKey].name;
|
|
597
595
|
const colorVariants = themeColors[ColorKey].variants;
|
|
598
596
|
// defaultVariant or 600 or the "middel" value available.
|
|
599
|
-
const defaultVariant =
|
|
600
|
-
|
|
601
|
-
|
|
597
|
+
const defaultVariant = themeColors[ColorKey].defaultVariant ??
|
|
598
|
+
// @ts-ignore - suppressImplicitAnyIndexErrors
|
|
599
|
+
(colorVariants[600] && 600) ??
|
|
600
|
+
Object.keys(colorVariants)[Math.floor(Object.keys(colorVariants).length / 2)];
|
|
602
601
|
let variant = defaultVariant;
|
|
603
602
|
let output = "CSS";
|
|
604
603
|
if (isOutputOption(arg2)) {
|