@pathscale/ui 1.1.31 → 1.1.32
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.
|
@@ -30,12 +30,19 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
30
30
|
const store = (0, __WEBPACK_EXTERNAL_MODULE__hueShift_js_ca4235e5__.createHueShiftStore)(local.storagePrefix ?? "theme");
|
|
31
31
|
const colorValue = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createMemo)(()=>hexToColorValue(store.themeColor()));
|
|
32
32
|
const handleColorChange = (color)=>{
|
|
33
|
+
console.log("[tcp] handleColorChange ENTER", {
|
|
34
|
+
hex: color.hex,
|
|
35
|
+
hsl: color.hsl,
|
|
36
|
+
rgb: color.rgb
|
|
37
|
+
});
|
|
33
38
|
const { s, l } = color.hsl;
|
|
34
39
|
if (s < 10 && l > 90) {
|
|
40
|
+
console.log("[tcp] handleColorChange -> center swatch, clearing");
|
|
35
41
|
store.setThemeColor(null);
|
|
36
42
|
local.onColorChange?.(null, 100);
|
|
37
43
|
return;
|
|
38
44
|
}
|
|
45
|
+
console.log("[tcp] handleColorChange -> setThemeColor", color.hex);
|
|
39
46
|
store.setThemeColor(color.hex);
|
|
40
47
|
local.onColorChange?.(color.hsl.h, color.hsl.s);
|
|
41
48
|
};
|
|
@@ -72,10 +79,13 @@ const ThemeColorPicker_ThemeColorPicker = (props)=>{
|
|
|
72
79
|
}
|
|
73
80
|
];
|
|
74
81
|
const handleGrayscale = (swatch)=>{
|
|
82
|
+
console.log("[tcp] handleGrayscale ENTER", swatch);
|
|
75
83
|
store.setThemeColor(null);
|
|
76
84
|
(0, __WEBPACK_EXTERNAL_MODULE__hueShift_js_ca4235e5__.resetHueShift)();
|
|
77
85
|
local.onColorChange?.(null, 0);
|
|
86
|
+
console.log("[tcp] handleGrayscale -> onThemeSwitch", swatch.theme);
|
|
78
87
|
local.onThemeSwitch?.(swatch.theme);
|
|
88
|
+
console.log("[tcp] handleGrayscale AFTER onThemeSwitch, data-theme=", document.documentElement.getAttribute("data-theme"));
|
|
79
89
|
};
|
|
80
90
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
81
91
|
if (!isOpen()) return;
|
|
@@ -6,10 +6,6 @@ export interface HueShiftStore {
|
|
|
6
6
|
setThemeColor: (color: string | null) => void;
|
|
7
7
|
isAvailable: () => boolean;
|
|
8
8
|
}
|
|
9
|
-
/**
|
|
10
|
-
* Creates a theme color store with configurable storage prefix.
|
|
11
|
-
* @param storagePrefix - Prefix for localStorage keys (e.g., "myapp" becomes "myapp_theme_color")
|
|
12
|
-
*/
|
|
13
9
|
export declare function createHueShiftStore(storagePrefix: string): HueShiftStore;
|
|
14
10
|
export declare function getDefaultHueShiftStore(): HueShiftStore;
|
|
15
11
|
export { resetHueShift };
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import * as __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__ from "solid-js";
|
|
2
|
+
const log = (...args)=>{
|
|
3
|
+
console.log("[tcp]", ...args);
|
|
4
|
+
};
|
|
2
5
|
let cspAllowsInlineStyles = null;
|
|
3
6
|
const checkCspAllowsInlineStyles = ()=>{
|
|
4
7
|
if (null !== cspAllowsInlineStyles) return cspAllowsInlineStyles;
|
|
@@ -6,13 +9,20 @@ const checkCspAllowsInlineStyles = ()=>{
|
|
|
6
9
|
try {
|
|
7
10
|
const testEl = document.createElement("div");
|
|
8
11
|
testEl.style.setProperty("--csp-test", "1");
|
|
12
|
+
if (!document.body) {
|
|
13
|
+
log("csp check: document.body missing, assuming allowed");
|
|
14
|
+
cspAllowsInlineStyles = true;
|
|
15
|
+
return true;
|
|
16
|
+
}
|
|
9
17
|
document.body.appendChild(testEl);
|
|
10
18
|
const computed = getComputedStyle(testEl).getPropertyValue("--csp-test");
|
|
11
19
|
document.body.removeChild(testEl);
|
|
12
20
|
cspAllowsInlineStyles = "1" === computed;
|
|
13
|
-
} catch
|
|
21
|
+
} catch (err) {
|
|
22
|
+
log("csp check: threw, disabling", err);
|
|
14
23
|
cspAllowsInlineStyles = false;
|
|
15
24
|
}
|
|
25
|
+
log("csp check result:", cspAllowsInlineStyles);
|
|
16
26
|
if (!cspAllowsInlineStyles) console.info("[themeColor] CSP blocks inline styles - theme color customization disabled");
|
|
17
27
|
return cspAllowsInlineStyles;
|
|
18
28
|
};
|
|
@@ -120,24 +130,50 @@ function pickContentColor(r, g, b) {
|
|
|
120
130
|
return contrastWithWhite >= contrastWithDark ? "#ffffff" : "#111111";
|
|
121
131
|
}
|
|
122
132
|
function applyThemeColor(hex) {
|
|
123
|
-
|
|
133
|
+
log("applyThemeColor ENTER", hex);
|
|
134
|
+
if (!checkCspAllowsInlineStyles()) return void log("applyThemeColor BAILED: csp blocks");
|
|
124
135
|
const rgb = parseHex(hex);
|
|
125
|
-
if (!rgb) return;
|
|
136
|
+
if (!rgb) return void log("applyThemeColor BAILED: parseHex returned null for", hex);
|
|
126
137
|
const root = document.documentElement;
|
|
127
138
|
const content = pickContentColor(rgb.r, rgb.g, rgb.b);
|
|
128
139
|
const resolvedTheme = getResolvedTheme();
|
|
140
|
+
log("applyThemeColor resolvedTheme=", resolvedTheme, "content=", content);
|
|
141
|
+
log("applyThemeColor data-theme attr=", root.getAttribute("data-theme"));
|
|
129
142
|
for (const varName of PRIMARY_VARS)root.style.setProperty(varName, hex, "important");
|
|
130
143
|
for (const varName of CONTENT_VARS)root.style.setProperty(varName, content, "important");
|
|
131
144
|
for (const { name, anchor, mix } of BACKGROUND_VARS[resolvedTheme])root.style.setProperty(name, `color-mix(in oklab, ${hex} ${mix}%, ${anchor})`, "important");
|
|
145
|
+
const inlineStyle = root.getAttribute("style") ?? "";
|
|
146
|
+
log("applyThemeColor inline style attr length=", inlineStyle.length);
|
|
147
|
+
log("applyThemeColor inline snippet:", inlineStyle.slice(0, 400) + (inlineStyle.length > 400 ? "\u2026" : ""));
|
|
148
|
+
const cs = getComputedStyle(root);
|
|
149
|
+
log("applyThemeColor computed --color-primary=", cs.getPropertyValue("--color-primary").trim());
|
|
150
|
+
log("applyThemeColor computed --nf-accent=", cs.getPropertyValue("--nf-accent").trim());
|
|
151
|
+
log("applyThemeColor computed --color-nf-accent=", cs.getPropertyValue("--color-nf-accent").trim());
|
|
152
|
+
log("applyThemeColor computed --color-primary-content=", cs.getPropertyValue("--color-primary-content").trim());
|
|
153
|
+
log("applyThemeColor computed --nf-on-accent=", cs.getPropertyValue("--nf-on-accent").trim());
|
|
154
|
+
log("applyThemeColor computed --gradient-start=", cs.getPropertyValue("--gradient-start").trim());
|
|
155
|
+
log("applyThemeColor computed --gradient-end=", cs.getPropertyValue("--gradient-end").trim());
|
|
156
|
+
log("applyThemeColor computed --color-base-100=", cs.getPropertyValue("--color-base-100").trim());
|
|
157
|
+
log("applyThemeColor EXIT");
|
|
132
158
|
}
|
|
133
159
|
function resetHueShift() {
|
|
134
|
-
|
|
160
|
+
log("resetHueShift ENTER");
|
|
161
|
+
if (!checkCspAllowsInlineStyles()) return void log("resetHueShift BAILED: csp blocks");
|
|
135
162
|
const root = document.documentElement;
|
|
136
163
|
for (const varName of PRIMARY_VARS)root.style.removeProperty(varName);
|
|
137
164
|
for (const varName of CONTENT_VARS)root.style.removeProperty(varName);
|
|
138
165
|
for (const { name } of BACKGROUND_VARS.light)root.style.removeProperty(name);
|
|
166
|
+
const inlineStyle = root.getAttribute("style") ?? "";
|
|
167
|
+
log("resetHueShift inline style attr length after=", inlineStyle.length);
|
|
168
|
+
const cs = getComputedStyle(root);
|
|
169
|
+
log("resetHueShift computed --nf-accent=", cs.getPropertyValue("--nf-accent").trim());
|
|
170
|
+
log("resetHueShift computed --color-nf-accent=", cs.getPropertyValue("--color-nf-accent").trim());
|
|
171
|
+
log("resetHueShift EXIT");
|
|
139
172
|
}
|
|
173
|
+
let storeInstanceCounter = 0;
|
|
140
174
|
function createHueShiftStore(storagePrefix) {
|
|
175
|
+
const storeId = ++storeInstanceCounter;
|
|
176
|
+
log(`createHueShiftStore INIT id=${storeId} prefix=${storagePrefix}`);
|
|
141
177
|
const STORAGE_KEY = `${storagePrefix}_theme_color`;
|
|
142
178
|
const LEGACY_KEYS = [
|
|
143
179
|
`${storagePrefix}_hue_shift`,
|
|
@@ -151,9 +187,12 @@ function createHueShiftStore(storagePrefix) {
|
|
|
151
187
|
if (saved && parseHex(saved)) return saved;
|
|
152
188
|
return null;
|
|
153
189
|
};
|
|
154
|
-
const
|
|
190
|
+
const initial = getInitial();
|
|
191
|
+
log(`createHueShiftStore id=${storeId} initial localStorage value=`, initial);
|
|
192
|
+
const [themeColor, setThemeColorInternal] = (0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createSignal)(initial);
|
|
155
193
|
(0, __WEBPACK_EXTERNAL_MODULE_solid_js_aeefcc6d__.createEffect)(()=>{
|
|
156
194
|
const color = themeColor();
|
|
195
|
+
log(`store id=${storeId} effect fired, themeColor=`, color);
|
|
157
196
|
if ("undefined" == typeof window) return;
|
|
158
197
|
if (null === color) {
|
|
159
198
|
localStorage.removeItem(STORAGE_KEY);
|
|
@@ -165,10 +204,14 @@ function createHueShiftStore(storagePrefix) {
|
|
|
165
204
|
});
|
|
166
205
|
if ("undefined" != typeof window) {
|
|
167
206
|
const observer = new MutationObserver((mutations)=>{
|
|
168
|
-
for (const mutation of mutations)if ("attributes" === mutation.type && "data-theme" === mutation.attributeName)
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
207
|
+
for (const mutation of mutations)if ("attributes" === mutation.type && "data-theme" === mutation.attributeName) {
|
|
208
|
+
log(`store id=${storeId} observer saw data-theme change to=`, document.documentElement.getAttribute("data-theme"));
|
|
209
|
+
requestAnimationFrame(()=>{
|
|
210
|
+
const color = themeColor();
|
|
211
|
+
log(`store id=${storeId} observer rAF fired, themeColor=`, color);
|
|
212
|
+
if (null !== color) applyThemeColor(color);
|
|
213
|
+
});
|
|
214
|
+
}
|
|
172
215
|
});
|
|
173
216
|
observer.observe(document.documentElement, {
|
|
174
217
|
attributes: true,
|
|
@@ -178,8 +221,9 @@ function createHueShiftStore(storagePrefix) {
|
|
|
178
221
|
});
|
|
179
222
|
}
|
|
180
223
|
const setThemeColor = (color)=>{
|
|
224
|
+
log(`store id=${storeId} setThemeColor called with=`, color);
|
|
181
225
|
if (null === color) return void setThemeColorInternal(null);
|
|
182
|
-
if (!parseHex(color)) return;
|
|
226
|
+
if (!parseHex(color)) return void log(`store id=${storeId} setThemeColor REJECTED (parseHex failed)`);
|
|
183
227
|
setThemeColorInternal(color);
|
|
184
228
|
};
|
|
185
229
|
return {
|