@descope/web-components-ui 1.0.94 → 1.0.95
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/cjs/index.cjs.js +22 -1
- package/dist/cjs/index.cjs.js.map +1 -1
- package/dist/index.esm.js +22 -1
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/helpers/index.js +11 -1
- package/src/helpers/themeHelpers/index.js +13 -2
package/package.json
CHANGED
package/src/helpers/index.js
CHANGED
@@ -13,4 +13,14 @@ export const compose = (...fns) =>
|
|
13
13
|
|
14
14
|
export const upperFirst = (str) => str.charAt(0).toUpperCase() + str.slice(1)
|
15
15
|
|
16
|
-
export const isFunction = (maybeFunc) => typeof maybeFunc === 'function'
|
16
|
+
export const isFunction = (maybeFunc) => typeof maybeFunc === 'function';
|
17
|
+
|
18
|
+
export const isUrl = (maybeUrl) => {
|
19
|
+
try {
|
20
|
+
new URL(maybeUrl)
|
21
|
+
|
22
|
+
return true;
|
23
|
+
} catch (e) {
|
24
|
+
return false;
|
25
|
+
}
|
26
|
+
}
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import merge from 'lodash.merge';
|
2
2
|
import set from 'lodash.set';
|
3
3
|
import { BASE_THEME_SECTION, DESCOPE_PREFIX, PORTAL_THEME_PREFIX } from '../../constants';
|
4
|
-
import { kebabCase } from '..';
|
4
|
+
import { isUrl, kebabCase } from '..';
|
5
5
|
import { getComponentName, getCssVarName } from '../componentHelpers';
|
6
6
|
|
7
7
|
const getVarName = (path) => getCssVarName(DESCOPE_PREFIX, ...path);
|
@@ -19,9 +19,20 @@ const transformTheme = (theme, path, getTransformation) => {
|
|
19
19
|
const stringifyArray = (strArr) =>
|
20
20
|
strArr.map((str) => (str.includes(' ') ? `"${str}"` : str)).join(', ');
|
21
21
|
|
22
|
+
const getCssVarValue = (val) => {
|
23
|
+
switch (true) {
|
24
|
+
case Array.isArray(val):
|
25
|
+
return stringifyArray(val)
|
26
|
+
case isUrl(val):
|
27
|
+
return `url(${val})`
|
28
|
+
default:
|
29
|
+
return val
|
30
|
+
}
|
31
|
+
}
|
32
|
+
|
22
33
|
export const themeToCSSVarsObj = (theme) =>
|
23
34
|
transformTheme(theme, [], (path, val) => ({
|
24
|
-
[getVarName(path)]:
|
35
|
+
[getVarName(path)]: getCssVarValue(val)
|
25
36
|
}));
|
26
37
|
|
27
38
|
export const getThemeRefs = (theme, prefix) =>
|