@pathscale/ui 1.1.14 → 1.1.16
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.
|
@@ -107,59 +107,263 @@ const hueDistance = (a, b)=>{
|
|
|
107
107
|
const isNearColor = (color, item)=>{
|
|
108
108
|
const hueDelta = hueDistance(color.hsl.h, item.hue);
|
|
109
109
|
const saturationDelta = Math.abs(color.hsl.s - item.saturation);
|
|
110
|
-
|
|
111
|
-
return hueDelta <= 2 && saturationDelta <= 2 && lightnessDelta <= 2;
|
|
110
|
+
return hueDelta <= 5 && saturationDelta <= 15;
|
|
112
111
|
};
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
112
|
+
const LAYOUT = [
|
|
113
|
+
{
|
|
114
|
+
id: "outer-1",
|
|
115
|
+
offsetX: 47.631,
|
|
116
|
+
offsetY: -27.5
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
id: "outer-2",
|
|
120
|
+
offsetX: 27.5,
|
|
121
|
+
offsetY: -47.631
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
id: "outer-3",
|
|
125
|
+
offsetX: 0,
|
|
126
|
+
offsetY: -55
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: "outer-4",
|
|
130
|
+
offsetX: -27.5,
|
|
131
|
+
offsetY: -47.631
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
id: "outer-5",
|
|
135
|
+
offsetX: -47.631,
|
|
136
|
+
offsetY: -27.5
|
|
137
|
+
},
|
|
138
|
+
{
|
|
139
|
+
id: "outer-6",
|
|
140
|
+
offsetX: -55,
|
|
141
|
+
offsetY: 0
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
id: "outer-7",
|
|
145
|
+
offsetX: -47.631,
|
|
146
|
+
offsetY: 27.5
|
|
147
|
+
},
|
|
148
|
+
{
|
|
149
|
+
id: "outer-8",
|
|
150
|
+
offsetX: -27.5,
|
|
151
|
+
offsetY: 47.631
|
|
152
|
+
},
|
|
153
|
+
{
|
|
154
|
+
id: "outer-9",
|
|
155
|
+
offsetX: 0,
|
|
156
|
+
offsetY: 55
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
id: "outer-10",
|
|
160
|
+
offsetX: 27.5,
|
|
161
|
+
offsetY: 47.631
|
|
162
|
+
},
|
|
163
|
+
{
|
|
164
|
+
id: "outer-11",
|
|
165
|
+
offsetX: 47.631,
|
|
166
|
+
offsetY: 27.5
|
|
167
|
+
},
|
|
168
|
+
{
|
|
169
|
+
id: "outer-12",
|
|
170
|
+
offsetX: 55,
|
|
171
|
+
offsetY: 0
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
id: "middle-1",
|
|
175
|
+
offsetX: 34.641,
|
|
176
|
+
offsetY: -20
|
|
177
|
+
},
|
|
178
|
+
{
|
|
179
|
+
id: "middle-2",
|
|
180
|
+
offsetX: 20,
|
|
181
|
+
offsetY: -34.641
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
id: "middle-3",
|
|
185
|
+
offsetX: 0,
|
|
186
|
+
offsetY: -40
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
id: "middle-4",
|
|
190
|
+
offsetX: -20,
|
|
191
|
+
offsetY: -34.641
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
id: "middle-5",
|
|
195
|
+
offsetX: -34.641,
|
|
196
|
+
offsetY: -20
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
id: "middle-6",
|
|
200
|
+
offsetX: -40,
|
|
201
|
+
offsetY: 0
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
id: "middle-7",
|
|
205
|
+
offsetX: -34.641,
|
|
206
|
+
offsetY: 20
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
id: "middle-8",
|
|
210
|
+
offsetX: -20,
|
|
211
|
+
offsetY: 34.641
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
id: "middle-9",
|
|
215
|
+
offsetX: 0,
|
|
216
|
+
offsetY: 40
|
|
217
|
+
},
|
|
218
|
+
{
|
|
219
|
+
id: "middle-10",
|
|
220
|
+
offsetX: 20,
|
|
221
|
+
offsetY: 34.641
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
id: "middle-11",
|
|
225
|
+
offsetX: 34.641,
|
|
226
|
+
offsetY: 20
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
id: "middle-12",
|
|
230
|
+
offsetX: 40,
|
|
231
|
+
offsetY: 0
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
id: "inner-1",
|
|
235
|
+
offsetX: 10,
|
|
236
|
+
offsetY: -17.3205
|
|
237
|
+
},
|
|
238
|
+
{
|
|
239
|
+
id: "inner-2",
|
|
240
|
+
offsetX: -10,
|
|
241
|
+
offsetY: -17.3205
|
|
242
|
+
},
|
|
243
|
+
{
|
|
244
|
+
id: "inner-3",
|
|
245
|
+
offsetX: -20,
|
|
246
|
+
offsetY: 0
|
|
247
|
+
},
|
|
248
|
+
{
|
|
249
|
+
id: "inner-4",
|
|
250
|
+
offsetX: -10,
|
|
251
|
+
offsetY: 17.3205
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: "inner-5",
|
|
255
|
+
offsetX: 10,
|
|
256
|
+
offsetY: 17.3205
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
id: "inner-6",
|
|
260
|
+
offsetX: 20,
|
|
261
|
+
offsetY: 0
|
|
262
|
+
},
|
|
263
|
+
{
|
|
264
|
+
id: "center",
|
|
265
|
+
offsetX: 0,
|
|
266
|
+
offsetY: 0,
|
|
145
267
|
isCenter: true
|
|
146
|
-
}
|
|
268
|
+
}
|
|
147
269
|
];
|
|
148
|
-
const
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
270
|
+
const LIGHT_RGBS = [
|
|
271
|
+
"rgb(249,168,37)",
|
|
272
|
+
"rgb(239,108,0)",
|
|
273
|
+
"rgb(198,40,40)",
|
|
274
|
+
"rgb(173,20,87)",
|
|
275
|
+
"rgb(106,27,154)",
|
|
276
|
+
"rgb(69,39,160)",
|
|
277
|
+
"rgb(40,53,147)",
|
|
278
|
+
"rgb(21,101,192)",
|
|
279
|
+
"rgb(0,131,143)",
|
|
280
|
+
"rgb(0,105,92)",
|
|
281
|
+
"rgb(46,125,50)",
|
|
282
|
+
"rgb(85,139,47)",
|
|
283
|
+
"rgb(255,235,59)",
|
|
284
|
+
"rgb(255,152,0)",
|
|
285
|
+
"rgb(244,67,54)",
|
|
286
|
+
"rgb(233,30,99)",
|
|
287
|
+
"rgb(156,39,176)",
|
|
288
|
+
"rgb(103,58,183)",
|
|
289
|
+
"rgb(63,81,181)",
|
|
290
|
+
"rgb(33,150,243)",
|
|
291
|
+
"rgb(0,188,212)",
|
|
292
|
+
"rgb(0,150,136)",
|
|
293
|
+
"rgb(76,175,80)",
|
|
294
|
+
"rgb(139,195,74)",
|
|
295
|
+
"rgb(239,154,154)",
|
|
296
|
+
"rgb(206,147,216)",
|
|
297
|
+
"rgb(144,202,249)",
|
|
298
|
+
"rgb(128,222,234)",
|
|
299
|
+
"rgb(165,214,167)",
|
|
300
|
+
"rgb(255,224,130)",
|
|
301
|
+
"rgb(255,255,255)"
|
|
302
|
+
];
|
|
303
|
+
const DARK_RGBS = [
|
|
304
|
+
"rgb(255,238,88)",
|
|
305
|
+
"rgb(255,167,38)",
|
|
306
|
+
"rgb(239,83,80)",
|
|
307
|
+
"rgb(236,64,122)",
|
|
308
|
+
"rgb(171,71,188)",
|
|
309
|
+
"rgb(126,87,194)",
|
|
310
|
+
"rgb(92,107,192)",
|
|
311
|
+
"rgb(66,165,245)",
|
|
312
|
+
"rgb(38,198,218)",
|
|
313
|
+
"rgb(38,166,154)",
|
|
314
|
+
"rgb(102,187,106)",
|
|
315
|
+
"rgb(156,204,101)",
|
|
316
|
+
"rgb(255,245,157)",
|
|
317
|
+
"rgb(255,204,128)",
|
|
318
|
+
"rgb(239,154,154)",
|
|
319
|
+
"rgb(244,143,177)",
|
|
320
|
+
"rgb(206,147,216)",
|
|
321
|
+
"rgb(179,157,219)",
|
|
322
|
+
"rgb(159,168,218)",
|
|
323
|
+
"rgb(144,202,249)",
|
|
324
|
+
"rgb(128,222,234)",
|
|
325
|
+
"rgb(128,203,196)",
|
|
326
|
+
"rgb(165,214,167)",
|
|
327
|
+
"rgb(197,225,165)",
|
|
328
|
+
"rgb(255,205,210)",
|
|
329
|
+
"rgb(225,190,231)",
|
|
330
|
+
"rgb(187,222,251)",
|
|
331
|
+
"rgb(178,235,242)",
|
|
332
|
+
"rgb(200,230,201)",
|
|
333
|
+
"rgb(255,236,179)",
|
|
334
|
+
"rgb(255,255,255)"
|
|
335
|
+
];
|
|
336
|
+
const LIGHT_RAINBOW = `conic-gradient(
|
|
337
|
+
from 0deg,
|
|
338
|
+
rgb(244,67,54) 0deg,
|
|
339
|
+
rgb(255,152,0) 30deg,
|
|
340
|
+
rgb(255,235,59) 60deg,
|
|
341
|
+
rgb(76,175,80) 120deg,
|
|
342
|
+
rgb(0,188,212) 180deg,
|
|
343
|
+
rgb(63,81,181) 240deg,
|
|
344
|
+
rgb(156,39,176) 300deg,
|
|
345
|
+
rgb(244,67,54) 360deg
|
|
346
|
+
)`;
|
|
347
|
+
const DARK_RAINBOW = `conic-gradient(
|
|
153
348
|
from 0deg,
|
|
154
|
-
rgb(
|
|
155
|
-
rgb(
|
|
156
|
-
rgb(
|
|
157
|
-
rgb(
|
|
158
|
-
rgb(
|
|
159
|
-
rgb(
|
|
160
|
-
rgb(
|
|
161
|
-
rgb(
|
|
349
|
+
rgb(239,154,154) 0deg,
|
|
350
|
+
rgb(255,204,128) 30deg,
|
|
351
|
+
rgb(255,245,157) 60deg,
|
|
352
|
+
rgb(165,214,167) 120deg,
|
|
353
|
+
rgb(128,222,234) 180deg,
|
|
354
|
+
rgb(159,168,218) 240deg,
|
|
355
|
+
rgb(206,147,216) 300deg,
|
|
356
|
+
rgb(239,154,154) 360deg
|
|
162
357
|
)`;
|
|
358
|
+
function buildColors(rgbs) {
|
|
359
|
+
return LAYOUT.map((layout, i)=>createColorItem(layout.id, rgbs[i], layout.offsetX, layout.offsetY, layout.isCenter ? {
|
|
360
|
+
isCenter: true
|
|
361
|
+
} : void 0));
|
|
362
|
+
}
|
|
363
|
+
const CENTER_INDEX = LAYOUT.findIndex((l)=>l.isCenter);
|
|
364
|
+
const MAX_RADIUS = Math.max(...LAYOUT.map((l)=>Math.sqrt(l.offsetX ** 2 + l.offsetY ** 2)));
|
|
365
|
+
const MAX_WAVE_DISTANCE = 2 * MAX_RADIUS;
|
|
366
|
+
const MAX_WAVE_DELAY = 0.12;
|
|
163
367
|
const ColorWheelFlower = (props)=>{
|
|
164
368
|
const context = (0, __WEBPACK_EXTERNAL_MODULE__colorpickerContext_js_45c33b20__.useColorPickerContext)();
|
|
165
369
|
const [selectedIndex, setSelectedIndex] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(null);
|
|
@@ -171,6 +375,22 @@ const ColorWheelFlower = (props)=>{
|
|
|
171
375
|
active: false
|
|
172
376
|
});
|
|
173
377
|
const [pulseState, setPulseState] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(null);
|
|
378
|
+
const [currentTheme, setCurrentTheme] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)("undefined" != typeof document ? document.documentElement.getAttribute("data-theme") ?? "light" : "light");
|
|
379
|
+
if ("undefined" != typeof window) {
|
|
380
|
+
const observer = new MutationObserver(()=>{
|
|
381
|
+
const t = document.documentElement.getAttribute("data-theme");
|
|
382
|
+
setCurrentTheme("dark" === t ? "dark" : "light");
|
|
383
|
+
});
|
|
384
|
+
observer.observe(document.documentElement, {
|
|
385
|
+
attributes: true,
|
|
386
|
+
attributeFilter: [
|
|
387
|
+
"data-theme"
|
|
388
|
+
]
|
|
389
|
+
});
|
|
390
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.onCleanup)(()=>observer.disconnect());
|
|
391
|
+
}
|
|
392
|
+
const colors = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>buildColors("dark" === currentTheme() ? DARK_RGBS : LIGHT_RGBS));
|
|
393
|
+
const rainbowGradient = ()=>"dark" === currentTheme() ? DARK_RAINBOW : LIGHT_RAINBOW;
|
|
174
394
|
const reduceMotion = (0, __WEBPACK_EXTERNAL_MODULE__motion_index_js_58495715__.prefersReducedMotion)();
|
|
175
395
|
const ringTransition = reduceMotion ? {
|
|
176
396
|
duration: 0
|
|
@@ -188,16 +408,17 @@ const ColorWheelFlower = (props)=>{
|
|
|
188
408
|
let outerRingControl = null;
|
|
189
409
|
const closestIndex = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
190
410
|
const current = context.color();
|
|
411
|
+
const items = colors();
|
|
191
412
|
if (current.hsl.s <= 6 && current.hsl.l >= 95 && CENTER_INDEX >= 0) return CENTER_INDEX;
|
|
192
413
|
let closest = 0;
|
|
193
414
|
let bestScore = Number.POSITIVE_INFINITY;
|
|
194
|
-
for(let index = 0; index <
|
|
195
|
-
const item =
|
|
415
|
+
for(let index = 0; index < items.length; index += 1){
|
|
416
|
+
const item = items[index];
|
|
196
417
|
if (item.isCenter) continue;
|
|
197
418
|
const hueDelta = hueDistance(current.hsl.h, item.hue);
|
|
198
419
|
const saturationDelta = Math.abs(current.hsl.s - item.saturation);
|
|
199
420
|
const lightnessDelta = Math.abs(current.hsl.l - item.lightness);
|
|
200
|
-
const score =
|
|
421
|
+
const score = 2.0 * hueDelta + +saturationDelta + 0.1 * lightnessDelta;
|
|
201
422
|
if (score < bestScore) {
|
|
202
423
|
bestScore = score;
|
|
203
424
|
closest = index;
|
|
@@ -219,11 +440,12 @@ const ColorWheelFlower = (props)=>{
|
|
|
219
440
|
};
|
|
220
441
|
const handlePickerChange = (selectedHex)=>{
|
|
221
442
|
if (context.disabled()) return;
|
|
222
|
-
const
|
|
443
|
+
const items = colors();
|
|
444
|
+
const index = items.findIndex((item)=>item.hex === selectedHex.toUpperCase());
|
|
223
445
|
if (index < 0) return;
|
|
224
446
|
triggerPulse(index);
|
|
225
447
|
const selected = selectedIndex();
|
|
226
|
-
const item =
|
|
448
|
+
const item = items[index];
|
|
227
449
|
if (selected === index && !item.isCenter) {
|
|
228
450
|
setSelectedIndex(null);
|
|
229
451
|
context.onChange((0, __WEBPACK_EXTERNAL_MODULE__ColorUtils_js_8c38ee50__.createColorFromHsl)(0, 0, 100, context.color().hsl.a));
|
|
@@ -237,7 +459,7 @@ const ColorWheelFlower = (props)=>{
|
|
|
237
459
|
const selected = selectedIndex();
|
|
238
460
|
const current = context.color();
|
|
239
461
|
if (null === selected) return;
|
|
240
|
-
const selectedItem =
|
|
462
|
+
const selectedItem = colors()[selected];
|
|
241
463
|
if (!selectedItem) return;
|
|
242
464
|
if (!isNearColor(current, selectedItem)) setSelectedIndex(null);
|
|
243
465
|
});
|
|
@@ -269,8 +491,8 @@ const ColorWheelFlower = (props)=>{
|
|
|
269
491
|
};
|
|
270
492
|
const outerRingBackground = ()=>{
|
|
271
493
|
const selected = selectedIndex();
|
|
272
|
-
if (null === selected) return
|
|
273
|
-
const color =
|
|
494
|
+
if (null === selected) return rainbowGradient();
|
|
495
|
+
const color = colors()[selected];
|
|
274
496
|
return `conic-gradient(${color.rgb}, ${color.rgb})`;
|
|
275
497
|
};
|
|
276
498
|
const outerRingTarget = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>{
|
|
@@ -295,7 +517,7 @@ const ColorWheelFlower = (props)=>{
|
|
|
295
517
|
if (context.disabled()) return "none";
|
|
296
518
|
const index = hoveredIndex() ?? selectedIndex();
|
|
297
519
|
if (null === index) return "0 0 10px rgba(255,255,255,0.08)";
|
|
298
|
-
const color =
|
|
520
|
+
const color = colors()[index].rgb;
|
|
299
521
|
return `0 0 10px rgba(255,255,255,0.16), 0 0 20px ${toRgba(color, 0.35)}`;
|
|
300
522
|
});
|
|
301
523
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
@@ -309,7 +531,7 @@ const ColorWheelFlower = (props)=>{
|
|
|
309
531
|
if (void 0 !== pulseTimeout) clearTimeout(pulseTimeout);
|
|
310
532
|
if (void 0 !== pointerTimeout) clearTimeout(pointerTimeout);
|
|
311
533
|
});
|
|
312
|
-
const pickerValue = ()=>
|
|
534
|
+
const pickerValue = ()=>colors()[visualSelectedIndex()]?.hex;
|
|
313
535
|
return (()=>{
|
|
314
536
|
var _el$ = _tmpl$(), _el$2 = _el$.firstChild, _el$3 = _el$2.firstChild, _el$4 = _el$3.firstChild;
|
|
315
537
|
_el$.addEventListener("mouseleave", handlePointerLeave);
|
|
@@ -331,7 +553,9 @@ const ColorWheelFlower = (props)=>{
|
|
|
331
553
|
"aria-label": "Flower color palette",
|
|
332
554
|
get children () {
|
|
333
555
|
return (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(__WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.For, {
|
|
334
|
-
each
|
|
556
|
+
get each () {
|
|
557
|
+
return colors();
|
|
558
|
+
},
|
|
335
559
|
children: (item, index)=>{
|
|
336
560
|
let motionRef;
|
|
337
561
|
let dotControl = null;
|
|
@@ -346,12 +570,12 @@ const ColorWheelFlower = (props)=>{
|
|
|
346
570
|
y: 0
|
|
347
571
|
};
|
|
348
572
|
const pointerState = pointer();
|
|
349
|
-
const
|
|
573
|
+
const anchorIdx = hoveredIndex();
|
|
350
574
|
let scale = 1;
|
|
351
575
|
let offsetX = 0;
|
|
352
576
|
let offsetY = 0;
|
|
353
|
-
if (null !==
|
|
354
|
-
const anchor =
|
|
577
|
+
if (null !== anchorIdx && pointerState.active) {
|
|
578
|
+
const anchor = colors()[anchorIdx];
|
|
355
579
|
const distance = Math.sqrt((item.offsetX - anchor.offsetX) ** 2 + (item.offsetY - anchor.offsetY) ** 2);
|
|
356
580
|
const waveRadius = 0.9 * MAX_RADIUS;
|
|
357
581
|
const influence = Math.max(0, 1 - distance / waveRadius);
|
|
@@ -397,11 +621,11 @@ const ColorWheelFlower = (props)=>{
|
|
|
397
621
|
if (reduceMotion) return {
|
|
398
622
|
duration: 0
|
|
399
623
|
};
|
|
400
|
-
const
|
|
624
|
+
const anchorIdx = hoveredIndex();
|
|
401
625
|
const pointerState = pointer();
|
|
402
626
|
let delay = 0;
|
|
403
|
-
if (null !==
|
|
404
|
-
const anchor =
|
|
627
|
+
if (null !== anchorIdx && pointerState.active) {
|
|
628
|
+
const anchor = colors()[anchorIdx];
|
|
405
629
|
const distance = Math.sqrt((item.offsetX - anchor.offsetX) ** 2 + (item.offsetY - anchor.offsetY) ** 2);
|
|
406
630
|
delay = Math.min(MAX_WAVE_DELAY, distance / MAX_WAVE_DISTANCE * MAX_WAVE_DELAY);
|
|
407
631
|
}
|
|
@@ -10,6 +10,10 @@ export interface ThemeColorPickerProps extends IComponentBaseProps {
|
|
|
10
10
|
* Callback when color changes
|
|
11
11
|
*/
|
|
12
12
|
onColorChange?: (hue: number | null, saturation: number) => void;
|
|
13
|
+
/**
|
|
14
|
+
* Callback to switch light/dark theme (triggered by grayscale selection)
|
|
15
|
+
*/
|
|
16
|
+
onThemeSwitch?: (theme: "light" | "dark") => void;
|
|
13
17
|
/**
|
|
14
18
|
* ARIA label for the button
|
|
15
19
|
*/
|
|
@@ -16,6 +16,7 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
16
16
|
const [local, others] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.splitProps)(props, [
|
|
17
17
|
"storagePrefix",
|
|
18
18
|
"onColorChange",
|
|
19
|
+
"onThemeSwitch",
|
|
19
20
|
"aria-label",
|
|
20
21
|
"children",
|
|
21
22
|
"class",
|
|
@@ -73,6 +74,8 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
73
74
|
const handleGrayscale = (lightnessOffset)=>{
|
|
74
75
|
store().setHueShift(0, 0, lightnessOffset);
|
|
75
76
|
local.onColorChange?.(null, 0);
|
|
77
|
+
if (lightnessOffset >= 5) local.onThemeSwitch?.("light");
|
|
78
|
+
else if (lightnessOffset <= -10) local.onThemeSwitch?.("dark");
|
|
76
79
|
};
|
|
77
80
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
78
81
|
if (!isOpen()) return;
|
|
@@ -17,58 +17,11 @@ const checkCspAllowsInlineStyles = ()=>{
|
|
|
17
17
|
return cspAllowsInlineStyles;
|
|
18
18
|
};
|
|
19
19
|
const MIN_CHROMA_SCALE = 0.3;
|
|
20
|
-
function hslHueToOklchHue(hslHue) {
|
|
21
|
-
const h = (hslHue % 360 + 360) % 360;
|
|
22
|
-
const controlPoints = [
|
|
23
|
-
[
|
|
24
|
-
0,
|
|
25
|
-
29
|
|
26
|
-
],
|
|
27
|
-
[
|
|
28
|
-
30,
|
|
29
|
-
55
|
|
30
|
-
],
|
|
31
|
-
[
|
|
32
|
-
60,
|
|
33
|
-
100
|
|
34
|
-
],
|
|
35
|
-
[
|
|
36
|
-
120,
|
|
37
|
-
145
|
|
38
|
-
],
|
|
39
|
-
[
|
|
40
|
-
180,
|
|
41
|
-
195
|
|
42
|
-
],
|
|
43
|
-
[
|
|
44
|
-
240,
|
|
45
|
-
265
|
|
46
|
-
],
|
|
47
|
-
[
|
|
48
|
-
300,
|
|
49
|
-
330
|
|
50
|
-
],
|
|
51
|
-
[
|
|
52
|
-
360,
|
|
53
|
-
389
|
|
54
|
-
]
|
|
55
|
-
];
|
|
56
|
-
for(let i = 0; i < controlPoints.length - 1; i++){
|
|
57
|
-
const [h1, o1] = controlPoints[i];
|
|
58
|
-
const [h2, o2] = controlPoints[i + 1];
|
|
59
|
-
if (h >= h1 && h <= h2) {
|
|
60
|
-
const t = (h - h1) / (h2 - h1);
|
|
61
|
-
const oklchHue = o1 + t * (o2 - o1);
|
|
62
|
-
return (oklchHue % 360 + 360) % 360;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return h;
|
|
66
|
-
}
|
|
67
20
|
const PRIMARY_SETTINGS = {
|
|
68
21
|
light: {
|
|
69
22
|
"--color-primary": {
|
|
70
|
-
l:
|
|
71
|
-
c: 0.
|
|
23
|
+
l: 58,
|
|
24
|
+
c: 0.22
|
|
72
25
|
},
|
|
73
26
|
"--color-primary-content": {
|
|
74
27
|
l: 98,
|
|
@@ -77,12 +30,12 @@ const PRIMARY_SETTINGS = {
|
|
|
77
30
|
},
|
|
78
31
|
dark: {
|
|
79
32
|
"--color-primary": {
|
|
80
|
-
l:
|
|
81
|
-
c: 0.
|
|
33
|
+
l: 75,
|
|
34
|
+
c: 0.18
|
|
82
35
|
},
|
|
83
36
|
"--color-primary-content": {
|
|
84
|
-
l:
|
|
85
|
-
c: 0.
|
|
37
|
+
l: 15,
|
|
38
|
+
c: 0.02
|
|
86
39
|
}
|
|
87
40
|
}
|
|
88
41
|
};
|
|
@@ -101,8 +54,8 @@ const HARMONY_SETTINGS = {
|
|
|
101
54
|
c: 0.026
|
|
102
55
|
},
|
|
103
56
|
"--color-accent": {
|
|
104
|
-
l:
|
|
105
|
-
c: 0.
|
|
57
|
+
l: 62,
|
|
58
|
+
c: 0.14
|
|
106
59
|
},
|
|
107
60
|
"--color-accent-content": {
|
|
108
61
|
l: 98,
|
|
@@ -111,19 +64,19 @@ const HARMONY_SETTINGS = {
|
|
|
111
64
|
},
|
|
112
65
|
dark: {
|
|
113
66
|
"--color-secondary": {
|
|
114
|
-
l:
|
|
115
|
-
c: 0.
|
|
67
|
+
l: 72,
|
|
68
|
+
c: 0.16
|
|
116
69
|
},
|
|
117
70
|
"--color-secondary-content": {
|
|
118
|
-
l:
|
|
71
|
+
l: 15,
|
|
119
72
|
c: 0.013
|
|
120
73
|
},
|
|
121
74
|
"--color-accent": {
|
|
122
|
-
l:
|
|
123
|
-
c: 0.
|
|
75
|
+
l: 78,
|
|
76
|
+
c: 0.12
|
|
124
77
|
},
|
|
125
78
|
"--color-accent-content": {
|
|
126
|
-
l:
|
|
79
|
+
l: 15,
|
|
127
80
|
c: 0.014
|
|
128
81
|
}
|
|
129
82
|
}
|
|
@@ -208,16 +161,16 @@ const SEMANTIC_SETTINGS = {
|
|
|
208
161
|
const NF_ACCENT_SETTINGS = {
|
|
209
162
|
light: {
|
|
210
163
|
"--nf-accent": {
|
|
211
|
-
l:
|
|
212
|
-
c: 0.
|
|
164
|
+
l: 58,
|
|
165
|
+
c: 0.22
|
|
213
166
|
},
|
|
214
167
|
"--nf-on-accent": {
|
|
215
168
|
l: 98,
|
|
216
169
|
c: 0.02
|
|
217
170
|
},
|
|
218
171
|
"--color-nf-accent": {
|
|
219
|
-
l:
|
|
220
|
-
c: 0.
|
|
172
|
+
l: 58,
|
|
173
|
+
c: 0.22
|
|
221
174
|
},
|
|
222
175
|
"--color-nf-on-accent": {
|
|
223
176
|
l: 98,
|
|
@@ -226,20 +179,20 @@ const NF_ACCENT_SETTINGS = {
|
|
|
226
179
|
},
|
|
227
180
|
dark: {
|
|
228
181
|
"--nf-accent": {
|
|
229
|
-
l:
|
|
230
|
-
c: 0.
|
|
182
|
+
l: 75,
|
|
183
|
+
c: 0.18
|
|
231
184
|
},
|
|
232
185
|
"--nf-on-accent": {
|
|
233
|
-
l:
|
|
234
|
-
c: 0.
|
|
186
|
+
l: 15,
|
|
187
|
+
c: 0.02
|
|
235
188
|
},
|
|
236
189
|
"--color-nf-accent": {
|
|
237
|
-
l:
|
|
238
|
-
c: 0.
|
|
190
|
+
l: 75,
|
|
191
|
+
c: 0.18
|
|
239
192
|
},
|
|
240
193
|
"--color-nf-on-accent": {
|
|
241
|
-
l:
|
|
242
|
-
c: 0.
|
|
194
|
+
l: 15,
|
|
195
|
+
c: 0.02
|
|
243
196
|
}
|
|
244
197
|
}
|
|
245
198
|
};
|
|
@@ -364,7 +317,7 @@ function getResolvedTheme() {
|
|
|
364
317
|
function applyHueShift(targetHue, saturation = 100, lightnessOffset = 0) {
|
|
365
318
|
if (!checkCspAllowsInlineStyles()) return;
|
|
366
319
|
const root = document.documentElement;
|
|
367
|
-
const oklchHue =
|
|
320
|
+
const oklchHue = (targetHue % 360 + 360) % 360;
|
|
368
321
|
const chromaScale = 0 === saturation ? 0 : MIN_CHROMA_SCALE + saturation / 100 * (1 - MIN_CHROMA_SCALE);
|
|
369
322
|
const resolvedTheme = getResolvedTheme();
|
|
370
323
|
const clampL = (l)=>Math.max(0, Math.min(100, l + lightnessOffset));
|