@decoda-ui/tokens 0.1.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/colors.d.ts +93 -0
- package/dist/colors.js +91 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +4 -0
- package/dist/progress.d.ts +2 -0
- package/dist/progress.js +6 -0
- package/dist/scales.d.ts +41 -0
- package/dist/scales.js +37 -0
- package/dist/theme.d.ts +70 -0
- package/dist/theme.js +17 -0
- package/dist/theme.test.d.ts +1 -0
- package/dist/theme.test.js +21 -0
- package/package.json +23 -0
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/** Cifra theme values from Decoda UI Figma and cifra's source CSS. */
|
|
2
|
+
export declare const cifraLightColors: {
|
|
3
|
+
readonly background: "#f3f7fa";
|
|
4
|
+
readonly foreground: "#0a1820";
|
|
5
|
+
readonly card: "#ffffff";
|
|
6
|
+
readonly cardForeground: "#0a1820";
|
|
7
|
+
readonly popover: "#ffffff";
|
|
8
|
+
readonly popoverForeground: "#0a1820";
|
|
9
|
+
readonly primary: "#086f94";
|
|
10
|
+
readonly primaryForeground: "#ffffff";
|
|
11
|
+
readonly brandPrimary: "#086f94";
|
|
12
|
+
readonly brandGradientStart: "#55d8ee";
|
|
13
|
+
readonly brandGradientEnd: "#2794ff";
|
|
14
|
+
readonly brandGradientHoverStart: "#88e7f6";
|
|
15
|
+
readonly brandGradientHoverEnd: "#50aeff";
|
|
16
|
+
readonly brandGradientBorder: "#2f9fdc";
|
|
17
|
+
readonly brandForeground: "#061721";
|
|
18
|
+
readonly secondary: "#ffffff";
|
|
19
|
+
readonly secondaryForeground: "#0a1820";
|
|
20
|
+
readonly secondaryBorder: "#7a95a3";
|
|
21
|
+
readonly secondaryHover: "#e9f1f6";
|
|
22
|
+
readonly muted: "#e6eef3";
|
|
23
|
+
readonly mutedForeground: "#4f6a79";
|
|
24
|
+
readonly accent: "#e2edf3";
|
|
25
|
+
readonly accentForeground: "#0a1820";
|
|
26
|
+
readonly destructive: "#b91c1c";
|
|
27
|
+
readonly destructiveSurface: "#fbeeee";
|
|
28
|
+
readonly destructiveBorder: "#e9a7a7";
|
|
29
|
+
readonly success: "#15803d";
|
|
30
|
+
readonly warning: "#8a5a05";
|
|
31
|
+
readonly caution: "#b45309";
|
|
32
|
+
readonly cautionForeground: "#ffffff";
|
|
33
|
+
readonly border: "rgb(23 84 110 / 0.2)";
|
|
34
|
+
readonly input: "rgb(23 84 110 / 0.62)";
|
|
35
|
+
readonly ring: "#086f94";
|
|
36
|
+
readonly chart1: "#1f7fb8";
|
|
37
|
+
readonly chart2: "#e0602c";
|
|
38
|
+
readonly chart3: "#4a3aa7";
|
|
39
|
+
readonly chart4: "#138a60";
|
|
40
|
+
readonly chart5: "#a87400";
|
|
41
|
+
readonly chart6: "#c9457d";
|
|
42
|
+
readonly chart7: "#b463f6";
|
|
43
|
+
readonly chartOther: "#7d8f9b";
|
|
44
|
+
readonly lineSoft: "#d5e2ea";
|
|
45
|
+
readonly overlay: "rgb(10 24 32 / 0.4)";
|
|
46
|
+
};
|
|
47
|
+
export type ColorRole = keyof typeof cifraLightColors;
|
|
48
|
+
export type ColorRoles = Record<ColorRole, string>;
|
|
49
|
+
export declare const cifraDarkColors: {
|
|
50
|
+
background: string;
|
|
51
|
+
foreground: string;
|
|
52
|
+
card: string;
|
|
53
|
+
cardForeground: string;
|
|
54
|
+
popover: string;
|
|
55
|
+
popoverForeground: string;
|
|
56
|
+
primary: string;
|
|
57
|
+
primaryForeground: string;
|
|
58
|
+
brandPrimary: string;
|
|
59
|
+
brandGradientStart: string;
|
|
60
|
+
brandGradientEnd: string;
|
|
61
|
+
brandGradientHoverStart: string;
|
|
62
|
+
brandGradientHoverEnd: string;
|
|
63
|
+
brandGradientBorder: string;
|
|
64
|
+
brandForeground: string;
|
|
65
|
+
secondary: string;
|
|
66
|
+
secondaryForeground: string;
|
|
67
|
+
secondaryBorder: string;
|
|
68
|
+
secondaryHover: string;
|
|
69
|
+
muted: string;
|
|
70
|
+
mutedForeground: string;
|
|
71
|
+
accent: string;
|
|
72
|
+
accentForeground: string;
|
|
73
|
+
destructive: string;
|
|
74
|
+
destructiveSurface: string;
|
|
75
|
+
destructiveBorder: string;
|
|
76
|
+
success: string;
|
|
77
|
+
warning: string;
|
|
78
|
+
caution: string;
|
|
79
|
+
cautionForeground: string;
|
|
80
|
+
border: string;
|
|
81
|
+
input: string;
|
|
82
|
+
ring: string;
|
|
83
|
+
chart1: string;
|
|
84
|
+
chart2: string;
|
|
85
|
+
chart3: string;
|
|
86
|
+
chart4: string;
|
|
87
|
+
chart5: string;
|
|
88
|
+
chart6: string;
|
|
89
|
+
chart7: string;
|
|
90
|
+
chartOther: string;
|
|
91
|
+
lineSoft: string;
|
|
92
|
+
overlay: string;
|
|
93
|
+
};
|
package/dist/colors.js
ADDED
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
/** Cifra theme values from Decoda UI Figma and cifra's source CSS. */
|
|
2
|
+
export const cifraLightColors = {
|
|
3
|
+
background: '#f3f7fa',
|
|
4
|
+
foreground: '#0a1820',
|
|
5
|
+
card: '#ffffff',
|
|
6
|
+
cardForeground: '#0a1820',
|
|
7
|
+
popover: '#ffffff',
|
|
8
|
+
popoverForeground: '#0a1820',
|
|
9
|
+
primary: '#086f94',
|
|
10
|
+
primaryForeground: '#ffffff',
|
|
11
|
+
brandPrimary: '#086f94',
|
|
12
|
+
brandGradientStart: '#55d8ee',
|
|
13
|
+
brandGradientEnd: '#2794ff',
|
|
14
|
+
brandGradientHoverStart: '#88e7f6',
|
|
15
|
+
brandGradientHoverEnd: '#50aeff',
|
|
16
|
+
brandGradientBorder: '#2f9fdc',
|
|
17
|
+
brandForeground: '#061721',
|
|
18
|
+
secondary: '#ffffff',
|
|
19
|
+
secondaryForeground: '#0a1820',
|
|
20
|
+
secondaryBorder: '#7a95a3',
|
|
21
|
+
secondaryHover: '#e9f1f6',
|
|
22
|
+
muted: '#e6eef3',
|
|
23
|
+
mutedForeground: '#4f6a79',
|
|
24
|
+
accent: '#e2edf3',
|
|
25
|
+
accentForeground: '#0a1820',
|
|
26
|
+
destructive: '#b91c1c',
|
|
27
|
+
destructiveSurface: '#fbeeee',
|
|
28
|
+
destructiveBorder: '#e9a7a7',
|
|
29
|
+
success: '#15803d',
|
|
30
|
+
warning: '#8a5a05',
|
|
31
|
+
caution: '#b45309',
|
|
32
|
+
cautionForeground: '#ffffff',
|
|
33
|
+
border: 'rgb(23 84 110 / 0.2)',
|
|
34
|
+
input: 'rgb(23 84 110 / 0.62)',
|
|
35
|
+
ring: '#086f94',
|
|
36
|
+
chart1: '#1f7fb8',
|
|
37
|
+
chart2: '#e0602c',
|
|
38
|
+
chart3: '#4a3aa7',
|
|
39
|
+
chart4: '#138a60',
|
|
40
|
+
chart5: '#a87400',
|
|
41
|
+
chart6: '#c9457d',
|
|
42
|
+
chart7: '#b463f6',
|
|
43
|
+
chartOther: '#7d8f9b',
|
|
44
|
+
lineSoft: '#d5e2ea',
|
|
45
|
+
overlay: 'rgb(10 24 32 / 0.4)'
|
|
46
|
+
};
|
|
47
|
+
export const cifraDarkColors = {
|
|
48
|
+
background: '#060c10',
|
|
49
|
+
foreground: '#f1f7fc',
|
|
50
|
+
card: '#0b151c',
|
|
51
|
+
cardForeground: '#f1f7fc',
|
|
52
|
+
popover: '#0b151c',
|
|
53
|
+
popoverForeground: '#f1f7fc',
|
|
54
|
+
primary: '#60d9f5',
|
|
55
|
+
primaryForeground: '#061721',
|
|
56
|
+
brandPrimary: '#60d9f5',
|
|
57
|
+
brandGradientStart: '#55d8ee',
|
|
58
|
+
brandGradientEnd: '#2794ff',
|
|
59
|
+
brandGradientHoverStart: '#88e7f6',
|
|
60
|
+
brandGradientHoverEnd: '#50aeff',
|
|
61
|
+
brandGradientBorder: '#4dbdf9',
|
|
62
|
+
brandForeground: '#061721',
|
|
63
|
+
secondary: '#0b141a',
|
|
64
|
+
secondaryForeground: '#f1f7fc',
|
|
65
|
+
secondaryBorder: '#2b3a45',
|
|
66
|
+
secondaryHover: '#14232b',
|
|
67
|
+
muted: '#0f1b22',
|
|
68
|
+
mutedForeground: '#94aaba',
|
|
69
|
+
accent: '#14232b',
|
|
70
|
+
accentForeground: '#f1f7fc',
|
|
71
|
+
destructive: '#f87171',
|
|
72
|
+
destructiveSurface: '#2b171a',
|
|
73
|
+
destructiveBorder: '#88424a',
|
|
74
|
+
success: '#4ade80',
|
|
75
|
+
warning: '#f2b23a',
|
|
76
|
+
caution: '#fbbf24',
|
|
77
|
+
cautionForeground: '#1a1204',
|
|
78
|
+
border: 'rgb(113 186 214 / 0.18)',
|
|
79
|
+
input: 'rgb(113 186 214 / 0.55)',
|
|
80
|
+
ring: '#60d9f5',
|
|
81
|
+
chart1: '#2f9fd6',
|
|
82
|
+
chart2: '#d95926',
|
|
83
|
+
chart3: '#9085e9',
|
|
84
|
+
chart4: '#199e70',
|
|
85
|
+
chart5: '#c98500',
|
|
86
|
+
chart6: '#d55181',
|
|
87
|
+
chart7: '#993ccf',
|
|
88
|
+
chartOther: '#5f7684',
|
|
89
|
+
lineSoft: '#1c303b',
|
|
90
|
+
overlay: 'rgb(6 12 16 / 0.7)'
|
|
91
|
+
};
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { cifraLightColors, cifraDarkColors } from './colors.js';
|
|
2
|
+
export type { ColorRole, ColorRoles } from './colors.js';
|
|
3
|
+
export { space, radius, controlSize, fontFamily, duration } from './scales.js';
|
|
4
|
+
export { createTheme, cifraLight, cifraDark, foundations } from './theme.js';
|
|
5
|
+
export type { DecodaTheme, ThemeOverrides } from './theme.js';
|
|
6
|
+
export { sharePercent } from './progress.js';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export { cifraLightColors, cifraDarkColors } from './colors.js';
|
|
2
|
+
export { space, radius, controlSize, fontFamily, duration } from './scales.js';
|
|
3
|
+
export { createTheme, cifraLight, cifraDark, foundations } from './theme.js';
|
|
4
|
+
export { sharePercent } from './progress.js';
|
package/dist/progress.js
ADDED
package/dist/scales.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export declare const space: {
|
|
2
|
+
readonly none: 0;
|
|
3
|
+
readonly xxs: 2;
|
|
4
|
+
readonly xs: 4;
|
|
5
|
+
readonly sm: 8;
|
|
6
|
+
readonly md: 12;
|
|
7
|
+
readonly lg: 16;
|
|
8
|
+
readonly xl: 20;
|
|
9
|
+
readonly '2xl': 24;
|
|
10
|
+
readonly '3xl': 32;
|
|
11
|
+
readonly '4xl': 40;
|
|
12
|
+
readonly '5xl': 48;
|
|
13
|
+
readonly '6xl': 64;
|
|
14
|
+
};
|
|
15
|
+
export declare const radius: {
|
|
16
|
+
readonly none: 0;
|
|
17
|
+
readonly xs: 4;
|
|
18
|
+
readonly sm: 8;
|
|
19
|
+
readonly md: 9;
|
|
20
|
+
readonly lg: 12;
|
|
21
|
+
readonly xl: 14;
|
|
22
|
+
readonly '2xl': 20;
|
|
23
|
+
readonly pill: 999;
|
|
24
|
+
};
|
|
25
|
+
export declare const controlSize: {
|
|
26
|
+
readonly sm: 32;
|
|
27
|
+
readonly md: 40;
|
|
28
|
+
readonly touch: 44;
|
|
29
|
+
readonly lg: 50;
|
|
30
|
+
readonly xl: 56;
|
|
31
|
+
};
|
|
32
|
+
export declare const fontFamily: {
|
|
33
|
+
readonly body: "Manrope";
|
|
34
|
+
readonly mono: "IBM Plex Mono";
|
|
35
|
+
readonly display: "Biysk";
|
|
36
|
+
};
|
|
37
|
+
export declare const duration: {
|
|
38
|
+
readonly fast: 120;
|
|
39
|
+
readonly normal: 200;
|
|
40
|
+
readonly slow: 300;
|
|
41
|
+
};
|
package/dist/scales.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
export const space = {
|
|
2
|
+
none: 0,
|
|
3
|
+
xxs: 2,
|
|
4
|
+
xs: 4,
|
|
5
|
+
sm: 8,
|
|
6
|
+
md: 12,
|
|
7
|
+
lg: 16,
|
|
8
|
+
xl: 20,
|
|
9
|
+
'2xl': 24,
|
|
10
|
+
'3xl': 32,
|
|
11
|
+
'4xl': 40,
|
|
12
|
+
'5xl': 48,
|
|
13
|
+
'6xl': 64
|
|
14
|
+
};
|
|
15
|
+
export const radius = {
|
|
16
|
+
none: 0,
|
|
17
|
+
xs: 4,
|
|
18
|
+
sm: 8,
|
|
19
|
+
md: 9,
|
|
20
|
+
lg: 12,
|
|
21
|
+
xl: 14,
|
|
22
|
+
'2xl': 20,
|
|
23
|
+
pill: 999
|
|
24
|
+
};
|
|
25
|
+
export const controlSize = {
|
|
26
|
+
sm: 32,
|
|
27
|
+
md: 40,
|
|
28
|
+
touch: 44,
|
|
29
|
+
lg: 50,
|
|
30
|
+
xl: 56
|
|
31
|
+
};
|
|
32
|
+
export const fontFamily = {
|
|
33
|
+
body: 'Manrope',
|
|
34
|
+
mono: 'IBM Plex Mono',
|
|
35
|
+
display: 'Biysk'
|
|
36
|
+
};
|
|
37
|
+
export const duration = { fast: 120, normal: 200, slow: 300 };
|
package/dist/theme.d.ts
ADDED
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { type ColorRoles } from './colors.js';
|
|
2
|
+
import { controlSize, duration, fontFamily, radius, space } from './scales.js';
|
|
3
|
+
export interface DecodaTheme {
|
|
4
|
+
color: ColorRoles;
|
|
5
|
+
space: {
|
|
6
|
+
[K in keyof typeof space]: number;
|
|
7
|
+
};
|
|
8
|
+
radius: {
|
|
9
|
+
[K in keyof typeof radius]: number;
|
|
10
|
+
};
|
|
11
|
+
controlSize: {
|
|
12
|
+
[K in keyof typeof controlSize]: number;
|
|
13
|
+
};
|
|
14
|
+
fontFamily: {
|
|
15
|
+
[K in keyof typeof fontFamily]: string;
|
|
16
|
+
};
|
|
17
|
+
duration: {
|
|
18
|
+
[K in keyof typeof duration]: number;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
export type ThemeOverrides = {
|
|
22
|
+
[K in keyof DecodaTheme]?: Partial<DecodaTheme[K]>;
|
|
23
|
+
};
|
|
24
|
+
/** Shallow merge per token group keeps overrides explicit and tree-shakeable. */
|
|
25
|
+
export declare function createTheme(color: ColorRoles, overrides?: ThemeOverrides): DecodaTheme;
|
|
26
|
+
export declare const cifraLight: DecodaTheme;
|
|
27
|
+
export declare const cifraDark: DecodaTheme;
|
|
28
|
+
export declare const foundations: {
|
|
29
|
+
space: {
|
|
30
|
+
readonly none: 0;
|
|
31
|
+
readonly xxs: 2;
|
|
32
|
+
readonly xs: 4;
|
|
33
|
+
readonly sm: 8;
|
|
34
|
+
readonly md: 12;
|
|
35
|
+
readonly lg: 16;
|
|
36
|
+
readonly xl: 20;
|
|
37
|
+
readonly '2xl': 24;
|
|
38
|
+
readonly '3xl': 32;
|
|
39
|
+
readonly '4xl': 40;
|
|
40
|
+
readonly '5xl': 48;
|
|
41
|
+
readonly '6xl': 64;
|
|
42
|
+
};
|
|
43
|
+
radius: {
|
|
44
|
+
readonly none: 0;
|
|
45
|
+
readonly xs: 4;
|
|
46
|
+
readonly sm: 8;
|
|
47
|
+
readonly md: 9;
|
|
48
|
+
readonly lg: 12;
|
|
49
|
+
readonly xl: 14;
|
|
50
|
+
readonly '2xl': 20;
|
|
51
|
+
readonly pill: 999;
|
|
52
|
+
};
|
|
53
|
+
controlSize: {
|
|
54
|
+
readonly sm: 32;
|
|
55
|
+
readonly md: 40;
|
|
56
|
+
readonly touch: 44;
|
|
57
|
+
readonly lg: 50;
|
|
58
|
+
readonly xl: 56;
|
|
59
|
+
};
|
|
60
|
+
fontFamily: {
|
|
61
|
+
readonly body: "Manrope";
|
|
62
|
+
readonly mono: "IBM Plex Mono";
|
|
63
|
+
readonly display: "Biysk";
|
|
64
|
+
};
|
|
65
|
+
duration: {
|
|
66
|
+
readonly fast: 120;
|
|
67
|
+
readonly normal: 200;
|
|
68
|
+
readonly slow: 300;
|
|
69
|
+
};
|
|
70
|
+
};
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { cifraDarkColors, cifraLightColors } from './colors.js';
|
|
2
|
+
import { controlSize, duration, fontFamily, radius, space } from './scales.js';
|
|
3
|
+
const base = { space, radius, controlSize, fontFamily, duration };
|
|
4
|
+
/** Shallow merge per token group keeps overrides explicit and tree-shakeable. */
|
|
5
|
+
export function createTheme(color, overrides = {}) {
|
|
6
|
+
return {
|
|
7
|
+
color: { ...color, ...overrides.color },
|
|
8
|
+
space: { ...space, ...overrides.space },
|
|
9
|
+
radius: { ...radius, ...overrides.radius },
|
|
10
|
+
controlSize: { ...controlSize, ...overrides.controlSize },
|
|
11
|
+
fontFamily: { ...fontFamily, ...overrides.fontFamily },
|
|
12
|
+
duration: { ...duration, ...overrides.duration }
|
|
13
|
+
};
|
|
14
|
+
}
|
|
15
|
+
export const cifraLight = createTheme(cifraLightColors);
|
|
16
|
+
export const cifraDark = createTheme(cifraDarkColors);
|
|
17
|
+
export const foundations = base;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import assert from 'node:assert/strict';
|
|
2
|
+
import test from 'node:test';
|
|
3
|
+
import { cifraDark, cifraLight, createTheme } from './theme.js';
|
|
4
|
+
import { sharePercent } from './progress.js';
|
|
5
|
+
test('a custom theme does not mutate Cifra defaults', () => {
|
|
6
|
+
const custom = createTheme(cifraLight.color, {
|
|
7
|
+
color: { primary: '#123456' },
|
|
8
|
+
radius: { md: 16 }
|
|
9
|
+
});
|
|
10
|
+
assert.equal(custom.color.primary, '#123456');
|
|
11
|
+
assert.equal(custom.radius.md, 16);
|
|
12
|
+
assert.equal(cifraLight.color.primary, '#086f94');
|
|
13
|
+
assert.equal(cifraLight.radius.md, 9);
|
|
14
|
+
assert.equal(cifraDark.color.primary, '#60d9f5');
|
|
15
|
+
});
|
|
16
|
+
test('a visual share stays inside its track', () => {
|
|
17
|
+
assert.equal(sharePercent(-0.4), 0);
|
|
18
|
+
assert.equal(sharePercent(0.25), 25);
|
|
19
|
+
assert.equal(sharePercent(1.8), 100);
|
|
20
|
+
assert.equal(sharePercent(Number.NaN), 0);
|
|
21
|
+
});
|
package/package.json
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@decoda-ui/tokens",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"access": "public"
|
|
7
|
+
},
|
|
8
|
+
"sideEffects": false,
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js"
|
|
13
|
+
}
|
|
14
|
+
},
|
|
15
|
+
"files": [
|
|
16
|
+
"dist"
|
|
17
|
+
],
|
|
18
|
+
"scripts": {
|
|
19
|
+
"build": "tsc -p tsconfig.build.json",
|
|
20
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
21
|
+
"test": "pnpm build && node --test dist/theme.test.js"
|
|
22
|
+
}
|
|
23
|
+
}
|