@pathscale/ui 1.1.2 → 1.1.4
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.
|
@@ -5,11 +5,9 @@ import * as __WEBPACK_EXTERNAL_MODULE_clsx__ from "clsx";
|
|
|
5
5
|
import * as __WEBPACK_EXTERNAL_MODULE__colorpicker_index_js_cf395329__ from "../colorpicker/index.js";
|
|
6
6
|
import * as __WEBPACK_EXTERNAL_MODULE__colorpicker_ColorUtils_js_79ac07b0__ from "../colorpicker/ColorUtils.js";
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE__button_index_js_557db1f7__ from "../button/index.js";
|
|
8
|
-
import * as __WEBPACK_EXTERNAL_MODULE__color_field_index_js_d63b754b__ from "../color-field/index.js";
|
|
9
|
-
import * as __WEBPACK_EXTERNAL_MODULE__color_slider_index_js_89667266__ from "../color-slider/index.js";
|
|
10
8
|
import * as __WEBPACK_EXTERNAL_MODULE__icon_index_js_1f7a158c__ from "../icon/index.js";
|
|
11
9
|
import * as __WEBPACK_EXTERNAL_MODULE__hueShift_js_ca4235e5__ from "./hueShift.js";
|
|
12
|
-
var _tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)('<div class=
|
|
10
|
+
var _tmpl$ = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)('<div class="flex items-center gap-3"><div class="flex justify-center"></div><div class="flex flex-col gap-1.5">'), _tmpl$2 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)('<div class="absolute right-0 z-50 mt-2 rounded-lg bg-base-200/80 p-4 shadow-xl backdrop-blur-sm">'), _tmpl$3 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)("<div>"), _tmpl$4 = /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.template)('<button type=button class="h-6 w-6 rounded-full border border-white/20 transition-transform hover:scale-110">');
|
|
13
11
|
function hueToColorValue(hue, sat) {
|
|
14
12
|
if (null === hue) return (0, __WEBPACK_EXTERNAL_MODULE__colorpicker_ColorUtils_js_79ac07b0__.createColorFromHsl)(0, 0, 100, 1);
|
|
15
13
|
return (0, __WEBPACK_EXTERNAL_MODULE__colorpicker_ColorUtils_js_79ac07b0__.createColorFromHsl)(hue, sat, 50, 1);
|
|
@@ -46,14 +44,35 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
46
44
|
if (s < 10 && l > 90) return void setThemeColor(null, 100);
|
|
47
45
|
setThemeColor(h, s);
|
|
48
46
|
};
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
47
|
+
const GRAYSCALE_SWATCHES = [
|
|
48
|
+
{
|
|
49
|
+
label: "White",
|
|
50
|
+
lightness: 10
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
label: "Light gray",
|
|
54
|
+
lightness: 5
|
|
55
|
+
},
|
|
56
|
+
{
|
|
57
|
+
label: "Gray",
|
|
58
|
+
lightness: 0
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
label: "Dark gray",
|
|
62
|
+
lightness: -5
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
label: "Charcoal",
|
|
66
|
+
lightness: -10
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
label: "Black",
|
|
70
|
+
lightness: -15
|
|
71
|
+
}
|
|
72
|
+
];
|
|
73
|
+
const handleGrayscale = (lightnessOffset)=>{
|
|
74
|
+
store().setHueShift(0, 0, lightnessOffset);
|
|
75
|
+
local.onColorChange?.(0, 0);
|
|
57
76
|
};
|
|
58
77
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
59
78
|
if (!isOpen()) return;
|
|
@@ -134,27 +153,31 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
134
153
|
return contextValue();
|
|
135
154
|
},
|
|
136
155
|
get children () {
|
|
137
|
-
var _el$3 = _tmpl$(), _el$4 = _el$3.firstChild;
|
|
156
|
+
var _el$3 = _tmpl$(), _el$4 = _el$3.firstChild, _el$5 = _el$4.nextSibling;
|
|
138
157
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$4, (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.createComponent)(__WEBPACK_EXTERNAL_MODULE__colorpicker_index_js_cf395329__.ColorWheelFlower, {
|
|
139
158
|
class: "color-wheel-custom"
|
|
140
159
|
}));
|
|
141
|
-
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
160
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.insert)(_el$5, ()=>GRAYSCALE_SWATCHES.map((g, i)=>(()=>{
|
|
161
|
+
var _el$6 = _tmpl$4();
|
|
162
|
+
_el$6.$$click = ()=>handleGrayscale(g.lightness);
|
|
163
|
+
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.effect)((_p$)=>{
|
|
164
|
+
var _v$ = `oklch(${[
|
|
165
|
+
95,
|
|
166
|
+
80,
|
|
167
|
+
60,
|
|
168
|
+
40,
|
|
169
|
+
25,
|
|
170
|
+
5
|
|
171
|
+
][i]}% 0 0)`, _v$2 = g.label;
|
|
172
|
+
_v$ !== _p$.e && (null != (_p$.e = _v$) ? _el$6.style.setProperty("background-color", _v$) : _el$6.style.removeProperty("background-color"));
|
|
173
|
+
_v$2 !== _p$.t && (0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.setAttribute)(_el$6, "aria-label", _p$.t = _v$2);
|
|
174
|
+
return _p$;
|
|
175
|
+
}, {
|
|
176
|
+
e: void 0,
|
|
177
|
+
t: void 0
|
|
178
|
+
});
|
|
179
|
+
return _el$6;
|
|
180
|
+
})()));
|
|
158
181
|
return _el$3;
|
|
159
182
|
}
|
|
160
183
|
}));
|
|
@@ -167,6 +190,7 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
167
190
|
};
|
|
168
191
|
const ThemeColorPicker = ThemeColorPicker_ThemeColorPicker;
|
|
169
192
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_web_35d951b7__.delegateEvents)([
|
|
170
|
-
"keydown"
|
|
193
|
+
"keydown",
|
|
194
|
+
"click"
|
|
171
195
|
]);
|
|
172
196
|
export { ThemeColorPicker as default };
|
|
@@ -2,7 +2,8 @@ declare function resetHueShift(): void;
|
|
|
2
2
|
export interface HueShiftStore {
|
|
3
3
|
hueShift: () => number | null;
|
|
4
4
|
hueSaturation: () => number;
|
|
5
|
-
|
|
5
|
+
hueLightness: () => number;
|
|
6
|
+
setHueShift: (hue: number | null, saturation?: number, lightness?: number) => void;
|
|
6
7
|
isAvailable: () => boolean;
|
|
7
8
|
}
|
|
8
9
|
/**
|
|
@@ -361,16 +361,17 @@ function getResolvedTheme() {
|
|
|
361
361
|
if ("light" === dataTheme) return "light";
|
|
362
362
|
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
363
363
|
}
|
|
364
|
-
function applyHueShift(targetHue, saturation = 100) {
|
|
364
|
+
function applyHueShift(targetHue, saturation = 100, lightnessOffset = 0) {
|
|
365
365
|
if (!checkCspAllowsInlineStyles()) return;
|
|
366
366
|
const root = document.documentElement;
|
|
367
367
|
const oklchHue = hslHueToOklchHue(targetHue);
|
|
368
|
-
const chromaScale = MIN_CHROMA_SCALE + saturation / 100 * (1 - MIN_CHROMA_SCALE);
|
|
368
|
+
const chromaScale = 0 === saturation ? 0 : MIN_CHROMA_SCALE + saturation / 100 * (1 - MIN_CHROMA_SCALE);
|
|
369
369
|
const resolvedTheme = getResolvedTheme();
|
|
370
|
+
const clampL = (l)=>Math.max(0, Math.min(100, l + lightnessOffset));
|
|
370
371
|
const primarySettings = PRIMARY_SETTINGS[resolvedTheme];
|
|
371
372
|
for (const [varName, settings] of Object.entries(primarySettings)){
|
|
372
373
|
const scaledChroma = settings.c * chromaScale;
|
|
373
|
-
root.style.setProperty(varName, toOklch(settings.l, scaledChroma, oklchHue));
|
|
374
|
+
root.style.setProperty(varName, toOklch(clampL(settings.l), scaledChroma, oklchHue));
|
|
374
375
|
}
|
|
375
376
|
const harmonySettings = HARMONY_SETTINGS[resolvedTheme];
|
|
376
377
|
for (const [varName, settings] of Object.entries(harmonySettings)){
|
|
@@ -378,7 +379,7 @@ function applyHueShift(targetHue, saturation = 100) {
|
|
|
378
379
|
if (varName.includes("secondary")) hue = oklchHue + HARMONY_OFFSETS.secondary;
|
|
379
380
|
else if (varName.includes("accent")) hue = oklchHue + HARMONY_OFFSETS.accent;
|
|
380
381
|
const scaledChroma = settings.c * chromaScale;
|
|
381
|
-
root.style.setProperty(varName, toOklch(settings.l, scaledChroma, hue));
|
|
382
|
+
root.style.setProperty(varName, toOklch(clampL(settings.l), scaledChroma, hue));
|
|
382
383
|
}
|
|
383
384
|
const semanticSettings = SEMANTIC_SETTINGS[resolvedTheme];
|
|
384
385
|
for (const [varName, settings] of Object.entries(semanticSettings)){
|
|
@@ -388,9 +389,9 @@ function applyHueShift(targetHue, saturation = 100) {
|
|
|
388
389
|
else if (varName.includes("error")) baseHue = SEMANTIC_BASE_HUES.error;
|
|
389
390
|
else if (varName.includes("info")) baseHue = SEMANTIC_BASE_HUES.info;
|
|
390
391
|
const tintedHue = getTintedHue(baseHue, oklchHue);
|
|
391
|
-
const semanticChromaScale = MIN_CHROMA_SCALE + (1 - MIN_CHROMA_SCALE) * Math.sqrt(saturation / 100);
|
|
392
|
+
const semanticChromaScale = 0 === saturation ? 0 : MIN_CHROMA_SCALE + (1 - MIN_CHROMA_SCALE) * Math.sqrt(saturation / 100);
|
|
392
393
|
const scaledChroma = settings.c * semanticChromaScale;
|
|
393
|
-
root.style.setProperty(varName, toOklch(settings.l, scaledChroma, tintedHue));
|
|
394
|
+
root.style.setProperty(varName, toOklch(clampL(settings.l), scaledChroma, tintedHue));
|
|
394
395
|
}
|
|
395
396
|
const gradients = GRADIENT_COLORS[resolvedTheme];
|
|
396
397
|
for (const [varName, color] of Object.entries(gradients)){
|
|
@@ -402,13 +403,13 @@ function applyHueShift(targetHue, saturation = 100) {
|
|
|
402
403
|
for (const [varName, color] of Object.entries(baseColors)){
|
|
403
404
|
const baseChroma = Math.max(color.c, BASE_CHROMA_BOOST);
|
|
404
405
|
const scaledChroma = baseChroma * chromaScale;
|
|
405
|
-
const shifted = toOklch(color.l, scaledChroma, oklchHue);
|
|
406
|
+
const shifted = toOklch(clampL(color.l), scaledChroma, oklchHue);
|
|
406
407
|
root.style.setProperty(varName, shifted);
|
|
407
408
|
}
|
|
408
409
|
const nfAccentSettings = NF_ACCENT_SETTINGS[resolvedTheme];
|
|
409
410
|
for (const [varName, settings] of Object.entries(nfAccentSettings)){
|
|
410
411
|
const scaledChroma = settings.c * chromaScale;
|
|
411
|
-
root.style.setProperty(varName, toOklch(settings.l, scaledChroma, oklchHue));
|
|
412
|
+
root.style.setProperty(varName, toOklch(clampL(settings.l), scaledChroma, oklchHue));
|
|
412
413
|
}
|
|
413
414
|
}
|
|
414
415
|
function resetHueShift() {
|
|
@@ -424,6 +425,7 @@ function resetHueShift() {
|
|
|
424
425
|
function createHueShiftStore(storagePrefix) {
|
|
425
426
|
const STORAGE_KEY = `${storagePrefix}_hue_shift`;
|
|
426
427
|
const STORAGE_KEY_SAT = `${storagePrefix}_hue_saturation`;
|
|
428
|
+
const STORAGE_KEY_LIT = `${storagePrefix}_hue_lightness`;
|
|
427
429
|
const getInitialHueShift = ()=>{
|
|
428
430
|
if ("undefined" == typeof window) return null;
|
|
429
431
|
const saved = localStorage.getItem(STORAGE_KEY);
|
|
@@ -442,20 +444,33 @@ function createHueShiftStore(storagePrefix) {
|
|
|
442
444
|
}
|
|
443
445
|
return 100;
|
|
444
446
|
};
|
|
447
|
+
const getInitialLightness = ()=>{
|
|
448
|
+
if ("undefined" == typeof window) return 0;
|
|
449
|
+
const saved = localStorage.getItem(STORAGE_KEY_LIT);
|
|
450
|
+
if (null !== saved) {
|
|
451
|
+
const parsed = parseFloat(saved);
|
|
452
|
+
if (!isNaN(parsed)) return parsed;
|
|
453
|
+
}
|
|
454
|
+
return 0;
|
|
455
|
+
};
|
|
445
456
|
const [hueShift, setHueShiftInternal] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(getInitialHueShift());
|
|
446
457
|
const [hueSaturation, setHueSaturationInternal] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(getInitialSaturation());
|
|
458
|
+
const [hueLightness, setHueLightnessInternal] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(getInitialLightness());
|
|
447
459
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
448
460
|
const shift = hueShift();
|
|
449
461
|
const sat = hueSaturation();
|
|
462
|
+
const lit = hueLightness();
|
|
450
463
|
if ("undefined" == typeof window) return;
|
|
451
464
|
if (null === shift) {
|
|
452
465
|
localStorage.removeItem(STORAGE_KEY);
|
|
453
466
|
localStorage.removeItem(STORAGE_KEY_SAT);
|
|
467
|
+
localStorage.removeItem(STORAGE_KEY_LIT);
|
|
454
468
|
resetHueShift();
|
|
455
469
|
} else {
|
|
456
470
|
localStorage.setItem(STORAGE_KEY, String(shift));
|
|
457
471
|
localStorage.setItem(STORAGE_KEY_SAT, String(sat));
|
|
458
|
-
|
|
472
|
+
localStorage.setItem(STORAGE_KEY_LIT, String(lit));
|
|
473
|
+
applyHueShift(shift, sat, lit);
|
|
459
474
|
}
|
|
460
475
|
});
|
|
461
476
|
if ("undefined" != typeof window) {
|
|
@@ -463,7 +478,8 @@ function createHueShiftStore(storagePrefix) {
|
|
|
463
478
|
for (const mutation of mutations)if ("attributes" === mutation.type && "data-theme" === mutation.attributeName) {
|
|
464
479
|
const shift = hueShift();
|
|
465
480
|
const sat = hueSaturation();
|
|
466
|
-
|
|
481
|
+
const lit = hueLightness();
|
|
482
|
+
if (null !== shift) requestAnimationFrame(()=>applyHueShift(shift, sat, lit));
|
|
467
483
|
}
|
|
468
484
|
});
|
|
469
485
|
observer.observe(document.documentElement, {
|
|
@@ -473,13 +489,15 @@ function createHueShiftStore(storagePrefix) {
|
|
|
473
489
|
]
|
|
474
490
|
});
|
|
475
491
|
}
|
|
476
|
-
const setHueShift = (hue, saturation = 100)=>{
|
|
492
|
+
const setHueShift = (hue, saturation = 100, lightness = 0)=>{
|
|
477
493
|
setHueShiftInternal(hue);
|
|
478
494
|
setHueSaturationInternal(saturation);
|
|
495
|
+
setHueLightnessInternal(lightness);
|
|
479
496
|
};
|
|
480
497
|
return {
|
|
481
498
|
hueShift,
|
|
482
499
|
hueSaturation,
|
|
500
|
+
hueLightness,
|
|
483
501
|
setHueShift,
|
|
484
502
|
isAvailable: ()=>checkCspAllowsInlineStyles()
|
|
485
503
|
};
|