uni-theme-select 1.0.1 → 1.0.2
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/index.js +119 -31
- package/dist/index.mjs +119 -31
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -67,9 +67,22 @@ var themes = [
|
|
|
67
67
|
{
|
|
68
68
|
name: "custom",
|
|
69
69
|
properties: {
|
|
70
|
+
"primary-button-text-color": "",
|
|
71
|
+
"primary-button-color": "",
|
|
72
|
+
"primary-button-border-color": "",
|
|
73
|
+
"primary-button-border-radius": "",
|
|
74
|
+
"secondary-button-text-color": "",
|
|
75
|
+
"secondary-button-color": "",
|
|
76
|
+
"secondary-button-border-color": "",
|
|
77
|
+
"secondary-button-border-radius": "",
|
|
70
78
|
"bg-color": "",
|
|
71
|
-
"
|
|
72
|
-
"primary-color": ""
|
|
79
|
+
"font-family": "",
|
|
80
|
+
"primary-font-color": "",
|
|
81
|
+
"primary-font-size": "",
|
|
82
|
+
"primary-font-weight": "",
|
|
83
|
+
"secondary-font-color": "",
|
|
84
|
+
"secondary-font-weight": "",
|
|
85
|
+
"secondary-font-size": ""
|
|
73
86
|
}
|
|
74
87
|
}
|
|
75
88
|
];
|
|
@@ -77,12 +90,55 @@ var themes = [
|
|
|
77
90
|
// src/coreFunctions.ts
|
|
78
91
|
var import_coloris = require("@melloware/coloris/dist/coloris.css");
|
|
79
92
|
var import_coloris2 = __toESM(require("@melloware/coloris"));
|
|
93
|
+
|
|
94
|
+
// src/store.ts
|
|
95
|
+
var ThemeStore = class {
|
|
96
|
+
constructor() {
|
|
97
|
+
this.currentTheme = "custom";
|
|
98
|
+
this.themeProps = {};
|
|
99
|
+
this.listeners = [];
|
|
100
|
+
}
|
|
101
|
+
setTheme(themeName, themeProps) {
|
|
102
|
+
this.currentTheme = themeName;
|
|
103
|
+
this.themeProps = themeProps;
|
|
104
|
+
this.notify();
|
|
105
|
+
}
|
|
106
|
+
getTheme() {
|
|
107
|
+
return {
|
|
108
|
+
themeName: this.currentTheme,
|
|
109
|
+
properties: this.themeProps
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
subscribe(listener) {
|
|
113
|
+
this.listeners.push(listener);
|
|
114
|
+
return () => {
|
|
115
|
+
this.listeners = this.listeners.filter((l) => l !== listener);
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
notify() {
|
|
119
|
+
this.listeners.forEach((listener) => listener(this.currentTheme, this.themeProps));
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
var themeStore = new ThemeStore();
|
|
123
|
+
|
|
124
|
+
// src/coreFunctions.ts
|
|
80
125
|
var colorFields = [
|
|
81
|
-
{ id: "
|
|
82
|
-
{ id: "
|
|
83
|
-
{ id: "
|
|
84
|
-
{ id: "
|
|
85
|
-
{ id: "
|
|
126
|
+
{ id: "bg-color", label: "Background Color", defaultValue: "#fff", type: "text", class: "radius-50" },
|
|
127
|
+
{ id: "primary-button-color", label: "Primary Button Color", defaultValue: "rgb(174, 174, 174)", type: "text", class: "radius-50" },
|
|
128
|
+
{ id: "primary-button-border-color", label: "Primary Button Border Color", defaultValue: "rgba(0, 0, 0, 0)", type: "text", class: "radius-50" },
|
|
129
|
+
{ id: "primary-button-border-radius", label: "Primary Button Border Radius", defaultValue: "0", type: "text", units: ["px", "%", "em"] },
|
|
130
|
+
{ id: "primary-button-text-color", label: "Primary Button Text Color", defaultValue: "#000", type: "text", class: "radius-50" },
|
|
131
|
+
{ id: "secondary-button-color", label: "Secondary Button Color", defaultValue: "rgb(174, 174, 174)", type: "text", class: "radius-50" },
|
|
132
|
+
{ id: "secondary-button-border-color", label: "Secondary Button Border Color", defaultValue: "rgba(0, 0, 0, 0)", type: "text", class: "radius-50" },
|
|
133
|
+
{ id: "secondary-button-border-radius", label: "Secondary Button Border Radius", defaultValue: "0", type: "text", units: ["px", "%", "em"] },
|
|
134
|
+
{ id: "secondary-button-text-color", label: "Secondary Button Text Color", defaultValue: "#000", type: "text", class: "radius-50" },
|
|
135
|
+
{ id: "font-family", label: "Font Family", defaultValue: "", type: "text" },
|
|
136
|
+
{ id: "primary-font-size", label: "Primary Font Size", defaultValue: "14", type: "text", units: ["px", "%", "em"] },
|
|
137
|
+
{ id: "primary-font-color", label: "Primary Font Color", defaultValue: "#000", type: "text", class: "radius-50" },
|
|
138
|
+
{ id: "primary-font-weight", label: "Primary Font Weight", defaultValue: "600", type: "text" },
|
|
139
|
+
{ id: "secondary-font-size", label: "Secondary Font Size", defaultValue: "14", type: "text", units: ["px", "%", "em"] },
|
|
140
|
+
{ id: "secondary-font-color", label: "Secondary Font Color", defaultValue: "#ccc", type: "text", class: "radius-50" },
|
|
141
|
+
{ id: "secondary-font-weight", label: "Primary Font Weight", defaultValue: "500", type: "text" }
|
|
86
142
|
];
|
|
87
143
|
function injectStyles() {
|
|
88
144
|
if (document.getElementById("uni-theme-style")) return;
|
|
@@ -134,11 +190,11 @@ function injectStyles() {
|
|
|
134
190
|
box-shadow: -4px 0 12px rgba(0,0,0,0.2);
|
|
135
191
|
transition: right 0.3s ease;
|
|
136
192
|
z-index: 9999;
|
|
193
|
+
overflow: auto
|
|
137
194
|
}
|
|
138
195
|
|
|
139
196
|
#uni-theme-root.opened #uni-theme-panel{
|
|
140
197
|
right: 0;
|
|
141
|
-
max-height: 500px;
|
|
142
198
|
}
|
|
143
199
|
|
|
144
200
|
#uni-theme-root.opened #uni-theme-toggle{
|
|
@@ -163,7 +219,7 @@ function injectStyles() {
|
|
|
163
219
|
.clr-field{
|
|
164
220
|
margin: 5px 0
|
|
165
221
|
}
|
|
166
|
-
.uni-
|
|
222
|
+
.uni-input-group {
|
|
167
223
|
display: flex;
|
|
168
224
|
align-items: center;
|
|
169
225
|
justify-content: space-between;
|
|
@@ -171,35 +227,50 @@ function injectStyles() {
|
|
|
171
227
|
gap: 12px;
|
|
172
228
|
}
|
|
173
229
|
|
|
174
|
-
.uni-
|
|
175
|
-
font-size:
|
|
230
|
+
.uni-input-group label {
|
|
231
|
+
font-size: 14px;
|
|
176
232
|
font-weight: 500;
|
|
177
|
-
color:
|
|
233
|
+
color: #333;
|
|
178
234
|
}
|
|
179
235
|
|
|
180
|
-
.uni-
|
|
236
|
+
.uni-input {
|
|
181
237
|
width: 36px;
|
|
182
238
|
height: 36px;
|
|
183
|
-
border-radius: 50%;
|
|
184
239
|
border: 2px solid #ddd;
|
|
185
240
|
cursor: pointer;
|
|
186
241
|
padding: 0;
|
|
187
242
|
}
|
|
243
|
+
.radius-50{
|
|
244
|
+
border-radius:50%
|
|
245
|
+
}
|
|
188
246
|
|
|
189
247
|
`;
|
|
190
248
|
document.head.appendChild(style);
|
|
191
249
|
}
|
|
192
|
-
function setTheme(name,
|
|
193
|
-
|
|
194
|
-
if (
|
|
195
|
-
|
|
196
|
-
|
|
250
|
+
function setTheme(name, customProps = {}) {
|
|
251
|
+
let themeProps = {};
|
|
252
|
+
if (name == "custom" && customProps) {
|
|
253
|
+
themeProps = customProps;
|
|
254
|
+
} else {
|
|
255
|
+
const theme = themes.find((t) => t.name === name);
|
|
256
|
+
if (!theme) {
|
|
257
|
+
console.warn(`Theme "${name}" not found`);
|
|
258
|
+
return;
|
|
259
|
+
}
|
|
260
|
+
themeProps = theme.properties;
|
|
197
261
|
}
|
|
198
262
|
const root = document.documentElement;
|
|
199
|
-
Object.entries(
|
|
263
|
+
Object.entries(themeProps).forEach(([key, value]) => {
|
|
200
264
|
root.style.setProperty(`--${key}`, value);
|
|
201
265
|
});
|
|
202
|
-
localStorage.setItem(
|
|
266
|
+
localStorage.setItem(
|
|
267
|
+
"uts-theme",
|
|
268
|
+
JSON.stringify({
|
|
269
|
+
name,
|
|
270
|
+
properties: themeProps
|
|
271
|
+
})
|
|
272
|
+
);
|
|
273
|
+
themeStore.setTheme(name, themeProps);
|
|
203
274
|
}
|
|
204
275
|
function constructPanel(container) {
|
|
205
276
|
const panel = document.createElement("div");
|
|
@@ -209,16 +280,27 @@ function constructPanel(container) {
|
|
|
209
280
|
panel.appendChild(title);
|
|
210
281
|
colorFields.forEach((field) => {
|
|
211
282
|
const group = document.createElement("div");
|
|
212
|
-
group.className = "uni-
|
|
283
|
+
group.className = "uni-input-group";
|
|
213
284
|
const label = document.createElement("label");
|
|
214
285
|
label.textContent = field.label;
|
|
215
286
|
const input = document.createElement("input");
|
|
216
|
-
input.type =
|
|
217
|
-
input.
|
|
287
|
+
input.type = field.type;
|
|
288
|
+
input.name = field.id;
|
|
289
|
+
input.className = `uni-input ${field.class}`;
|
|
218
290
|
input.id = `uni-theme-${field.id}`;
|
|
219
|
-
input.value =
|
|
291
|
+
input.value = field.defaultValue;
|
|
220
292
|
group.appendChild(label);
|
|
221
293
|
group.appendChild(input);
|
|
294
|
+
if (field.units && field.units.length > 0) {
|
|
295
|
+
const inputUnits = document.createElement("select");
|
|
296
|
+
field.units.forEach((unit) => {
|
|
297
|
+
const option = document.createElement("option");
|
|
298
|
+
option.value = unit;
|
|
299
|
+
option.textContent = unit;
|
|
300
|
+
inputUnits.appendChild(option);
|
|
301
|
+
});
|
|
302
|
+
group.appendChild(inputUnits);
|
|
303
|
+
}
|
|
222
304
|
panel.appendChild(group);
|
|
223
305
|
});
|
|
224
306
|
container.appendChild(panel);
|
|
@@ -240,16 +322,18 @@ function initThemeElements() {
|
|
|
240
322
|
const themeToggler = document.getElementById("uni-theme-toggle");
|
|
241
323
|
const themePanel = document.getElementById("uni-theme-panel");
|
|
242
324
|
import_coloris2.default.init();
|
|
243
|
-
document.querySelectorAll(".uni-
|
|
244
|
-
console.log(input.className);
|
|
325
|
+
document.querySelectorAll(".uni-input").forEach((input) => {
|
|
245
326
|
(0, import_coloris2.default)({
|
|
246
|
-
el:
|
|
327
|
+
el: `.uni-input.radius-50`,
|
|
247
328
|
alpha: true,
|
|
248
329
|
format: "hex"
|
|
249
330
|
});
|
|
250
331
|
input.addEventListener("input", (e) => {
|
|
251
332
|
const target = e.target;
|
|
252
|
-
|
|
333
|
+
const currentTheme = themeStore.getTheme();
|
|
334
|
+
currentTheme.properties[target.name] = target.value;
|
|
335
|
+
console.log(currentTheme);
|
|
336
|
+
setTheme(currentTheme.themeName, currentTheme.properties);
|
|
253
337
|
});
|
|
254
338
|
});
|
|
255
339
|
return { themeToggler, themePanel };
|
|
@@ -261,8 +345,12 @@ function getAvailableThemes() {
|
|
|
261
345
|
}
|
|
262
346
|
function loadSavedTheme() {
|
|
263
347
|
const saved = localStorage.getItem("uts-theme");
|
|
264
|
-
if (saved)
|
|
265
|
-
|
|
348
|
+
if (!saved) return;
|
|
349
|
+
const parsed = JSON.parse(saved);
|
|
350
|
+
if (parsed.name == "custom") {
|
|
351
|
+
setTheme(parsed.name, parsed.properties);
|
|
352
|
+
} else {
|
|
353
|
+
setTheme(parsed.name);
|
|
266
354
|
}
|
|
267
355
|
}
|
|
268
356
|
function mountToggleTheme(options = {}) {
|
package/dist/index.mjs
CHANGED
|
@@ -27,9 +27,22 @@ var themes = [
|
|
|
27
27
|
{
|
|
28
28
|
name: "custom",
|
|
29
29
|
properties: {
|
|
30
|
+
"primary-button-text-color": "",
|
|
31
|
+
"primary-button-color": "",
|
|
32
|
+
"primary-button-border-color": "",
|
|
33
|
+
"primary-button-border-radius": "",
|
|
34
|
+
"secondary-button-text-color": "",
|
|
35
|
+
"secondary-button-color": "",
|
|
36
|
+
"secondary-button-border-color": "",
|
|
37
|
+
"secondary-button-border-radius": "",
|
|
30
38
|
"bg-color": "",
|
|
31
|
-
"
|
|
32
|
-
"primary-color": ""
|
|
39
|
+
"font-family": "",
|
|
40
|
+
"primary-font-color": "",
|
|
41
|
+
"primary-font-size": "",
|
|
42
|
+
"primary-font-weight": "",
|
|
43
|
+
"secondary-font-color": "",
|
|
44
|
+
"secondary-font-weight": "",
|
|
45
|
+
"secondary-font-size": ""
|
|
33
46
|
}
|
|
34
47
|
}
|
|
35
48
|
];
|
|
@@ -37,12 +50,55 @@ var themes = [
|
|
|
37
50
|
// src/coreFunctions.ts
|
|
38
51
|
import "@melloware/coloris/dist/coloris.css";
|
|
39
52
|
import Coloris from "@melloware/coloris";
|
|
53
|
+
|
|
54
|
+
// src/store.ts
|
|
55
|
+
var ThemeStore = class {
|
|
56
|
+
constructor() {
|
|
57
|
+
this.currentTheme = "custom";
|
|
58
|
+
this.themeProps = {};
|
|
59
|
+
this.listeners = [];
|
|
60
|
+
}
|
|
61
|
+
setTheme(themeName, themeProps) {
|
|
62
|
+
this.currentTheme = themeName;
|
|
63
|
+
this.themeProps = themeProps;
|
|
64
|
+
this.notify();
|
|
65
|
+
}
|
|
66
|
+
getTheme() {
|
|
67
|
+
return {
|
|
68
|
+
themeName: this.currentTheme,
|
|
69
|
+
properties: this.themeProps
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
subscribe(listener) {
|
|
73
|
+
this.listeners.push(listener);
|
|
74
|
+
return () => {
|
|
75
|
+
this.listeners = this.listeners.filter((l) => l !== listener);
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
notify() {
|
|
79
|
+
this.listeners.forEach((listener) => listener(this.currentTheme, this.themeProps));
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
var themeStore = new ThemeStore();
|
|
83
|
+
|
|
84
|
+
// src/coreFunctions.ts
|
|
40
85
|
var colorFields = [
|
|
41
|
-
{ id: "
|
|
42
|
-
{ id: "
|
|
43
|
-
{ id: "
|
|
44
|
-
{ id: "
|
|
45
|
-
{ id: "
|
|
86
|
+
{ id: "bg-color", label: "Background Color", defaultValue: "#fff", type: "text", class: "radius-50" },
|
|
87
|
+
{ id: "primary-button-color", label: "Primary Button Color", defaultValue: "rgb(174, 174, 174)", type: "text", class: "radius-50" },
|
|
88
|
+
{ id: "primary-button-border-color", label: "Primary Button Border Color", defaultValue: "rgba(0, 0, 0, 0)", type: "text", class: "radius-50" },
|
|
89
|
+
{ id: "primary-button-border-radius", label: "Primary Button Border Radius", defaultValue: "0", type: "text", units: ["px", "%", "em"] },
|
|
90
|
+
{ id: "primary-button-text-color", label: "Primary Button Text Color", defaultValue: "#000", type: "text", class: "radius-50" },
|
|
91
|
+
{ id: "secondary-button-color", label: "Secondary Button Color", defaultValue: "rgb(174, 174, 174)", type: "text", class: "radius-50" },
|
|
92
|
+
{ id: "secondary-button-border-color", label: "Secondary Button Border Color", defaultValue: "rgba(0, 0, 0, 0)", type: "text", class: "radius-50" },
|
|
93
|
+
{ id: "secondary-button-border-radius", label: "Secondary Button Border Radius", defaultValue: "0", type: "text", units: ["px", "%", "em"] },
|
|
94
|
+
{ id: "secondary-button-text-color", label: "Secondary Button Text Color", defaultValue: "#000", type: "text", class: "radius-50" },
|
|
95
|
+
{ id: "font-family", label: "Font Family", defaultValue: "", type: "text" },
|
|
96
|
+
{ id: "primary-font-size", label: "Primary Font Size", defaultValue: "14", type: "text", units: ["px", "%", "em"] },
|
|
97
|
+
{ id: "primary-font-color", label: "Primary Font Color", defaultValue: "#000", type: "text", class: "radius-50" },
|
|
98
|
+
{ id: "primary-font-weight", label: "Primary Font Weight", defaultValue: "600", type: "text" },
|
|
99
|
+
{ id: "secondary-font-size", label: "Secondary Font Size", defaultValue: "14", type: "text", units: ["px", "%", "em"] },
|
|
100
|
+
{ id: "secondary-font-color", label: "Secondary Font Color", defaultValue: "#ccc", type: "text", class: "radius-50" },
|
|
101
|
+
{ id: "secondary-font-weight", label: "Primary Font Weight", defaultValue: "500", type: "text" }
|
|
46
102
|
];
|
|
47
103
|
function injectStyles() {
|
|
48
104
|
if (document.getElementById("uni-theme-style")) return;
|
|
@@ -94,11 +150,11 @@ function injectStyles() {
|
|
|
94
150
|
box-shadow: -4px 0 12px rgba(0,0,0,0.2);
|
|
95
151
|
transition: right 0.3s ease;
|
|
96
152
|
z-index: 9999;
|
|
153
|
+
overflow: auto
|
|
97
154
|
}
|
|
98
155
|
|
|
99
156
|
#uni-theme-root.opened #uni-theme-panel{
|
|
100
157
|
right: 0;
|
|
101
|
-
max-height: 500px;
|
|
102
158
|
}
|
|
103
159
|
|
|
104
160
|
#uni-theme-root.opened #uni-theme-toggle{
|
|
@@ -123,7 +179,7 @@ function injectStyles() {
|
|
|
123
179
|
.clr-field{
|
|
124
180
|
margin: 5px 0
|
|
125
181
|
}
|
|
126
|
-
.uni-
|
|
182
|
+
.uni-input-group {
|
|
127
183
|
display: flex;
|
|
128
184
|
align-items: center;
|
|
129
185
|
justify-content: space-between;
|
|
@@ -131,35 +187,50 @@ function injectStyles() {
|
|
|
131
187
|
gap: 12px;
|
|
132
188
|
}
|
|
133
189
|
|
|
134
|
-
.uni-
|
|
135
|
-
font-size:
|
|
190
|
+
.uni-input-group label {
|
|
191
|
+
font-size: 14px;
|
|
136
192
|
font-weight: 500;
|
|
137
|
-
color:
|
|
193
|
+
color: #333;
|
|
138
194
|
}
|
|
139
195
|
|
|
140
|
-
.uni-
|
|
196
|
+
.uni-input {
|
|
141
197
|
width: 36px;
|
|
142
198
|
height: 36px;
|
|
143
|
-
border-radius: 50%;
|
|
144
199
|
border: 2px solid #ddd;
|
|
145
200
|
cursor: pointer;
|
|
146
201
|
padding: 0;
|
|
147
202
|
}
|
|
203
|
+
.radius-50{
|
|
204
|
+
border-radius:50%
|
|
205
|
+
}
|
|
148
206
|
|
|
149
207
|
`;
|
|
150
208
|
document.head.appendChild(style);
|
|
151
209
|
}
|
|
152
|
-
function setTheme(name,
|
|
153
|
-
|
|
154
|
-
if (
|
|
155
|
-
|
|
156
|
-
|
|
210
|
+
function setTheme(name, customProps = {}) {
|
|
211
|
+
let themeProps = {};
|
|
212
|
+
if (name == "custom" && customProps) {
|
|
213
|
+
themeProps = customProps;
|
|
214
|
+
} else {
|
|
215
|
+
const theme = themes.find((t) => t.name === name);
|
|
216
|
+
if (!theme) {
|
|
217
|
+
console.warn(`Theme "${name}" not found`);
|
|
218
|
+
return;
|
|
219
|
+
}
|
|
220
|
+
themeProps = theme.properties;
|
|
157
221
|
}
|
|
158
222
|
const root = document.documentElement;
|
|
159
|
-
Object.entries(
|
|
223
|
+
Object.entries(themeProps).forEach(([key, value]) => {
|
|
160
224
|
root.style.setProperty(`--${key}`, value);
|
|
161
225
|
});
|
|
162
|
-
localStorage.setItem(
|
|
226
|
+
localStorage.setItem(
|
|
227
|
+
"uts-theme",
|
|
228
|
+
JSON.stringify({
|
|
229
|
+
name,
|
|
230
|
+
properties: themeProps
|
|
231
|
+
})
|
|
232
|
+
);
|
|
233
|
+
themeStore.setTheme(name, themeProps);
|
|
163
234
|
}
|
|
164
235
|
function constructPanel(container) {
|
|
165
236
|
const panel = document.createElement("div");
|
|
@@ -169,16 +240,27 @@ function constructPanel(container) {
|
|
|
169
240
|
panel.appendChild(title);
|
|
170
241
|
colorFields.forEach((field) => {
|
|
171
242
|
const group = document.createElement("div");
|
|
172
|
-
group.className = "uni-
|
|
243
|
+
group.className = "uni-input-group";
|
|
173
244
|
const label = document.createElement("label");
|
|
174
245
|
label.textContent = field.label;
|
|
175
246
|
const input = document.createElement("input");
|
|
176
|
-
input.type =
|
|
177
|
-
input.
|
|
247
|
+
input.type = field.type;
|
|
248
|
+
input.name = field.id;
|
|
249
|
+
input.className = `uni-input ${field.class}`;
|
|
178
250
|
input.id = `uni-theme-${field.id}`;
|
|
179
|
-
input.value =
|
|
251
|
+
input.value = field.defaultValue;
|
|
180
252
|
group.appendChild(label);
|
|
181
253
|
group.appendChild(input);
|
|
254
|
+
if (field.units && field.units.length > 0) {
|
|
255
|
+
const inputUnits = document.createElement("select");
|
|
256
|
+
field.units.forEach((unit) => {
|
|
257
|
+
const option = document.createElement("option");
|
|
258
|
+
option.value = unit;
|
|
259
|
+
option.textContent = unit;
|
|
260
|
+
inputUnits.appendChild(option);
|
|
261
|
+
});
|
|
262
|
+
group.appendChild(inputUnits);
|
|
263
|
+
}
|
|
182
264
|
panel.appendChild(group);
|
|
183
265
|
});
|
|
184
266
|
container.appendChild(panel);
|
|
@@ -200,16 +282,18 @@ function initThemeElements() {
|
|
|
200
282
|
const themeToggler = document.getElementById("uni-theme-toggle");
|
|
201
283
|
const themePanel = document.getElementById("uni-theme-panel");
|
|
202
284
|
Coloris.init();
|
|
203
|
-
document.querySelectorAll(".uni-
|
|
204
|
-
console.log(input.className);
|
|
285
|
+
document.querySelectorAll(".uni-input").forEach((input) => {
|
|
205
286
|
Coloris({
|
|
206
|
-
el:
|
|
287
|
+
el: `.uni-input.radius-50`,
|
|
207
288
|
alpha: true,
|
|
208
289
|
format: "hex"
|
|
209
290
|
});
|
|
210
291
|
input.addEventListener("input", (e) => {
|
|
211
292
|
const target = e.target;
|
|
212
|
-
|
|
293
|
+
const currentTheme = themeStore.getTheme();
|
|
294
|
+
currentTheme.properties[target.name] = target.value;
|
|
295
|
+
console.log(currentTheme);
|
|
296
|
+
setTheme(currentTheme.themeName, currentTheme.properties);
|
|
213
297
|
});
|
|
214
298
|
});
|
|
215
299
|
return { themeToggler, themePanel };
|
|
@@ -221,8 +305,12 @@ function getAvailableThemes() {
|
|
|
221
305
|
}
|
|
222
306
|
function loadSavedTheme() {
|
|
223
307
|
const saved = localStorage.getItem("uts-theme");
|
|
224
|
-
if (saved)
|
|
225
|
-
|
|
308
|
+
if (!saved) return;
|
|
309
|
+
const parsed = JSON.parse(saved);
|
|
310
|
+
if (parsed.name == "custom") {
|
|
311
|
+
setTheme(parsed.name, parsed.properties);
|
|
312
|
+
} else {
|
|
313
|
+
setTheme(parsed.name);
|
|
226
314
|
}
|
|
227
315
|
}
|
|
228
316
|
function mountToggleTheme(options = {}) {
|