@ismail-elkorchi/ui-tokens 0.1.0 → 0.1.1
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/README.md +113 -10
- package/dist/base.css +986 -0
- package/dist/index.css +1646 -1
- package/dist/index.d.ts +7 -0
- package/dist/index.js +38 -0
- package/dist/themes/uik-dark.css +657 -0
- package/dist/themes/uik-density-comfortable.css +26 -0
- package/dist/themes/uik-density-compact.css +26 -0
- package/dist/themes/uik-light.css +420 -0
- package/dist/themes/uik-theme-base.css +414 -0
- package/dist/tokens.resolved.dark.comfortable.json +2355 -0
- package/dist/tokens.resolved.dark.compact.json +2377 -0
- package/dist/tokens.resolved.light.comfortable.json +2355 -0
- package/dist/tokens.resolved.light.compact.json +2377 -0
- package/dist/uik-tailwind.compat.css +638 -0
- package/dist/uik-tailwind.strict.css +659 -0
- package/package.json +44 -9
- package/dist/theme.css +0 -45
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export const THEME_ATTRIBUTE: 'data-uik-theme';
|
|
2
|
+
export const DENSITY_ATTRIBUTE: 'data-uik-density';
|
|
3
|
+
export type ThemeName = 'light' | 'dark' | (string & {});
|
|
4
|
+
export type DensityName = 'comfortable' | 'compact' | (string & {});
|
|
5
|
+
export function setTheme(element: Element | null | undefined, theme?: ThemeName | null): void;
|
|
6
|
+
export function setDensity(element: Element | null | undefined, density?: DensityName | null): void;
|
|
7
|
+
export function getCssVarName(token: string): string;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
const THEME_ATTRIBUTE = 'data-uik-theme';
|
|
2
|
+
const DENSITY_ATTRIBUTE = 'data-uik-density';
|
|
3
|
+
|
|
4
|
+
function setTheme(element, theme) {
|
|
5
|
+
if (!element || typeof element.setAttribute !== 'function') return;
|
|
6
|
+
if (theme == null || theme === '') {
|
|
7
|
+
if (typeof element.removeAttribute === 'function') {
|
|
8
|
+
element.removeAttribute(THEME_ATTRIBUTE);
|
|
9
|
+
}
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
element.setAttribute(THEME_ATTRIBUTE, String(theme));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function setDensity(element, density) {
|
|
16
|
+
if (!element || typeof element.setAttribute !== 'function') return;
|
|
17
|
+
if (density == null || density === '') {
|
|
18
|
+
if (typeof element.removeAttribute === 'function') {
|
|
19
|
+
element.removeAttribute(DENSITY_ATTRIBUTE);
|
|
20
|
+
}
|
|
21
|
+
return;
|
|
22
|
+
}
|
|
23
|
+
element.setAttribute(DENSITY_ATTRIBUTE, String(density));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
function toKebab(segment) {
|
|
27
|
+
return segment
|
|
28
|
+
.replace(/([a-z0-9])([A-Z])/g, '$1-$2')
|
|
29
|
+
.replace(/_/g, '-')
|
|
30
|
+
.toLowerCase();
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
function getCssVarName(token) {
|
|
34
|
+
const key = typeof token === 'string' ? token : String(token);
|
|
35
|
+
return `--uik-${key.split('.').map(toKebab).join('-')}`;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export { THEME_ATTRIBUTE, DENSITY_ATTRIBUTE, setTheme, setDensity, getCssVarName };
|