@tomo-inc/tomo-ui 0.0.13 → 0.0.14
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 +3 -8
- package/dist/index.cjs +50 -19
- package/dist/index.js +50 -19
- package/dist/tailwind/plugin.cjs +31 -17
- package/dist/tailwind/plugin.js +30 -17
- package/package.json +1 -1
- package/src/App.tsx +3 -36
- package/src/tailwind/plugin.ts +30 -17
- package/src/tailwind/theme-to-css.ts +37 -5
package/README.md
CHANGED
|
@@ -103,22 +103,18 @@ Tomo UI allows you to provide a theme configuration at runtime.
|
|
|
103
103
|
The type is aligned with HeroUI’s theme configuration surface.
|
|
104
104
|
|
|
105
105
|
```tsx
|
|
106
|
-
import {
|
|
107
|
-
TomoUIProvider,
|
|
108
|
-
useTheme,
|
|
109
|
-
type ThemeConfig,
|
|
110
|
-
} from "@tomo-inc/tomo-ui";
|
|
106
|
+
import { TomoUIProvider, useTheme, type ThemeConfig } from "@tomo-inc/tomo-ui";
|
|
111
107
|
|
|
112
108
|
const themeConfig: ThemeConfig = {
|
|
113
109
|
themes: {
|
|
114
110
|
light: {
|
|
115
111
|
colors: {
|
|
116
|
-
primary: "#
|
|
112
|
+
primary: "#fe3c9c",
|
|
117
113
|
},
|
|
118
114
|
},
|
|
119
115
|
dark: {
|
|
120
116
|
colors: {
|
|
121
|
-
primary: "#
|
|
117
|
+
primary: "#fe3c9c",
|
|
122
118
|
},
|
|
123
119
|
},
|
|
124
120
|
},
|
|
@@ -214,4 +210,3 @@ If you are extending `@tomo-inc/tomo-ui` or integrating it into a new applicatio
|
|
|
214
210
|
- Prefer importing from the root package (`@tomo-inc/tomo-ui`) instead of deep imports.
|
|
215
211
|
- Avoid depending on HeroUI directly; treat it as an internal implementation detail.
|
|
216
212
|
- Keep Tailwind integration minimal and aligned with the usage examples above, so that future UI framework changes can remain transparent to applications.
|
|
217
|
-
|
package/dist/index.cjs
CHANGED
|
@@ -834,6 +834,20 @@ var import_react25 = require("react");
|
|
|
834
834
|
|
|
835
835
|
// src/tailwind/plugin.ts
|
|
836
836
|
var import_react23 = require("@heroui/react");
|
|
837
|
+
var TOMO_PRIMARY = {
|
|
838
|
+
50: "#FFFBEA",
|
|
839
|
+
100: "#FED8DB",
|
|
840
|
+
200: "#FEB1C0",
|
|
841
|
+
300: "#FE89AC",
|
|
842
|
+
400: "#FE6CA6",
|
|
843
|
+
500: "#FE3C9C",
|
|
844
|
+
600: "#DA2B93",
|
|
845
|
+
700: "#B61E88",
|
|
846
|
+
800: "#931379",
|
|
847
|
+
900: "#790B6E",
|
|
848
|
+
foreground: "#12122A",
|
|
849
|
+
DEFAULT: "#FE3C9C"
|
|
850
|
+
};
|
|
837
851
|
var baseConfig = {
|
|
838
852
|
// Don't change this prefix, some css not working
|
|
839
853
|
prefix: "heroui",
|
|
@@ -843,37 +857,49 @@ var baseConfig = {
|
|
|
843
857
|
foreground: "#12122A",
|
|
844
858
|
background: "#FFF",
|
|
845
859
|
content1: "#FCFCFD",
|
|
846
|
-
primary:
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
300: "#FADB5F",
|
|
851
|
-
400: "#F7C948",
|
|
852
|
-
500: "#FCD436",
|
|
853
|
-
600: "#F0B429",
|
|
854
|
-
700: "#DE911D",
|
|
855
|
-
800: "#CB6E17",
|
|
856
|
-
900: "#B44D12",
|
|
857
|
-
foreground: "#12122A",
|
|
858
|
-
DEFAULT: "#FCD436"
|
|
859
|
-
},
|
|
860
|
-
danger: "#FF5A5A",
|
|
861
|
-
warning: "#FFAD32",
|
|
862
|
-
success: "#079455",
|
|
860
|
+
primary: TOMO_PRIMARY,
|
|
861
|
+
danger: "#FF447C",
|
|
862
|
+
warning: "#FF9F4C",
|
|
863
|
+
success: "#A8D84E",
|
|
863
864
|
t1: "#12122A",
|
|
864
865
|
t2: "#616184",
|
|
865
866
|
t3: "#8989AB",
|
|
866
867
|
t4: "#C1C0D8",
|
|
867
868
|
t5: "#EEC41F"
|
|
868
869
|
}
|
|
870
|
+
},
|
|
871
|
+
dark: {
|
|
872
|
+
colors: {
|
|
873
|
+
foreground: "#ECEDEE",
|
|
874
|
+
background: "#000",
|
|
875
|
+
content1: "#18181b",
|
|
876
|
+
primary: { ...TOMO_PRIMARY, foreground: "#FFF" },
|
|
877
|
+
danger: "#FF447C",
|
|
878
|
+
warning: "#FF9F4C",
|
|
879
|
+
success: "#A8D84E"
|
|
880
|
+
}
|
|
869
881
|
}
|
|
870
882
|
}
|
|
871
883
|
};
|
|
872
884
|
var plugin_default = (0, import_react23.heroui)(baseConfig);
|
|
873
885
|
|
|
874
886
|
// src/tailwind/theme-to-css.ts
|
|
887
|
+
var import_theme = require("@heroui/theme");
|
|
875
888
|
var import_color = __toESM(require("color"), 1);
|
|
876
889
|
var flat = __toESM(require("flat"), 1);
|
|
890
|
+
function deepMerge(a, b) {
|
|
891
|
+
const result = { ...a };
|
|
892
|
+
for (const key of Object.keys(b)) {
|
|
893
|
+
const aVal = a[key];
|
|
894
|
+
const bVal = b[key];
|
|
895
|
+
if (aVal && bVal && typeof aVal === "object" && !Array.isArray(aVal) && typeof bVal === "object" && !Array.isArray(bVal)) {
|
|
896
|
+
result[key] = deepMerge(aVal, bVal);
|
|
897
|
+
} else {
|
|
898
|
+
result[key] = bVal;
|
|
899
|
+
}
|
|
900
|
+
}
|
|
901
|
+
return result;
|
|
902
|
+
}
|
|
877
903
|
function toKebabCase(str) {
|
|
878
904
|
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
879
905
|
}
|
|
@@ -939,6 +965,7 @@ function processLayoutTheme(layout, prefix) {
|
|
|
939
965
|
return cssVars;
|
|
940
966
|
}
|
|
941
967
|
function themeConfigToCSS(config, scopeId) {
|
|
968
|
+
var _a, _b, _c, _d, _e;
|
|
942
969
|
const prefix = baseConfig.prefix || "tomo";
|
|
943
970
|
const themes = config.themes || {};
|
|
944
971
|
const cssBlocks = [];
|
|
@@ -946,8 +973,12 @@ function themeConfigToCSS(config, scopeId) {
|
|
|
946
973
|
const scopeSelector = scopeId ? `#${scopeId.replace(/:/g, "\\:")}` : "";
|
|
947
974
|
for (const [themeName, themeConfig] of Object.entries(themes)) {
|
|
948
975
|
const cssVars = [];
|
|
949
|
-
|
|
950
|
-
const
|
|
976
|
+
{
|
|
977
|
+
const heroDefaultColors = (_a = import_theme.semanticColors[themeName]) != null ? _a : {};
|
|
978
|
+
const baseConfigColors = (_d = (_c = (_b = baseConfig.themes) == null ? void 0 : _b[themeName]) == null ? void 0 : _c.colors) != null ? _d : {};
|
|
979
|
+
const userColors = (_e = themeConfig == null ? void 0 : themeConfig.colors) != null ? _e : {};
|
|
980
|
+
const mergedColors = deepMerge(deepMerge(heroDefaultColors, baseConfigColors), userColors);
|
|
981
|
+
const flatColors = flattenThemeObject(mergedColors);
|
|
951
982
|
for (const [colorKey, colorValue] of Object.entries(flatColors)) {
|
|
952
983
|
if (!colorValue) continue;
|
|
953
984
|
const value = toHslString(colorValue);
|
package/dist/index.js
CHANGED
|
@@ -742,6 +742,20 @@ import { useId, useMemo as useMemo2 } from "react";
|
|
|
742
742
|
|
|
743
743
|
// src/tailwind/plugin.ts
|
|
744
744
|
import { heroui } from "@heroui/react";
|
|
745
|
+
var TOMO_PRIMARY = {
|
|
746
|
+
50: "#FFFBEA",
|
|
747
|
+
100: "#FED8DB",
|
|
748
|
+
200: "#FEB1C0",
|
|
749
|
+
300: "#FE89AC",
|
|
750
|
+
400: "#FE6CA6",
|
|
751
|
+
500: "#FE3C9C",
|
|
752
|
+
600: "#DA2B93",
|
|
753
|
+
700: "#B61E88",
|
|
754
|
+
800: "#931379",
|
|
755
|
+
900: "#790B6E",
|
|
756
|
+
foreground: "#12122A",
|
|
757
|
+
DEFAULT: "#FE3C9C"
|
|
758
|
+
};
|
|
745
759
|
var baseConfig = {
|
|
746
760
|
// Don't change this prefix, some css not working
|
|
747
761
|
prefix: "heroui",
|
|
@@ -751,37 +765,49 @@ var baseConfig = {
|
|
|
751
765
|
foreground: "#12122A",
|
|
752
766
|
background: "#FFF",
|
|
753
767
|
content1: "#FCFCFD",
|
|
754
|
-
primary:
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
300: "#FADB5F",
|
|
759
|
-
400: "#F7C948",
|
|
760
|
-
500: "#FCD436",
|
|
761
|
-
600: "#F0B429",
|
|
762
|
-
700: "#DE911D",
|
|
763
|
-
800: "#CB6E17",
|
|
764
|
-
900: "#B44D12",
|
|
765
|
-
foreground: "#12122A",
|
|
766
|
-
DEFAULT: "#FCD436"
|
|
767
|
-
},
|
|
768
|
-
danger: "#FF5A5A",
|
|
769
|
-
warning: "#FFAD32",
|
|
770
|
-
success: "#079455",
|
|
768
|
+
primary: TOMO_PRIMARY,
|
|
769
|
+
danger: "#FF447C",
|
|
770
|
+
warning: "#FF9F4C",
|
|
771
|
+
success: "#A8D84E",
|
|
771
772
|
t1: "#12122A",
|
|
772
773
|
t2: "#616184",
|
|
773
774
|
t3: "#8989AB",
|
|
774
775
|
t4: "#C1C0D8",
|
|
775
776
|
t5: "#EEC41F"
|
|
776
777
|
}
|
|
778
|
+
},
|
|
779
|
+
dark: {
|
|
780
|
+
colors: {
|
|
781
|
+
foreground: "#ECEDEE",
|
|
782
|
+
background: "#000",
|
|
783
|
+
content1: "#18181b",
|
|
784
|
+
primary: { ...TOMO_PRIMARY, foreground: "#FFF" },
|
|
785
|
+
danger: "#FF447C",
|
|
786
|
+
warning: "#FF9F4C",
|
|
787
|
+
success: "#A8D84E"
|
|
788
|
+
}
|
|
777
789
|
}
|
|
778
790
|
}
|
|
779
791
|
};
|
|
780
792
|
var plugin_default = heroui(baseConfig);
|
|
781
793
|
|
|
782
794
|
// src/tailwind/theme-to-css.ts
|
|
795
|
+
import { semanticColors } from "@heroui/theme";
|
|
783
796
|
import Color from "color";
|
|
784
797
|
import * as flat from "flat";
|
|
798
|
+
function deepMerge(a, b) {
|
|
799
|
+
const result = { ...a };
|
|
800
|
+
for (const key of Object.keys(b)) {
|
|
801
|
+
const aVal = a[key];
|
|
802
|
+
const bVal = b[key];
|
|
803
|
+
if (aVal && bVal && typeof aVal === "object" && !Array.isArray(aVal) && typeof bVal === "object" && !Array.isArray(bVal)) {
|
|
804
|
+
result[key] = deepMerge(aVal, bVal);
|
|
805
|
+
} else {
|
|
806
|
+
result[key] = bVal;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
return result;
|
|
810
|
+
}
|
|
785
811
|
function toKebabCase(str) {
|
|
786
812
|
return str.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g, "$1-$2").toLowerCase();
|
|
787
813
|
}
|
|
@@ -847,6 +873,7 @@ function processLayoutTheme(layout, prefix) {
|
|
|
847
873
|
return cssVars;
|
|
848
874
|
}
|
|
849
875
|
function themeConfigToCSS(config, scopeId) {
|
|
876
|
+
var _a, _b, _c, _d, _e;
|
|
850
877
|
const prefix = baseConfig.prefix || "tomo";
|
|
851
878
|
const themes = config.themes || {};
|
|
852
879
|
const cssBlocks = [];
|
|
@@ -854,8 +881,12 @@ function themeConfigToCSS(config, scopeId) {
|
|
|
854
881
|
const scopeSelector = scopeId ? `#${scopeId.replace(/:/g, "\\:")}` : "";
|
|
855
882
|
for (const [themeName, themeConfig] of Object.entries(themes)) {
|
|
856
883
|
const cssVars = [];
|
|
857
|
-
|
|
858
|
-
const
|
|
884
|
+
{
|
|
885
|
+
const heroDefaultColors = (_a = semanticColors[themeName]) != null ? _a : {};
|
|
886
|
+
const baseConfigColors = (_d = (_c = (_b = baseConfig.themes) == null ? void 0 : _b[themeName]) == null ? void 0 : _c.colors) != null ? _d : {};
|
|
887
|
+
const userColors = (_e = themeConfig == null ? void 0 : themeConfig.colors) != null ? _e : {};
|
|
888
|
+
const mergedColors = deepMerge(deepMerge(heroDefaultColors, baseConfigColors), userColors);
|
|
889
|
+
const flatColors = flattenThemeObject(mergedColors);
|
|
859
890
|
for (const [colorKey, colorValue] of Object.entries(flatColors)) {
|
|
860
891
|
if (!colorValue) continue;
|
|
861
892
|
const value = toHslString(colorValue);
|
package/dist/tailwind/plugin.cjs
CHANGED
|
@@ -20,11 +20,26 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/tailwind/plugin.ts
|
|
21
21
|
var plugin_exports = {};
|
|
22
22
|
__export(plugin_exports, {
|
|
23
|
+
TOMO_PRIMARY: () => TOMO_PRIMARY,
|
|
23
24
|
baseConfig: () => baseConfig,
|
|
24
25
|
default: () => plugin_default
|
|
25
26
|
});
|
|
26
27
|
module.exports = __toCommonJS(plugin_exports);
|
|
27
28
|
var import_react = require("@heroui/react");
|
|
29
|
+
var TOMO_PRIMARY = {
|
|
30
|
+
50: "#FFFBEA",
|
|
31
|
+
100: "#FED8DB",
|
|
32
|
+
200: "#FEB1C0",
|
|
33
|
+
300: "#FE89AC",
|
|
34
|
+
400: "#FE6CA6",
|
|
35
|
+
500: "#FE3C9C",
|
|
36
|
+
600: "#DA2B93",
|
|
37
|
+
700: "#B61E88",
|
|
38
|
+
800: "#931379",
|
|
39
|
+
900: "#790B6E",
|
|
40
|
+
foreground: "#12122A",
|
|
41
|
+
DEFAULT: "#FE3C9C"
|
|
42
|
+
};
|
|
28
43
|
var baseConfig = {
|
|
29
44
|
// Don't change this prefix, some css not working
|
|
30
45
|
prefix: "heroui",
|
|
@@ -34,34 +49,33 @@ var baseConfig = {
|
|
|
34
49
|
foreground: "#12122A",
|
|
35
50
|
background: "#FFF",
|
|
36
51
|
content1: "#FCFCFD",
|
|
37
|
-
primary:
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
300: "#FADB5F",
|
|
42
|
-
400: "#F7C948",
|
|
43
|
-
500: "#FCD436",
|
|
44
|
-
600: "#F0B429",
|
|
45
|
-
700: "#DE911D",
|
|
46
|
-
800: "#CB6E17",
|
|
47
|
-
900: "#B44D12",
|
|
48
|
-
foreground: "#12122A",
|
|
49
|
-
DEFAULT: "#FCD436"
|
|
50
|
-
},
|
|
51
|
-
danger: "#FF5A5A",
|
|
52
|
-
warning: "#FFAD32",
|
|
53
|
-
success: "#079455",
|
|
52
|
+
primary: TOMO_PRIMARY,
|
|
53
|
+
danger: "#FF447C",
|
|
54
|
+
warning: "#FF9F4C",
|
|
55
|
+
success: "#A8D84E",
|
|
54
56
|
t1: "#12122A",
|
|
55
57
|
t2: "#616184",
|
|
56
58
|
t3: "#8989AB",
|
|
57
59
|
t4: "#C1C0D8",
|
|
58
60
|
t5: "#EEC41F"
|
|
59
61
|
}
|
|
62
|
+
},
|
|
63
|
+
dark: {
|
|
64
|
+
colors: {
|
|
65
|
+
foreground: "#ECEDEE",
|
|
66
|
+
background: "#000",
|
|
67
|
+
content1: "#18181b",
|
|
68
|
+
primary: { ...TOMO_PRIMARY, foreground: "#FFF" },
|
|
69
|
+
danger: "#FF447C",
|
|
70
|
+
warning: "#FF9F4C",
|
|
71
|
+
success: "#A8D84E"
|
|
72
|
+
}
|
|
60
73
|
}
|
|
61
74
|
}
|
|
62
75
|
};
|
|
63
76
|
var plugin_default = (0, import_react.heroui)(baseConfig);
|
|
64
77
|
// Annotate the CommonJS export names for ESM import in node:
|
|
65
78
|
0 && (module.exports = {
|
|
79
|
+
TOMO_PRIMARY,
|
|
66
80
|
baseConfig
|
|
67
81
|
});
|
package/dist/tailwind/plugin.js
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
// src/tailwind/plugin.ts
|
|
2
2
|
import { heroui } from "@heroui/react";
|
|
3
|
+
var TOMO_PRIMARY = {
|
|
4
|
+
50: "#FFFBEA",
|
|
5
|
+
100: "#FED8DB",
|
|
6
|
+
200: "#FEB1C0",
|
|
7
|
+
300: "#FE89AC",
|
|
8
|
+
400: "#FE6CA6",
|
|
9
|
+
500: "#FE3C9C",
|
|
10
|
+
600: "#DA2B93",
|
|
11
|
+
700: "#B61E88",
|
|
12
|
+
800: "#931379",
|
|
13
|
+
900: "#790B6E",
|
|
14
|
+
foreground: "#12122A",
|
|
15
|
+
DEFAULT: "#FE3C9C"
|
|
16
|
+
};
|
|
3
17
|
var baseConfig = {
|
|
4
18
|
// Don't change this prefix, some css not working
|
|
5
19
|
prefix: "heroui",
|
|
@@ -9,34 +23,33 @@ var baseConfig = {
|
|
|
9
23
|
foreground: "#12122A",
|
|
10
24
|
background: "#FFF",
|
|
11
25
|
content1: "#FCFCFD",
|
|
12
|
-
primary:
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
300: "#FADB5F",
|
|
17
|
-
400: "#F7C948",
|
|
18
|
-
500: "#FCD436",
|
|
19
|
-
600: "#F0B429",
|
|
20
|
-
700: "#DE911D",
|
|
21
|
-
800: "#CB6E17",
|
|
22
|
-
900: "#B44D12",
|
|
23
|
-
foreground: "#12122A",
|
|
24
|
-
DEFAULT: "#FCD436"
|
|
25
|
-
},
|
|
26
|
-
danger: "#FF5A5A",
|
|
27
|
-
warning: "#FFAD32",
|
|
28
|
-
success: "#079455",
|
|
26
|
+
primary: TOMO_PRIMARY,
|
|
27
|
+
danger: "#FF447C",
|
|
28
|
+
warning: "#FF9F4C",
|
|
29
|
+
success: "#A8D84E",
|
|
29
30
|
t1: "#12122A",
|
|
30
31
|
t2: "#616184",
|
|
31
32
|
t3: "#8989AB",
|
|
32
33
|
t4: "#C1C0D8",
|
|
33
34
|
t5: "#EEC41F"
|
|
34
35
|
}
|
|
36
|
+
},
|
|
37
|
+
dark: {
|
|
38
|
+
colors: {
|
|
39
|
+
foreground: "#ECEDEE",
|
|
40
|
+
background: "#000",
|
|
41
|
+
content1: "#18181b",
|
|
42
|
+
primary: { ...TOMO_PRIMARY, foreground: "#FFF" },
|
|
43
|
+
danger: "#FF447C",
|
|
44
|
+
warning: "#FF9F4C",
|
|
45
|
+
success: "#A8D84E"
|
|
46
|
+
}
|
|
35
47
|
}
|
|
36
48
|
}
|
|
37
49
|
};
|
|
38
50
|
var plugin_default = heroui(baseConfig);
|
|
39
51
|
export {
|
|
52
|
+
TOMO_PRIMARY,
|
|
40
53
|
baseConfig,
|
|
41
54
|
plugin_default as default
|
|
42
55
|
};
|
package/package.json
CHANGED
package/src/App.tsx
CHANGED
|
@@ -5,42 +5,8 @@ import { Input } from "./components/input";
|
|
|
5
5
|
import { Modal, ModalContent, ModalHeader } from "./components/modal";
|
|
6
6
|
|
|
7
7
|
import "./style.css";
|
|
8
|
+
import { baseConfig } from "./tailwind/plugin";
|
|
8
9
|
import { TomoUIProvider } from "./theme-provider";
|
|
9
|
-
import { ThemeConfig } from "./types";
|
|
10
|
-
|
|
11
|
-
const _dogeThemeConfig: ThemeConfig = {
|
|
12
|
-
themes: {
|
|
13
|
-
light: {
|
|
14
|
-
colors: {
|
|
15
|
-
foreground: "#12122A",
|
|
16
|
-
background: "#FFF",
|
|
17
|
-
content1: "#FCFCFD",
|
|
18
|
-
primary: {
|
|
19
|
-
50: "#FFFBEA",
|
|
20
|
-
100: "#FFF3C4",
|
|
21
|
-
200: "#FCE588",
|
|
22
|
-
300: "#FADB5F",
|
|
23
|
-
400: "#F7C948",
|
|
24
|
-
500: "#FCD436",
|
|
25
|
-
600: "#F0B429",
|
|
26
|
-
700: "#DE911D",
|
|
27
|
-
800: "#CB6E17",
|
|
28
|
-
900: "#B44D12",
|
|
29
|
-
foreground: "#12122A",
|
|
30
|
-
DEFAULT: "#FCD436",
|
|
31
|
-
},
|
|
32
|
-
danger: "#FF5A5A",
|
|
33
|
-
warning: "#FFAD32",
|
|
34
|
-
success: "#079455",
|
|
35
|
-
t1: "#12122A",
|
|
36
|
-
t2: "#616184",
|
|
37
|
-
t3: "#8989AB",
|
|
38
|
-
t4: "#C1C0D8",
|
|
39
|
-
t5: "#EEC41F",
|
|
40
|
-
} as any,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
};
|
|
44
10
|
|
|
45
11
|
export const MoonIcon = (props: React.SVGProps<SVGSVGElement>) => {
|
|
46
12
|
return (
|
|
@@ -115,10 +81,11 @@ function App() {
|
|
|
115
81
|
</div>
|
|
116
82
|
</TomoUIProvider>
|
|
117
83
|
<br />
|
|
118
|
-
<TomoUIProvider themeConfig={
|
|
84
|
+
<TomoUIProvider themeConfig={baseConfig}>
|
|
119
85
|
<div className="bg-content1 p-4 rounded-lg flex flex-col gap-4 border border-primary">
|
|
120
86
|
<div className="flex items-center justify-between">
|
|
121
87
|
<h1 className="text-2xl font-bold text-foreground">Doge Theme Config Preview</h1>
|
|
88
|
+
<p className="text-sm text-default">preview text</p>
|
|
122
89
|
<SwitchTheme />
|
|
123
90
|
</div>
|
|
124
91
|
<Input label="Email" type="email" />
|
package/src/tailwind/plugin.ts
CHANGED
|
@@ -1,6 +1,21 @@
|
|
|
1
1
|
import type { HeroUIPluginConfig } from "@heroui/react";
|
|
2
2
|
import { heroui } from "@heroui/react";
|
|
3
3
|
|
|
4
|
+
export const TOMO_PRIMARY = {
|
|
5
|
+
50: "#FFFBEA",
|
|
6
|
+
100: "#FED8DB",
|
|
7
|
+
200: "#FEB1C0",
|
|
8
|
+
300: "#FE89AC",
|
|
9
|
+
400: "#FE6CA6",
|
|
10
|
+
500: "#FE3C9C",
|
|
11
|
+
600: "#DA2B93",
|
|
12
|
+
700: "#B61E88",
|
|
13
|
+
800: "#931379",
|
|
14
|
+
900: "#790B6E",
|
|
15
|
+
foreground: "#12122A",
|
|
16
|
+
DEFAULT: "#FE3C9C",
|
|
17
|
+
};
|
|
18
|
+
|
|
4
19
|
export const baseConfig: HeroUIPluginConfig = {
|
|
5
20
|
// Don't change this prefix, some css not working
|
|
6
21
|
prefix: "heroui",
|
|
@@ -10,23 +25,10 @@ export const baseConfig: HeroUIPluginConfig = {
|
|
|
10
25
|
foreground: "#12122A",
|
|
11
26
|
background: "#FFF",
|
|
12
27
|
content1: "#FCFCFD",
|
|
13
|
-
primary:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
300: "#FADB5F",
|
|
18
|
-
400: "#F7C948",
|
|
19
|
-
500: "#FCD436",
|
|
20
|
-
600: "#F0B429",
|
|
21
|
-
700: "#DE911D",
|
|
22
|
-
800: "#CB6E17",
|
|
23
|
-
900: "#B44D12",
|
|
24
|
-
foreground: "#12122A",
|
|
25
|
-
DEFAULT: "#FCD436",
|
|
26
|
-
},
|
|
27
|
-
danger: "#FF5A5A",
|
|
28
|
-
warning: "#FFAD32",
|
|
29
|
-
success: "#079455",
|
|
28
|
+
primary: TOMO_PRIMARY,
|
|
29
|
+
danger: "#FF447C",
|
|
30
|
+
warning: "#FF9F4C",
|
|
31
|
+
success: "#A8D84E",
|
|
30
32
|
t1: "#12122A",
|
|
31
33
|
t2: "#616184",
|
|
32
34
|
t3: "#8989AB",
|
|
@@ -34,6 +36,17 @@ export const baseConfig: HeroUIPluginConfig = {
|
|
|
34
36
|
t5: "#EEC41F",
|
|
35
37
|
} as any,
|
|
36
38
|
},
|
|
39
|
+
dark: {
|
|
40
|
+
colors: {
|
|
41
|
+
foreground: "#ECEDEE",
|
|
42
|
+
background: "#000",
|
|
43
|
+
content1: "#18181b",
|
|
44
|
+
primary: { ...TOMO_PRIMARY, foreground: "#FFF" },
|
|
45
|
+
danger: "#FF447C",
|
|
46
|
+
warning: "#FF9F4C",
|
|
47
|
+
success: "#A8D84E",
|
|
48
|
+
} as any,
|
|
49
|
+
},
|
|
37
50
|
},
|
|
38
51
|
};
|
|
39
52
|
export default heroui(baseConfig) as any;
|
|
@@ -1,9 +1,34 @@
|
|
|
1
1
|
import type { ColorScale, HeroUIPluginConfig, LayoutTheme } from "@heroui/theme";
|
|
2
|
+
import { semanticColors } from "@heroui/theme";
|
|
2
3
|
|
|
3
4
|
import Color from "color";
|
|
4
5
|
import * as flat from "flat";
|
|
5
6
|
import { baseConfig } from "./plugin";
|
|
6
7
|
|
|
8
|
+
/**
|
|
9
|
+
* Deep-merge two objects: b's values override a's, recursing into nested plain objects.
|
|
10
|
+
*/
|
|
11
|
+
function deepMerge<T extends Record<string, unknown>>(a: T, b: Record<string, unknown>): T {
|
|
12
|
+
const result = { ...a } as Record<string, unknown>;
|
|
13
|
+
for (const key of Object.keys(b)) {
|
|
14
|
+
const aVal = a[key];
|
|
15
|
+
const bVal = b[key];
|
|
16
|
+
if (
|
|
17
|
+
aVal &&
|
|
18
|
+
bVal &&
|
|
19
|
+
typeof aVal === "object" &&
|
|
20
|
+
!Array.isArray(aVal) &&
|
|
21
|
+
typeof bVal === "object" &&
|
|
22
|
+
!Array.isArray(bVal)
|
|
23
|
+
) {
|
|
24
|
+
result[key] = deepMerge(aVal as Record<string, unknown>, bVal as Record<string, unknown>);
|
|
25
|
+
} else {
|
|
26
|
+
result[key] = bVal;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
return result as T;
|
|
30
|
+
}
|
|
31
|
+
|
|
7
32
|
/**
|
|
8
33
|
* Convert camelCase to kebab-case
|
|
9
34
|
* Matches heroui's kebabCase utility
|
|
@@ -170,12 +195,19 @@ export function themeConfigToCSS(config: HeroUIPluginConfig, scopeId?: string):
|
|
|
170
195
|
for (const [themeName, themeConfig] of Object.entries(themes)) {
|
|
171
196
|
const cssVars: string[] = [];
|
|
172
197
|
|
|
173
|
-
//
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
198
|
+
// Merge chain: HeroUI semanticColors → tomo-ui baseConfig → user themeConfig
|
|
199
|
+
// This replicates at runtime what the heroui() Tailwind plugin does at build time,
|
|
200
|
+
// ensuring ALL semantic variables are present in the scoped CSS.
|
|
201
|
+
{
|
|
202
|
+
const heroDefaultColors = (semanticColors as Record<string, Record<string, unknown>>)[themeName] ?? {};
|
|
203
|
+
const baseConfigColors = ((baseConfig.themes as Record<string, any>)?.[themeName]?.colors ?? {}) as Record<
|
|
204
|
+
string,
|
|
205
|
+
unknown
|
|
206
|
+
>;
|
|
207
|
+
const userColors = (themeConfig?.colors ?? {}) as Record<string, unknown>;
|
|
208
|
+
const mergedColors = deepMerge(deepMerge(heroDefaultColors, baseConfigColors), userColors);
|
|
209
|
+
const flatColors = flattenThemeObject(mergedColors as Record<string, ColorScale>);
|
|
177
210
|
|
|
178
|
-
// Extract colors -> HSL triplet values (matching heroui plugin)
|
|
179
211
|
for (const [colorKey, colorValue] of Object.entries(flatColors)) {
|
|
180
212
|
if (!colorValue) continue;
|
|
181
213
|
|