@zendeskgarden/react-theming 9.12.6 → 9.14.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/dist/esm/index.js +1 -0
- package/dist/esm/utils/getColor.js +16 -7
- package/dist/esm/utils/getHueColor.js +24 -0
- package/dist/index.cjs.js +32 -7
- package/dist/typings/index.d.ts +2 -1
- package/dist/typings/types/index.d.ts +4 -0
- package/dist/typings/utils/getHueColor.d.ts +14 -0
- package/package.json +2 -2
package/dist/esm/index.js
CHANGED
|
@@ -16,6 +16,7 @@ export { getColor } from './utils/getColor.js';
|
|
|
16
16
|
export { getColorV8 } from './utils/getColorV8.js';
|
|
17
17
|
export { getFloatingPlacements } from './utils/getFloatingPlacements.js';
|
|
18
18
|
export { getFocusBoxShadow } from './utils/getFocusBoxShadow.js';
|
|
19
|
+
export { getHueColor } from './utils/getHueColor.js';
|
|
19
20
|
export { default as getLineHeight } from './utils/getLineHeight.js';
|
|
20
21
|
export { getMenuPosition } from './utils/getMenuPosition.js';
|
|
21
22
|
export { default as mediaQuery } from './utils/mediaQuery.js';
|
|
@@ -149,17 +149,26 @@ const toProperty = (object, path) => {
|
|
|
149
149
|
};
|
|
150
150
|
const fromRgba = value => {
|
|
151
151
|
let retVal;
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
const property = _rgba.groups.property;
|
|
156
|
-
const transparency = parseFloat(_rgba.groups.alpha);
|
|
152
|
+
try {
|
|
153
|
+
const [red, green, blue, transparency] = parseToRgba(value);
|
|
154
|
+
const property = toHex$1(`rgb(${red}, ${green}, ${blue})`);
|
|
157
155
|
retVal = {
|
|
158
156
|
property,
|
|
159
157
|
transparency
|
|
160
158
|
};
|
|
161
|
-
}
|
|
162
|
-
|
|
159
|
+
} catch {
|
|
160
|
+
const regex = /rgba\s*\(\s*(?<property>[#\w.]+)\s*,\s*(?<alpha>[\w.]+)\s*\)/gu;
|
|
161
|
+
const _rgba = regex.exec(value);
|
|
162
|
+
if (_rgba && _rgba.groups) {
|
|
163
|
+
const property = _rgba.groups.property;
|
|
164
|
+
const transparency = parseFloat(_rgba.groups.alpha);
|
|
165
|
+
retVal = {
|
|
166
|
+
property,
|
|
167
|
+
transparency
|
|
168
|
+
};
|
|
169
|
+
} else {
|
|
170
|
+
throw new Error(`Error: invalid \`rgba\` value "${value}"`);
|
|
171
|
+
}
|
|
163
172
|
}
|
|
164
173
|
return retVal;
|
|
165
174
|
};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { getColor } from './getColor.js';
|
|
8
|
+
|
|
9
|
+
const getHueColor = ({
|
|
10
|
+
theme,
|
|
11
|
+
value
|
|
12
|
+
}) => {
|
|
13
|
+
const pattern = /^[a-z]+\.[a-z]+$/giu;
|
|
14
|
+
const options = pattern.test(value) ? {
|
|
15
|
+
variable: value,
|
|
16
|
+
theme
|
|
17
|
+
} : {
|
|
18
|
+
hue: value,
|
|
19
|
+
theme
|
|
20
|
+
};
|
|
21
|
+
return getColor(options);
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export { getHueColor };
|
package/dist/index.cjs.js
CHANGED
|
@@ -769,17 +769,26 @@ const toProperty = (object, path) => {
|
|
|
769
769
|
};
|
|
770
770
|
const fromRgba = value => {
|
|
771
771
|
let retVal;
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
const property = _rgba.groups.property;
|
|
776
|
-
const transparency = parseFloat(_rgba.groups.alpha);
|
|
772
|
+
try {
|
|
773
|
+
const [red, green, blue, transparency] = color2k.parseToRgba(value);
|
|
774
|
+
const property = color2k.toHex(`rgb(${red}, ${green}, ${blue})`);
|
|
777
775
|
retVal = {
|
|
778
776
|
property,
|
|
779
777
|
transparency
|
|
780
778
|
};
|
|
781
|
-
}
|
|
782
|
-
|
|
779
|
+
} catch {
|
|
780
|
+
const regex = /rgba\s*\(\s*(?<property>[#\w.]+)\s*,\s*(?<alpha>[\w.]+)\s*\)/gu;
|
|
781
|
+
const _rgba = regex.exec(value);
|
|
782
|
+
if (_rgba && _rgba.groups) {
|
|
783
|
+
const property = _rgba.groups.property;
|
|
784
|
+
const transparency = parseFloat(_rgba.groups.alpha);
|
|
785
|
+
retVal = {
|
|
786
|
+
property,
|
|
787
|
+
transparency
|
|
788
|
+
};
|
|
789
|
+
} else {
|
|
790
|
+
throw new Error(`Error: invalid \`rgba\` value "${value}"`);
|
|
791
|
+
}
|
|
783
792
|
}
|
|
784
793
|
return retVal;
|
|
785
794
|
};
|
|
@@ -1280,6 +1289,21 @@ const getFocusBoxShadow = ({
|
|
|
1280
1289
|
return boxShadow ? `${retVal}, ${boxShadow}` : retVal;
|
|
1281
1290
|
};
|
|
1282
1291
|
|
|
1292
|
+
const getHueColor = ({
|
|
1293
|
+
theme,
|
|
1294
|
+
value
|
|
1295
|
+
}) => {
|
|
1296
|
+
const pattern = /^[a-z]+\.[a-z]+$/giu;
|
|
1297
|
+
const options = pattern.test(value) ? {
|
|
1298
|
+
variable: value,
|
|
1299
|
+
theme
|
|
1300
|
+
} : {
|
|
1301
|
+
hue: value,
|
|
1302
|
+
theme
|
|
1303
|
+
};
|
|
1304
|
+
return getColor(options);
|
|
1305
|
+
};
|
|
1306
|
+
|
|
1283
1307
|
function getLineHeight(height, fontSize) {
|
|
1284
1308
|
const [heightValue, heightUnit] = polished.getValueAndUnit(height.toString());
|
|
1285
1309
|
const [fontSizeValue, fontSizeUnit] = polished.getValueAndUnit(fontSize.toString());
|
|
@@ -1557,6 +1581,7 @@ exports.getColor = getColor;
|
|
|
1557
1581
|
exports.getColorV8 = getColorV8;
|
|
1558
1582
|
exports.getFloatingPlacements = getFloatingPlacements;
|
|
1559
1583
|
exports.getFocusBoxShadow = getFocusBoxShadow;
|
|
1584
|
+
exports.getHueColor = getHueColor;
|
|
1560
1585
|
exports.getLineHeight = getLineHeight;
|
|
1561
1586
|
exports.getMenuPosition = getMenuPosition;
|
|
1562
1587
|
exports.mediaQuery = mediaQuery;
|
package/dist/typings/index.d.ts
CHANGED
|
@@ -16,6 +16,7 @@ export { getColor } from './utils/getColor';
|
|
|
16
16
|
export { getColorV8 } from './utils/getColorV8';
|
|
17
17
|
export { getFloatingPlacements } from './utils/getFloatingPlacements';
|
|
18
18
|
export { getFocusBoxShadow } from './utils/getFocusBoxShadow';
|
|
19
|
+
export { getHueColor } from './utils/getHueColor';
|
|
19
20
|
export { default as getLineHeight } from './utils/getLineHeight';
|
|
20
21
|
export { getMenuPosition } from './utils/getMenuPosition';
|
|
21
22
|
export { default as mediaQuery } from './utils/mediaQuery';
|
|
@@ -27,4 +28,4 @@ export { useText } from './utils/useText';
|
|
|
27
28
|
export { default as menuStyles } from './utils/menuStyles';
|
|
28
29
|
export { focusStyles, SELECTOR_FOCUS_VISIBLE } from './utils/focusStyles';
|
|
29
30
|
export { StyledBaseIcon } from './utils/StyledBaseIcon';
|
|
30
|
-
export { ARROW_POSITION, MENU_POSITION, PLACEMENT, type IColorSchemeContext, type IColorSchemeProviderProps, type IGardenTheme, type IStyledBaseIconProps, type IThemeProviderProps, type ArrowPosition, type CheckeredBackgroundParameters, type ColorParameters, type ColorScheme, type FocusBoxShadowParameters, type FocusStylesParameters, type MenuPosition, type Placement } from './types';
|
|
31
|
+
export { ARROW_POSITION, MENU_POSITION, PLACEMENT, type IColorSchemeContext, type IColorSchemeProviderProps, type IGardenTheme, type IStyledBaseIconProps, type IThemeProviderProps, type ArrowPosition, type CheckeredBackgroundParameters, type ColorParameters, type ColorScheme, type FocusBoxShadowParameters, type FocusStylesParameters, type HueColorParameters, type MenuPosition, type Placement } from './types';
|
|
@@ -54,6 +54,10 @@ export type FocusBoxShadowParameters = {
|
|
|
54
54
|
theme: IGardenTheme;
|
|
55
55
|
};
|
|
56
56
|
export type Hue = Record<number | string, string> | string;
|
|
57
|
+
export type HueColorParameters = {
|
|
58
|
+
theme: IGardenTheme;
|
|
59
|
+
value: string;
|
|
60
|
+
};
|
|
57
61
|
export interface IGardenTheme {
|
|
58
62
|
rtl: boolean;
|
|
59
63
|
document?: any;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright Zendesk, Inc.
|
|
3
|
+
*
|
|
4
|
+
* Use of this source code is governed under the Apache License, Version 2.0
|
|
5
|
+
* found at http://www.apache.org/licenses/LICENSE-2.0.
|
|
6
|
+
*/
|
|
7
|
+
import { HueColorParameters } from '../types';
|
|
8
|
+
/**
|
|
9
|
+
* Get a hue color from the theme
|
|
10
|
+
*
|
|
11
|
+
* @param {Object} options.theme Provides values used to resolve the desired color
|
|
12
|
+
* @param {string} options.value A color variable key (i.e. 'foreground.subtle'), key hue value (i.e. 'primaryHue'), or valid CSS color
|
|
13
|
+
*/
|
|
14
|
+
export declare const getHueColor: ({ theme, value }: HueColorParameters) => string;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zendeskgarden/react-theming",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.14.0",
|
|
4
4
|
"description": "Theming utilities and components within the Garden Design System",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Zendesk Garden <garden@zendesk.com>",
|
|
@@ -47,5 +47,5 @@
|
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
49
|
"zendeskgarden:src": "src/index.ts",
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "75fd88fc9ea5e6dd48a188d6a15c93a98356b0b7"
|
|
51
51
|
}
|