@particle-network/ui-react 0.5.1-beta.3 → 0.5.1-beta.5
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/components/ProgressWrapper/index.d.ts +2 -2
- package/dist/components/UXChip/chip.extend.d.ts +2 -1
- package/dist/components/UXChip/index.d.ts +1 -1
- package/dist/components/UXColorPicker/color-picker.js +13 -7
- package/dist/components/UXColorPicker/types.d.ts +11 -0
- package/dist/components/UXThemeSwitch/constants.d.ts +9 -0
- package/dist/components/UXThemeSwitch/constants.js +3 -0
- package/dist/components/UXThemeSwitch/custom-theme-config.d.ts +2 -0
- package/dist/components/UXThemeSwitch/custom-theme-config.js +169 -0
- package/dist/components/UXThemeSwitch/theme-item.js +93 -14
- package/dist/components/UXThemeSwitch/theme-switch.js +24 -3
- package/dist/components/UXThemeSwitch/use-theme-color.d.ts +1 -22
- package/dist/components/UXThemeSwitch/use-theme-color.js +1 -9
- package/dist/components/UXThemeSwitch/use-theme-store.d.ts +5 -0
- package/dist/components/UXThemeSwitch/use-theme-store.js +9 -4
- package/dist/components/UXThemeSwitch/use-theme.d.ts +2 -0
- package/dist/components/UXThemeSwitch/use-theme.js +10 -53
- package/dist/components/UXThemeSwitch/utils.d.ts +28 -0
- package/dist/components/UXThemeSwitch/utils.js +202 -0
- package/dist/components/typography/Text.type.d.ts +2 -2
- package/dist/components/typography/Text.type.js +0 -1
- package/dist/heroui/constants.d.ts +18 -0
- package/dist/heroui/constants.js +98 -0
- package/dist/heroui/types.d.ts +91 -0
- package/dist/heroui/types.js +0 -0
- package/dist/heroui/utils/colors.d.ts +34 -0
- package/dist/heroui/utils/colors.js +121 -0
- package/dist/heroui/utils/object.d.ts +1 -0
- package/dist/heroui/utils/object.js +17 -0
- package/dist/hooks/useI18n.d.ts +129 -25
- package/dist/hooks/useI18n.js +80 -2
- package/dist/hooks/useLang.d.ts +5 -1
- package/dist/hooks/useLang.js +13 -1
- package/package.json +5 -3
- package/tailwind-preset.js +22 -148
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { CustomTheme, UXDarkTheme } from "@particle-network/ui-shared";
|
|
2
2
|
import { create } from "zustand";
|
|
3
3
|
import { createJSONStorage, persist } from "zustand/middleware";
|
|
4
4
|
const useThemeStore = create()(persist((set)=>({
|
|
5
|
-
theme:
|
|
5
|
+
theme: UXDarkTheme,
|
|
6
|
+
customTheme: CustomTheme,
|
|
6
7
|
fontUrl: '',
|
|
7
8
|
fontName: '',
|
|
8
9
|
fontLoadStatus: 'idle',
|
|
9
10
|
setTheme: (theme)=>set({
|
|
10
11
|
theme
|
|
11
12
|
}),
|
|
13
|
+
setCustomTheme: (customTheme)=>set({
|
|
14
|
+
customTheme
|
|
15
|
+
}),
|
|
12
16
|
setFontUrl: (fontUrl)=>set({
|
|
13
17
|
fontUrl
|
|
14
18
|
}),
|
|
@@ -19,11 +23,12 @@ const useThemeStore = create()(persist((set)=>({
|
|
|
19
23
|
fontName
|
|
20
24
|
})
|
|
21
25
|
}), {
|
|
22
|
-
name: 'ux-
|
|
23
|
-
version:
|
|
26
|
+
name: 'ux-preference-theme',
|
|
27
|
+
version: 0,
|
|
24
28
|
storage: createJSONStorage(()=>'undefined' != typeof window ? window.localStorage : {}),
|
|
25
29
|
partialize: (state)=>({
|
|
26
30
|
theme: state.theme,
|
|
31
|
+
customTheme: state.customTheme,
|
|
27
32
|
fontName: state.fontName,
|
|
28
33
|
fontUrl: state.fontUrl
|
|
29
34
|
})
|
|
@@ -4,7 +4,9 @@ import { type ThemeItemType } from '@particle-network/ui-shared';
|
|
|
4
4
|
*/
|
|
5
5
|
export declare const useTheme: () => {
|
|
6
6
|
theme: ThemeItemType;
|
|
7
|
+
customTheme: ThemeItemType;
|
|
7
8
|
setTheme: (theme: ThemeItemType) => void;
|
|
9
|
+
setCustomTheme: (customTheme: ThemeItemType) => void;
|
|
8
10
|
fontUrl: string;
|
|
9
11
|
setFontUrl: (link: string) => void;
|
|
10
12
|
clearFontUrl: () => void;
|
|
@@ -1,65 +1,15 @@
|
|
|
1
1
|
import { useEffect } from "react";
|
|
2
|
-
import { themeKeys } from "@particle-network/ui-shared";
|
|
3
2
|
import { useDebounceFn } from "ahooks";
|
|
4
3
|
import { useThemeStore } from "./use-theme-store.js";
|
|
5
|
-
|
|
6
|
-
const PRELOAD_FONTS_URL = 'https://fonts.googleapis.com/css2?family=Geist:wght@100..900&family=IBM+Plex+Sans:ital,wght@0,100..700;1,100..700&display=swap';
|
|
7
|
-
const preloadFonts = ()=>{
|
|
8
|
-
if ('undefined' == typeof window) return;
|
|
9
|
-
const existingLink = document.getElementById('ux-preload-fonts-link');
|
|
10
|
-
if (existingLink) return;
|
|
11
|
-
const linkElement = document.createElement('link');
|
|
12
|
-
linkElement.id = 'ux-preload-fonts-link';
|
|
13
|
-
linkElement.rel = 'stylesheet';
|
|
14
|
-
linkElement.href = PRELOAD_FONTS_URL;
|
|
15
|
-
document.head.appendChild(linkElement);
|
|
16
|
-
};
|
|
17
|
-
const applyTheme = (theme)=>{
|
|
18
|
-
if ('undefined' == typeof window) return;
|
|
19
|
-
const root = document.documentElement;
|
|
20
|
-
const isClassListCorrect = root.classList.contains(theme.id);
|
|
21
|
-
const isDataThemeCorrect = root.getAttribute('data-theme') === theme.colorScheme;
|
|
22
|
-
const isDataPrefersColorCorrect = root.getAttribute('data-prefers-color') === theme.colorScheme;
|
|
23
|
-
if (isClassListCorrect && isDataThemeCorrect && isDataPrefersColorCorrect) return;
|
|
24
|
-
if (!isDataThemeCorrect) root.setAttribute('data-theme', theme.colorScheme);
|
|
25
|
-
if (!isDataPrefersColorCorrect) root.setAttribute('data-prefers-color', theme.colorScheme);
|
|
26
|
-
root.classList.remove('dark');
|
|
27
|
-
root.classList.remove('light');
|
|
28
|
-
if (!isClassListCorrect) {
|
|
29
|
-
themeKeys.forEach((key)=>{
|
|
30
|
-
root.classList.remove(key);
|
|
31
|
-
});
|
|
32
|
-
root.classList.add(theme.id);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
const extractFontFamilyFromLink = (link)=>{
|
|
36
|
-
if (!link) return null;
|
|
37
|
-
try {
|
|
38
|
-
const url = new URL(link);
|
|
39
|
-
const familyParam = url.searchParams.get('family');
|
|
40
|
-
if (!familyParam) return null;
|
|
41
|
-
const firstFamily = familyParam.split('&family=')[0].split(':')[0].replace(/\+/g, ' ');
|
|
42
|
-
return firstFamily;
|
|
43
|
-
} catch {
|
|
44
|
-
return null;
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
const applyFont = (fontName)=>{
|
|
48
|
-
if ('undefined' == typeof window) return;
|
|
49
|
-
if (fontName) {
|
|
50
|
-
document.documentElement.style.setProperty('--ux-font-family', `"${fontName}", ${DEFAULT_FONT_FAMILY}`);
|
|
51
|
-
document.body.style.fontFamily = `"${fontName}", ${DEFAULT_FONT_FAMILY}`;
|
|
52
|
-
} else {
|
|
53
|
-
document.documentElement.style.setProperty('--ux-font-family', DEFAULT_FONT_FAMILY);
|
|
54
|
-
document.body.style.fontFamily = DEFAULT_FONT_FAMILY;
|
|
55
|
-
}
|
|
56
|
-
};
|
|
4
|
+
import { applyFont, applyTheme, extractFontFamilyFromLink, preloadFonts } from "./utils.js";
|
|
57
5
|
const useTheme = ()=>{
|
|
58
6
|
const theme = useThemeStore((state)=>state.theme);
|
|
7
|
+
const customTheme = useThemeStore((state)=>state.customTheme);
|
|
59
8
|
const fontUrl = useThemeStore((state)=>state.fontUrl);
|
|
60
9
|
const fontName = useThemeStore((state)=>state.fontName);
|
|
61
10
|
const fontLoadStatus = useThemeStore((state)=>state.fontLoadStatus);
|
|
62
11
|
const storeSetTheme = useThemeStore((state)=>state.setTheme);
|
|
12
|
+
const storeSetCustomTheme = useThemeStore((state)=>state.setCustomTheme);
|
|
63
13
|
const storeSetFontUrl = useThemeStore((state)=>state.setFontUrl);
|
|
64
14
|
const storeSetFontLoadStatus = useThemeStore((state)=>state.setFontLoadStatus);
|
|
65
15
|
const storeSetFontName = useThemeStore((state)=>state.setFontName);
|
|
@@ -97,6 +47,11 @@ const useTheme = ()=>{
|
|
|
97
47
|
applyTheme(theme);
|
|
98
48
|
debouncedApplyFont(fontUrl, theme.fontName);
|
|
99
49
|
}, []);
|
|
50
|
+
useEffect(()=>{
|
|
51
|
+
applyTheme(theme);
|
|
52
|
+
}, [
|
|
53
|
+
theme
|
|
54
|
+
]);
|
|
100
55
|
const setTheme = (theme)=>{
|
|
101
56
|
storeSetTheme(theme);
|
|
102
57
|
applyTheme(theme);
|
|
@@ -114,7 +69,9 @@ const useTheme = ()=>{
|
|
|
114
69
|
};
|
|
115
70
|
return {
|
|
116
71
|
theme,
|
|
72
|
+
customTheme,
|
|
117
73
|
setTheme,
|
|
74
|
+
setCustomTheme: storeSetCustomTheme,
|
|
118
75
|
fontUrl,
|
|
119
76
|
setFontUrl,
|
|
120
77
|
clearFontUrl,
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { type ThemeItemType } from '@particle-network/ui-shared';
|
|
2
|
+
/**
|
|
3
|
+
* 初始化并预加载字体 CSS(仅执行一次)
|
|
4
|
+
*/
|
|
5
|
+
export declare const preloadFonts: () => void;
|
|
6
|
+
export declare const setCSSProperty: (property: string, value: string) => void;
|
|
7
|
+
/**
|
|
8
|
+
* 应用自定义主题的颜色到 CSS 变量
|
|
9
|
+
*/
|
|
10
|
+
export declare const applyCustomThemeColors: (theme: ThemeItemType) => void;
|
|
11
|
+
/**
|
|
12
|
+
* 清除自定义主题的 CSS 变量(切换到其他主题时)
|
|
13
|
+
*/
|
|
14
|
+
export declare const clearCustomThemeColors: () => void;
|
|
15
|
+
/**
|
|
16
|
+
* 应用主题到文档根元素
|
|
17
|
+
*/
|
|
18
|
+
export declare const applyTheme: (theme: ThemeItemType) => void;
|
|
19
|
+
/**
|
|
20
|
+
* 从 Google Fonts 链接中提取字体名称
|
|
21
|
+
* 例如: https://fonts.googleapis.com/css2?family=Roboto:wght@400;700&display=swap
|
|
22
|
+
* 提取: Roboto
|
|
23
|
+
*/
|
|
24
|
+
export declare const extractFontFamilyFromLink: (link: string) => string | null;
|
|
25
|
+
/**
|
|
26
|
+
* 应用字体到 DOM
|
|
27
|
+
*/
|
|
28
|
+
export declare const applyFont: (fontName: string | undefined) => void;
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
import { hexColorToHSLValue, themeKeys } from "@particle-network/ui-shared";
|
|
2
|
+
import { readableColor } from "color2k";
|
|
3
|
+
import { generateThemeColor } from "../../heroui/utils/colors.js";
|
|
4
|
+
import { DEFAULT_FONT_FAMILY, PRELOAD_FONTS_URL } from "./constants.js";
|
|
5
|
+
const getCSSProperties = (theme)=>{
|
|
6
|
+
const { colorVariables } = theme;
|
|
7
|
+
return {
|
|
8
|
+
foreground: [
|
|
9
|
+
[
|
|
10
|
+
'--heroui-foreground',
|
|
11
|
+
colorVariables.foreground
|
|
12
|
+
]
|
|
13
|
+
],
|
|
14
|
+
secondary: [
|
|
15
|
+
...generateThemeColor(colorVariables.secondary, 'secondary', theme.colorScheme).cssVariables,
|
|
16
|
+
[
|
|
17
|
+
'--heroui-foreground-300',
|
|
18
|
+
colorVariables.secondary
|
|
19
|
+
]
|
|
20
|
+
],
|
|
21
|
+
tertiary: [
|
|
22
|
+
[
|
|
23
|
+
'--heroui-tertiary',
|
|
24
|
+
colorVariables.tertiary
|
|
25
|
+
],
|
|
26
|
+
[
|
|
27
|
+
'--heroui-foreground-100',
|
|
28
|
+
colorVariables.tertiary
|
|
29
|
+
],
|
|
30
|
+
[
|
|
31
|
+
'--heroui-tertiary-foreground',
|
|
32
|
+
readableColor(colorVariables.tertiary)
|
|
33
|
+
]
|
|
34
|
+
],
|
|
35
|
+
primary: generateThemeColor(colorVariables.primary, 'primary', theme.colorScheme).cssVariables,
|
|
36
|
+
success: generateThemeColor(colorVariables.success, 'success', theme.colorScheme).cssVariables,
|
|
37
|
+
danger: generateThemeColor(colorVariables.danger, 'danger', theme.colorScheme).cssVariables,
|
|
38
|
+
alert: [
|
|
39
|
+
[
|
|
40
|
+
'--heroui-alert',
|
|
41
|
+
colorVariables.alert
|
|
42
|
+
],
|
|
43
|
+
[
|
|
44
|
+
'--heroui-alert-foreground',
|
|
45
|
+
readableColor(colorVariables.alert)
|
|
46
|
+
]
|
|
47
|
+
],
|
|
48
|
+
warning: generateThemeColor(colorVariables.warning, 'warning', theme.colorScheme).cssVariables,
|
|
49
|
+
'bg-default': [
|
|
50
|
+
[
|
|
51
|
+
'--heroui-background',
|
|
52
|
+
colorVariables['bg-default']
|
|
53
|
+
],
|
|
54
|
+
[
|
|
55
|
+
'--heroui-background-500',
|
|
56
|
+
colorVariables['bg-default']
|
|
57
|
+
]
|
|
58
|
+
],
|
|
59
|
+
'bg-200': [
|
|
60
|
+
[
|
|
61
|
+
'--heroui-background-200',
|
|
62
|
+
colorVariables['bg-200']
|
|
63
|
+
]
|
|
64
|
+
],
|
|
65
|
+
'bg-300': [
|
|
66
|
+
[
|
|
67
|
+
'--heroui-background-300',
|
|
68
|
+
colorVariables['bg-300']
|
|
69
|
+
]
|
|
70
|
+
],
|
|
71
|
+
'bg-400': [
|
|
72
|
+
[
|
|
73
|
+
'--heroui-background-400',
|
|
74
|
+
colorVariables['bg-400']
|
|
75
|
+
]
|
|
76
|
+
],
|
|
77
|
+
overlay: [
|
|
78
|
+
[
|
|
79
|
+
'--heroui-overlay',
|
|
80
|
+
colorVariables.overlay
|
|
81
|
+
],
|
|
82
|
+
[
|
|
83
|
+
'--heroui-content1',
|
|
84
|
+
colorVariables.overlay
|
|
85
|
+
],
|
|
86
|
+
[
|
|
87
|
+
'--heroui-overlay-foreground',
|
|
88
|
+
readableColor(colorVariables.overlay)
|
|
89
|
+
],
|
|
90
|
+
[
|
|
91
|
+
'--heroui-content1-foreground',
|
|
92
|
+
readableColor(colorVariables.overlay)
|
|
93
|
+
]
|
|
94
|
+
],
|
|
95
|
+
divider: [
|
|
96
|
+
[
|
|
97
|
+
'--heroui-divider',
|
|
98
|
+
colorVariables.divider
|
|
99
|
+
],
|
|
100
|
+
[
|
|
101
|
+
'--heroui-divider-foreground',
|
|
102
|
+
readableColor(colorVariables.divider)
|
|
103
|
+
]
|
|
104
|
+
],
|
|
105
|
+
bullish: [
|
|
106
|
+
[
|
|
107
|
+
'--heroui-bullish',
|
|
108
|
+
colorVariables.bullish
|
|
109
|
+
],
|
|
110
|
+
[
|
|
111
|
+
'--heroui-bullish-foreground',
|
|
112
|
+
readableColor(colorVariables.bullish)
|
|
113
|
+
]
|
|
114
|
+
],
|
|
115
|
+
bearish: [
|
|
116
|
+
[
|
|
117
|
+
'--heroui-bearish',
|
|
118
|
+
colorVariables.bearish
|
|
119
|
+
],
|
|
120
|
+
[
|
|
121
|
+
'--heroui-bearish-foreground',
|
|
122
|
+
readableColor(colorVariables.bearish)
|
|
123
|
+
]
|
|
124
|
+
]
|
|
125
|
+
};
|
|
126
|
+
};
|
|
127
|
+
const preloadFonts = ()=>{
|
|
128
|
+
if ('undefined' == typeof window) return;
|
|
129
|
+
const existingLink = document.getElementById('ux-preload-fonts-link');
|
|
130
|
+
if (existingLink) return;
|
|
131
|
+
const linkElement = document.createElement('link');
|
|
132
|
+
linkElement.id = 'ux-preload-fonts-link';
|
|
133
|
+
linkElement.rel = 'stylesheet';
|
|
134
|
+
linkElement.href = PRELOAD_FONTS_URL;
|
|
135
|
+
document.head.appendChild(linkElement);
|
|
136
|
+
};
|
|
137
|
+
const setCSSProperty = (property, value)=>{
|
|
138
|
+
if ('undefined' == typeof window) return;
|
|
139
|
+
const root = document.documentElement;
|
|
140
|
+
root.style.setProperty(property, hexColorToHSLValue(value));
|
|
141
|
+
};
|
|
142
|
+
const applyCustomThemeColors = (theme)=>{
|
|
143
|
+
if ('undefined' == typeof window) return;
|
|
144
|
+
const cssProperties = getCSSProperties(theme);
|
|
145
|
+
Object.entries(cssProperties).forEach(([, value])=>{
|
|
146
|
+
value.forEach(([variable, value])=>{
|
|
147
|
+
setCSSProperty(variable, value);
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
};
|
|
151
|
+
const clearCustomThemeColors = ()=>{
|
|
152
|
+
if ('undefined' == typeof window) return;
|
|
153
|
+
const rootStyles = getComputedStyle(document.documentElement);
|
|
154
|
+
Array.from(rootStyles).filter((prop)=>prop.startsWith('--heroui')).forEach((prop)=>{
|
|
155
|
+
document.documentElement.style.removeProperty(prop);
|
|
156
|
+
});
|
|
157
|
+
};
|
|
158
|
+
const applyTheme = (theme)=>{
|
|
159
|
+
if ('undefined' == typeof window) return;
|
|
160
|
+
const root = document.documentElement;
|
|
161
|
+
const isClassListCorrect = root.classList.contains(theme.id);
|
|
162
|
+
const isDataThemeCorrect = root.getAttribute('data-theme') === theme.colorScheme;
|
|
163
|
+
const isDataPrefersColorCorrect = root.getAttribute('data-prefers-color') === theme.colorScheme;
|
|
164
|
+
if ('custom' === theme.id) {
|
|
165
|
+
clearCustomThemeColors();
|
|
166
|
+
applyCustomThemeColors(theme);
|
|
167
|
+
} else clearCustomThemeColors();
|
|
168
|
+
if (isClassListCorrect && isDataThemeCorrect && isDataPrefersColorCorrect && 'custom' !== theme.id) return;
|
|
169
|
+
if (!isDataThemeCorrect) root.setAttribute('data-theme', theme.colorScheme);
|
|
170
|
+
if (!isDataPrefersColorCorrect) root.setAttribute('data-prefers-color', theme.colorScheme);
|
|
171
|
+
root.classList.remove('dark');
|
|
172
|
+
root.classList.remove('light');
|
|
173
|
+
if (!isClassListCorrect) {
|
|
174
|
+
themeKeys.forEach((key)=>{
|
|
175
|
+
root.classList.remove(key);
|
|
176
|
+
});
|
|
177
|
+
root.classList.add('custom' === theme.id ? theme.baseThemeId : theme.id);
|
|
178
|
+
}
|
|
179
|
+
};
|
|
180
|
+
const extractFontFamilyFromLink = (link)=>{
|
|
181
|
+
if (!link) return null;
|
|
182
|
+
try {
|
|
183
|
+
const url = new URL(link);
|
|
184
|
+
const familyParam = url.searchParams.get('family');
|
|
185
|
+
if (!familyParam) return null;
|
|
186
|
+
const firstFamily = familyParam.split('&family=')[0].split(':')[0].replace(/\+/g, ' ');
|
|
187
|
+
return firstFamily;
|
|
188
|
+
} catch {
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
};
|
|
192
|
+
const applyFont = (fontName)=>{
|
|
193
|
+
if ('undefined' == typeof window) return;
|
|
194
|
+
if (fontName) {
|
|
195
|
+
document.documentElement.style.setProperty('--ux-font-family', `"${fontName}", ${DEFAULT_FONT_FAMILY}`);
|
|
196
|
+
document.body.style.fontFamily = `"${fontName}", ${DEFAULT_FONT_FAMILY}`;
|
|
197
|
+
} else {
|
|
198
|
+
document.documentElement.style.setProperty('--ux-font-family', DEFAULT_FONT_FAMILY);
|
|
199
|
+
document.body.style.fontFamily = DEFAULT_FONT_FAMILY;
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
export { applyCustomThemeColors, applyFont, applyTheme, clearCustomThemeColors, extractFontFamilyFromLink, preloadFonts, setCSSProperty };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from 'react';
|
|
2
|
-
import type { UXForegroundColor } from '@particle-network/ui-shared';
|
|
2
|
+
import type { HexColor, UXForegroundColor } from '@particle-network/ui-shared';
|
|
3
3
|
type TextVariant = 'h1' | 'h2' | 'h3' | 'body1' | 'body1Bold' | 'body2' | 'body2Bold' | 'body3' | 'body3Bold' | 'caption1' | 'caption1Bold';
|
|
4
4
|
type TextWeight = 'normal' | 'medium' | 'semibold' | 'bold' | 'extrabold';
|
|
5
5
|
type TextLineHeight = '1' | '1.4';
|
|
@@ -75,7 +75,7 @@ export interface TextProps extends React.HTMLAttributes<HTMLSpanElement> {
|
|
|
75
75
|
* | extrabold | 800 |
|
|
76
76
|
*/
|
|
77
77
|
fontWeight?: TextWeight;
|
|
78
|
-
color?: UXForegroundColor |
|
|
78
|
+
color?: UXForegroundColor | HexColor;
|
|
79
79
|
lineHeight?: TextLineHeight;
|
|
80
80
|
align?: TextAlign;
|
|
81
81
|
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { Config, ConfigColors, ConfigLayout } from './types';
|
|
2
|
+
export declare const defaultDarkColorWeight = 20;
|
|
3
|
+
export declare const defaultLightColorWeight = 17.5;
|
|
4
|
+
export declare const colorWeight = 17.5;
|
|
5
|
+
export declare const floatNumberPattern: RegExp;
|
|
6
|
+
export declare const colorsId = "th-colors";
|
|
7
|
+
export declare const defaultColorsId = "th-default-colors";
|
|
8
|
+
export declare const baseColorsId = "th-base-colors";
|
|
9
|
+
export declare const otherColorsId = "th-other-colors";
|
|
10
|
+
export declare const showcaseId = "th-showcase";
|
|
11
|
+
export declare const contentShowcaseId = "th-content-showcase";
|
|
12
|
+
export declare const contentColorsId = "th-content-colors";
|
|
13
|
+
export declare const configKey = "config";
|
|
14
|
+
export declare const syncThemesKey = "sync-themes";
|
|
15
|
+
export declare const initialLightTheme: ConfigColors;
|
|
16
|
+
export declare const initialDarkTheme: ConfigColors;
|
|
17
|
+
export declare const initialLayout: ConfigLayout;
|
|
18
|
+
export declare const initialConfig: Config;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { colors } from "@heroui/theme";
|
|
2
|
+
const defaultDarkColorWeight = 20;
|
|
3
|
+
const defaultLightColorWeight = 17.5;
|
|
4
|
+
const colorWeight = 17.5;
|
|
5
|
+
const floatNumberPattern = /^\d+(\.\d*)?$/;
|
|
6
|
+
const colorsId = 'th-colors';
|
|
7
|
+
const defaultColorsId = 'th-default-colors';
|
|
8
|
+
const baseColorsId = 'th-base-colors';
|
|
9
|
+
const otherColorsId = 'th-other-colors';
|
|
10
|
+
const showcaseId = 'th-showcase';
|
|
11
|
+
const contentShowcaseId = 'th-content-showcase';
|
|
12
|
+
const contentColorsId = 'th-content-colors';
|
|
13
|
+
const configKey = 'config';
|
|
14
|
+
const syncThemesKey = 'sync-themes';
|
|
15
|
+
const initialLightTheme = {
|
|
16
|
+
defaultColor: {
|
|
17
|
+
default: '#d4d4d8'
|
|
18
|
+
},
|
|
19
|
+
baseColor: {
|
|
20
|
+
primary: colors.blue["500"],
|
|
21
|
+
secondary: colors.purple["500"],
|
|
22
|
+
success: colors.green["500"],
|
|
23
|
+
warning: colors.yellow["500"],
|
|
24
|
+
danger: colors.red["500"]
|
|
25
|
+
},
|
|
26
|
+
layoutColor: {
|
|
27
|
+
foreground: colors.black,
|
|
28
|
+
background: colors.white,
|
|
29
|
+
focus: colors.blue["500"],
|
|
30
|
+
overlay: colors.white
|
|
31
|
+
},
|
|
32
|
+
contentColor: {
|
|
33
|
+
content1: colors.white,
|
|
34
|
+
content2: colors.zinc["100"],
|
|
35
|
+
content3: colors.zinc["200"],
|
|
36
|
+
content4: colors.zinc["300"]
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const initialDarkTheme = {
|
|
40
|
+
defaultColor: {
|
|
41
|
+
default: colors.zinc["700"]
|
|
42
|
+
},
|
|
43
|
+
baseColor: {
|
|
44
|
+
primary: colors.blue["500"],
|
|
45
|
+
secondary: colors.purple["500"],
|
|
46
|
+
success: colors.green["500"],
|
|
47
|
+
warning: colors.yellow["500"],
|
|
48
|
+
danger: colors.red["500"]
|
|
49
|
+
},
|
|
50
|
+
layoutColor: {
|
|
51
|
+
foreground: colors.white,
|
|
52
|
+
background: colors.black,
|
|
53
|
+
focus: colors.blue["500"],
|
|
54
|
+
overlay: colors.black
|
|
55
|
+
},
|
|
56
|
+
contentColor: {
|
|
57
|
+
content1: colors.zinc["900"],
|
|
58
|
+
content2: colors.zinc["800"],
|
|
59
|
+
content3: colors.zinc["700"],
|
|
60
|
+
content4: colors.zinc["600"]
|
|
61
|
+
}
|
|
62
|
+
};
|
|
63
|
+
const initialLayout = {
|
|
64
|
+
fontSize: {
|
|
65
|
+
tiny: '0.75',
|
|
66
|
+
small: '0.875',
|
|
67
|
+
medium: '1',
|
|
68
|
+
large: '1.125'
|
|
69
|
+
},
|
|
70
|
+
lineHeight: {
|
|
71
|
+
tiny: '1',
|
|
72
|
+
small: '1.25',
|
|
73
|
+
medium: '1.5',
|
|
74
|
+
large: '1.75'
|
|
75
|
+
},
|
|
76
|
+
radius: {
|
|
77
|
+
small: '0.5',
|
|
78
|
+
medium: '0.75',
|
|
79
|
+
large: '0.875'
|
|
80
|
+
},
|
|
81
|
+
borderWidth: {
|
|
82
|
+
small: '1',
|
|
83
|
+
medium: '2',
|
|
84
|
+
large: '3'
|
|
85
|
+
},
|
|
86
|
+
otherParams: {
|
|
87
|
+
disabledOpacity: '0.5',
|
|
88
|
+
dividerWeight: '1',
|
|
89
|
+
hoverOpacity: '0.9'
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
const initialConfig = {
|
|
93
|
+
name: 'heroui',
|
|
94
|
+
light: initialLightTheme,
|
|
95
|
+
dark: initialDarkTheme,
|
|
96
|
+
layout: initialLayout
|
|
97
|
+
};
|
|
98
|
+
export { baseColorsId, colorWeight, colorsId, configKey, contentColorsId, contentShowcaseId, defaultColorsId, defaultDarkColorWeight, defaultLightColorWeight, floatNumberPattern, initialConfig, initialDarkTheme, initialLayout, initialLightTheme, otherColorsId, showcaseId, syncThemesKey };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
export interface ColorShades {
|
|
2
|
+
50: string;
|
|
3
|
+
100: string;
|
|
4
|
+
200: string;
|
|
5
|
+
300: string;
|
|
6
|
+
400: string;
|
|
7
|
+
500: string;
|
|
8
|
+
600: string;
|
|
9
|
+
700: string;
|
|
10
|
+
800: string;
|
|
11
|
+
900: string;
|
|
12
|
+
}
|
|
13
|
+
export type ColorPickerType = 'background' | 'content1' | 'content2' | 'content3' | 'content4' | 'danger' | 'default' | 'divider' | 'focus' | 'foreground' | 'overlay' | 'primary' | 'secondary' | 'success' | 'warning';
|
|
14
|
+
export type Color = 'default' | 'primary' | 'secondary' | 'success' | 'warning' | 'danger';
|
|
15
|
+
export type Size = 'sm' | 'md' | 'lg';
|
|
16
|
+
export type Variant = 'dot' | 'solid' | 'faded' | 'bordered' | 'light' | 'flat' | 'ghost' | 'shadow' | 'underlined';
|
|
17
|
+
export type Radius = 'none' | 'sm' | 'md' | 'lg' | 'full';
|
|
18
|
+
export type HeroUIScaling = 90 | 95 | 100 | 105 | 110;
|
|
19
|
+
export type Border = 'thin' | 'medium' | 'thick';
|
|
20
|
+
export type FontName = 'Inter' | 'Roboto' | 'Outfit' | 'Lora';
|
|
21
|
+
export type ThemeType = 'light' | 'dark';
|
|
22
|
+
export interface ThemeColor extends ColorShades {
|
|
23
|
+
foreground: string;
|
|
24
|
+
DEFAULT: string;
|
|
25
|
+
}
|
|
26
|
+
export interface Config {
|
|
27
|
+
name: TemplateType;
|
|
28
|
+
light: ConfigColors;
|
|
29
|
+
dark: ConfigColors;
|
|
30
|
+
layout: ConfigLayout;
|
|
31
|
+
}
|
|
32
|
+
export interface ConfigColors {
|
|
33
|
+
defaultColor: {
|
|
34
|
+
default: string;
|
|
35
|
+
};
|
|
36
|
+
baseColor: {
|
|
37
|
+
primary: string;
|
|
38
|
+
secondary: string;
|
|
39
|
+
success: string;
|
|
40
|
+
warning: string;
|
|
41
|
+
danger: string;
|
|
42
|
+
};
|
|
43
|
+
layoutColor: {
|
|
44
|
+
foreground: string;
|
|
45
|
+
background: string;
|
|
46
|
+
focus: string;
|
|
47
|
+
overlay: string;
|
|
48
|
+
};
|
|
49
|
+
contentColor: {
|
|
50
|
+
content1: string;
|
|
51
|
+
content2: string;
|
|
52
|
+
content3: string;
|
|
53
|
+
content4: string;
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
export interface ConfigLayout {
|
|
57
|
+
fontSize: {
|
|
58
|
+
tiny: string;
|
|
59
|
+
small: string;
|
|
60
|
+
medium: string;
|
|
61
|
+
large: string;
|
|
62
|
+
};
|
|
63
|
+
lineHeight: {
|
|
64
|
+
tiny: string;
|
|
65
|
+
small: string;
|
|
66
|
+
medium: string;
|
|
67
|
+
large: string;
|
|
68
|
+
};
|
|
69
|
+
radius: {
|
|
70
|
+
small: string;
|
|
71
|
+
medium: string;
|
|
72
|
+
large: string;
|
|
73
|
+
};
|
|
74
|
+
borderWidth: {
|
|
75
|
+
small: string;
|
|
76
|
+
medium: string;
|
|
77
|
+
large: string;
|
|
78
|
+
};
|
|
79
|
+
otherParams: {
|
|
80
|
+
disabledOpacity: string;
|
|
81
|
+
dividerWeight: string;
|
|
82
|
+
hoverOpacity: string;
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
export interface Template {
|
|
86
|
+
label: string;
|
|
87
|
+
name: TemplateType;
|
|
88
|
+
value: Config;
|
|
89
|
+
}
|
|
90
|
+
export type TemplateType = 'coffee' | 'emerald' | 'heroui' | 'elegant' | 'modern' | 'retro';
|
|
91
|
+
export type FontType = 'Inter' | 'Roboto' | 'Outfit' | 'Lora';
|
|
File without changes
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { ColorPickerType, ThemeType } from '../types';
|
|
2
|
+
import Values from 'values.js';
|
|
3
|
+
/**
|
|
4
|
+
* Convert color values to RGB
|
|
5
|
+
*/
|
|
6
|
+
export declare function colorValuesToRgb(value: Values): string;
|
|
7
|
+
/**
|
|
8
|
+
* Convert hex color to HSL
|
|
9
|
+
*/
|
|
10
|
+
export declare function hexToHsl(hex: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Get the color weight
|
|
13
|
+
*/
|
|
14
|
+
export declare function getColorWeight(colorType: ColorPickerType, theme: ThemeType): 20 | 17.5;
|
|
15
|
+
/**
|
|
16
|
+
* Generate theme color
|
|
17
|
+
*/
|
|
18
|
+
export declare function generateThemeColor(color: string, type: ColorPickerType, theme: ThemeType): {
|
|
19
|
+
twTheme: {
|
|
20
|
+
foreground: string;
|
|
21
|
+
DEFAULT: string;
|
|
22
|
+
50: string;
|
|
23
|
+
100: string;
|
|
24
|
+
200: string;
|
|
25
|
+
300: string;
|
|
26
|
+
400: string;
|
|
27
|
+
500: string;
|
|
28
|
+
600: string;
|
|
29
|
+
700: string;
|
|
30
|
+
800: string;
|
|
31
|
+
900: string;
|
|
32
|
+
};
|
|
33
|
+
cssVariables: string[][];
|
|
34
|
+
};
|