@gospore/theme 1.0.163 → 1.0.165
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 +79 -9
- package/dist/index.d.ts +5 -0
- package/dist/theme.cjs +45 -0
- package/dist/theme.cjs.map +1 -0
- package/dist/theme.css +1 -1
- package/dist/theme.es.js +292 -143
- package/dist/theme.es.js.map +1 -1
- package/dist/theme.umd.js +44 -1
- package/dist/theme.umd.js.map +1 -1
- package/dist/themeBootstrap.d.ts +20 -0
- package/package.json +9 -9
- package/dist/theme.cjs.js +0 -2
- package/dist/theme.cjs.js.map +0 -1
package/dist/theme.es.js
CHANGED
|
@@ -9,37 +9,48 @@ var y = [
|
|
|
9
9
|
], b = "gospore-theme-mode", x = 3600 * 24 * 365, S = "(prefers-color-scheme: dark)";
|
|
10
10
|
function C() {
|
|
11
11
|
if (typeof document > "u") return null;
|
|
12
|
-
let e =
|
|
12
|
+
let e = D(b);
|
|
13
13
|
return k(e) ? e : null;
|
|
14
14
|
}
|
|
15
15
|
function w(e) {
|
|
16
16
|
if (typeof document > "u" || !y.includes(e)) return;
|
|
17
|
-
let t = typeof window < "u" ? window.location.hostname : "", n = typeof window < "u" ? window.location.protocol : ""
|
|
17
|
+
let t = typeof window < "u" ? window.location.hostname : "", n = (typeof window < "u" ? window.location.protocol : "") === "https:", r = [
|
|
18
18
|
"path=/",
|
|
19
19
|
`max-age=${x}`,
|
|
20
20
|
"SameSite=Lax"
|
|
21
21
|
];
|
|
22
|
-
|
|
22
|
+
n && r.push("Secure");
|
|
23
|
+
let i = T(t);
|
|
24
|
+
i && (document.cookie = [
|
|
25
|
+
`${encodeURIComponent(b)}=`,
|
|
26
|
+
"path=/",
|
|
27
|
+
"max-age=0",
|
|
28
|
+
"SameSite=Lax",
|
|
29
|
+
`domain=${i}`,
|
|
30
|
+
...n ? ["Secure"] : []
|
|
31
|
+
].join("; ")), document.cookie = [`${encodeURIComponent(b)}=${encodeURIComponent(e)}`, ...r].join("; ");
|
|
23
32
|
}
|
|
24
33
|
function T(e) {
|
|
25
|
-
if (
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
document.documentElement.setAttribute("dark-mode", String(n));
|
|
34
|
+
if (!e || e === "localhost") return null;
|
|
35
|
+
if (/^\d+(?:\.\d+){3}$/.test(e)) return e;
|
|
36
|
+
let t = e.split(".");
|
|
37
|
+
return t.length <= 1 ? null : t.slice(-2).join(".");
|
|
30
38
|
}
|
|
31
39
|
function E(e) {
|
|
40
|
+
if (typeof document > "u") return;
|
|
41
|
+
let t = O(k(e) ? e : C() ?? "auto");
|
|
42
|
+
document.documentElement.setAttribute("dark-mode", String(t));
|
|
43
|
+
}
|
|
44
|
+
function D(e) {
|
|
32
45
|
if (typeof document > "u" || !document.cookie) return null;
|
|
33
46
|
let t = `${encodeURIComponent(e)}=`, n = document.cookie.split("; ");
|
|
34
|
-
for (let e of n) if (e.startsWith(t))
|
|
47
|
+
for (let e of n) if (e.startsWith(t)) try {
|
|
48
|
+
return decodeURIComponent(e.slice(t.length));
|
|
49
|
+
} catch {
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
35
52
|
return null;
|
|
36
53
|
}
|
|
37
|
-
function D(e) {
|
|
38
|
-
if (!e || e === "localhost") return null;
|
|
39
|
-
if (/^\d+(?:\.\d+){3}$/.test(e)) return e;
|
|
40
|
-
let t = e.split(".");
|
|
41
|
-
return t.length <= 1 ? null : t.length === 2 ? e : t.slice(-2).join(".");
|
|
42
|
-
}
|
|
43
54
|
function O(e) {
|
|
44
55
|
if (e === "dark") return !0;
|
|
45
56
|
if (e === "light" || typeof window > "u") return !1;
|
|
@@ -56,15 +67,13 @@ function k(e) {
|
|
|
56
67
|
//#endregion
|
|
57
68
|
//#region src/portalHost.ts
|
|
58
69
|
var A = Symbol.for("gospore.theme.portalHost");
|
|
59
|
-
function
|
|
70
|
+
function ee() {
|
|
60
71
|
let t = o(A, null);
|
|
61
|
-
|
|
62
|
-
let n = typeof document < "u" ? document.body : "body";
|
|
63
|
-
return e(() => t?.value ?? n);
|
|
72
|
+
return e(() => t?.value ?? "body");
|
|
64
73
|
}
|
|
65
74
|
//#endregion
|
|
66
75
|
//#region src/Theme.vue?vue&type=script&setup=true&lang.ts
|
|
67
|
-
var
|
|
76
|
+
var j = [], M = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Map(), P = [], F, te = "(prefers-color-scheme: dark)", ne = "(prefers-reduced-motion: reduce)", re = 200, I = 4.5, ie = 1.8, ae = 1.15, oe = 1.08, L = 4.5, se = 3, R = "#ffffff", z = "#1f2228", B = /* @__PURE__ */ a({
|
|
68
77
|
name: "Theme",
|
|
69
78
|
__name: "Theme",
|
|
70
79
|
props: {
|
|
@@ -90,49 +99,84 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
90
99
|
setup(t) {
|
|
91
100
|
let i = t;
|
|
92
101
|
function a() {
|
|
102
|
+
if (typeof document > "u") return;
|
|
93
103
|
let e = document.documentElement;
|
|
94
104
|
if (!e) return;
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
t && Object.
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
}
|
|
103
|
-
let o = window.matchMedia(ee), p = window.matchMedia(te), h = E();
|
|
104
|
-
T(h);
|
|
105
|
-
let g = d(h), _ = d({ darkMode: b(h) }), v = d(null);
|
|
106
|
-
o.addEventListener("change", x), m(() => i.mode, () => {
|
|
107
|
-
y();
|
|
108
|
-
}, { immediate: !0 }), m(() => _.value.darkMode, (e, t) => {
|
|
109
|
-
if (t === void 0) {
|
|
110
|
-
S(e);
|
|
105
|
+
M.forEach((t) => {
|
|
106
|
+
let n = N.get(t);
|
|
107
|
+
n?.value ? e.style.setProperty(t, n.value, n.priority) : e.style.removeProperty(t);
|
|
108
|
+
}), M.clear();
|
|
109
|
+
let t = [...j].reverse().find((e) => e.enabled && e.vars && Object.keys(e.vars).length > 0);
|
|
110
|
+
if (!t) {
|
|
111
|
+
N.clear();
|
|
111
112
|
return;
|
|
112
113
|
}
|
|
113
|
-
|
|
114
|
-
|
|
114
|
+
Object.entries(t.vars).forEach(([t, n]) => {
|
|
115
|
+
N.has(t) || N.set(t, {
|
|
116
|
+
priority: e.style.getPropertyPriority(t),
|
|
117
|
+
value: e.style.getPropertyValue(t)
|
|
118
|
+
}), e.style.setProperty(t, n), M.add(t);
|
|
115
119
|
});
|
|
120
|
+
}
|
|
121
|
+
let p = U(te), h = U(ne), g = o("theme", null), _ = H(), v = d(_), y = null, b = d({ darkMode: D(_) }), x = { darkMode: b.value.darkMode }, S = !1;
|
|
122
|
+
E();
|
|
123
|
+
let w = d(null);
|
|
124
|
+
p.addEventListener("change", O), m(() => i.mode, () => {
|
|
125
|
+
T();
|
|
126
|
+
}, { immediate: !0 }), m(() => g?.value.darkMode, () => {
|
|
127
|
+
i.mode === void 0 && T();
|
|
128
|
+
}), m(() => b.value.darkMode, (e, t) => {
|
|
129
|
+
if (x.darkMode = e, !(!S || !B(x))) {
|
|
130
|
+
if (t === void 0) {
|
|
131
|
+
k(e);
|
|
132
|
+
return;
|
|
133
|
+
}
|
|
134
|
+
ce(() => {
|
|
135
|
+
B(x) && k(e);
|
|
136
|
+
});
|
|
137
|
+
}
|
|
116
138
|
}, { immediate: !0 }), c(() => {
|
|
117
|
-
|
|
118
|
-
let e =
|
|
119
|
-
e !== -1 &&
|
|
139
|
+
p.removeEventListener("change", O), y !== null && typeof window < "u" && (window.cancelAnimationFrame(y), y = null), S && V(x);
|
|
140
|
+
let e = j.indexOf($);
|
|
141
|
+
e !== -1 && j.splice(e, 1), a();
|
|
120
142
|
});
|
|
121
|
-
function
|
|
122
|
-
let e =
|
|
123
|
-
|
|
143
|
+
function T() {
|
|
144
|
+
let e = H(), t = D(e);
|
|
145
|
+
v.value = e, x.darkMode = t, E(), b.value.darkMode = t;
|
|
146
|
+
}
|
|
147
|
+
function E() {
|
|
148
|
+
let e = g === null || i.mode !== void 0;
|
|
149
|
+
e && !S ? S = ee(x) : !e && S && (V(x), S = !1);
|
|
150
|
+
}
|
|
151
|
+
function D(e) {
|
|
152
|
+
return e === "dark" || e !== "light" && p.matches;
|
|
153
|
+
}
|
|
154
|
+
function O(e) {
|
|
155
|
+
!e || v.value !== "auto" || (b.value.darkMode = e.matches);
|
|
156
|
+
}
|
|
157
|
+
function k(e) {
|
|
158
|
+
typeof document > "u" || document.documentElement.setAttribute("dark-mode", String(e));
|
|
124
159
|
}
|
|
125
|
-
function
|
|
126
|
-
return
|
|
160
|
+
function ee(e) {
|
|
161
|
+
return typeof document > "u" ? !1 : (P.length === 0 && (F = document.documentElement.getAttribute("dark-mode")), P.push(e), k(e.darkMode), !0);
|
|
127
162
|
}
|
|
128
|
-
function
|
|
129
|
-
|
|
163
|
+
function B(e) {
|
|
164
|
+
return P.at(-1) === e;
|
|
130
165
|
}
|
|
131
|
-
function
|
|
132
|
-
|
|
166
|
+
function V(e) {
|
|
167
|
+
let t = P.indexOf(e);
|
|
168
|
+
if (t === -1) return;
|
|
169
|
+
let n = t === P.length - 1;
|
|
170
|
+
if (P.splice(t, 1), !n || typeof document > "u") return;
|
|
171
|
+
let r = P.at(-1);
|
|
172
|
+
if (r) {
|
|
173
|
+
k(r.darkMode);
|
|
174
|
+
return;
|
|
175
|
+
}
|
|
176
|
+
F === null ? document.documentElement.removeAttribute("dark-mode") : F !== void 0 && document.documentElement.setAttribute("dark-mode", F), F = void 0;
|
|
133
177
|
}
|
|
134
|
-
function
|
|
135
|
-
if (
|
|
178
|
+
function ce(e) {
|
|
179
|
+
if (h.matches || typeof document > "u" || typeof window > "u") {
|
|
136
180
|
e();
|
|
137
181
|
return;
|
|
138
182
|
}
|
|
@@ -145,18 +189,33 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
145
189
|
}
|
|
146
190
|
e();
|
|
147
191
|
let n = document.documentElement;
|
|
148
|
-
typeof n.animate == "function" && window.requestAnimationFrame(() => {
|
|
149
|
-
n.animate([{ opacity: .85 }, { opacity: 1 }], {
|
|
150
|
-
duration:
|
|
192
|
+
typeof n.animate == "function" && (y !== null && window.cancelAnimationFrame(y), y = window.requestAnimationFrame(() => {
|
|
193
|
+
y = null, n.animate([{ opacity: .85 }, { opacity: 1 }], {
|
|
194
|
+
duration: re,
|
|
151
195
|
easing: "ease-in-out"
|
|
152
196
|
});
|
|
153
|
-
});
|
|
197
|
+
}));
|
|
154
198
|
}
|
|
155
|
-
function
|
|
156
|
-
return i.mode ?? C() ?? "auto";
|
|
199
|
+
function H() {
|
|
200
|
+
return i.mode === void 0 && g ? g.value.darkMode ? "dark" : "light" : i.mode ?? C() ?? "auto";
|
|
157
201
|
}
|
|
158
|
-
|
|
159
|
-
|
|
202
|
+
function U(e) {
|
|
203
|
+
if (typeof window < "u" && typeof window.matchMedia == "function") try {
|
|
204
|
+
return window.matchMedia(e);
|
|
205
|
+
} catch {}
|
|
206
|
+
return {
|
|
207
|
+
addEventListener() {},
|
|
208
|
+
addListener() {},
|
|
209
|
+
dispatchEvent: () => !1,
|
|
210
|
+
matches: !1,
|
|
211
|
+
media: e,
|
|
212
|
+
onchange: null,
|
|
213
|
+
removeEventListener() {},
|
|
214
|
+
removeListener() {}
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
u("theme", b), u(A, w);
|
|
218
|
+
function W(e) {
|
|
160
219
|
if (!e) return null;
|
|
161
220
|
let t = e.trim().toLowerCase();
|
|
162
221
|
if (!/^#(?:[0-9a-f]{3}|[0-9a-f]{6})$/i.exec(t)) return null;
|
|
@@ -166,94 +225,94 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
166
225
|
}
|
|
167
226
|
return t;
|
|
168
227
|
}
|
|
169
|
-
function
|
|
170
|
-
let t =
|
|
228
|
+
function G(e) {
|
|
229
|
+
let t = W(e);
|
|
171
230
|
return t ? {
|
|
172
231
|
r: parseInt(t.slice(1, 3), 16),
|
|
173
232
|
g: parseInt(t.slice(3, 5), 16),
|
|
174
233
|
b: parseInt(t.slice(5, 7), 16)
|
|
175
234
|
} : null;
|
|
176
235
|
}
|
|
177
|
-
function
|
|
236
|
+
function K({ r: e, g: t, b: n }) {
|
|
178
237
|
let r = (e) => e.toString(16).padStart(2, "0");
|
|
179
238
|
return `#${r(e)}${r(t)}${r(n)}`;
|
|
180
239
|
}
|
|
181
|
-
function
|
|
240
|
+
function q(e) {
|
|
182
241
|
return Math.max(0, Math.min(1, e));
|
|
183
242
|
}
|
|
184
|
-
function
|
|
243
|
+
function J(e) {
|
|
185
244
|
return e <= .04045 ? e / 12.92 : ((e + .055) / 1.055) ** 2.4;
|
|
186
245
|
}
|
|
187
|
-
function
|
|
188
|
-
let t =
|
|
246
|
+
function Y(e) {
|
|
247
|
+
let t = q(e);
|
|
189
248
|
return t <= .0031308 ? 12.92 * t : 1.055 * t ** (1 / 2.4) - .055;
|
|
190
249
|
}
|
|
191
|
-
function
|
|
192
|
-
let r = e / 255, i = t / 255, a = n / 255, o =
|
|
250
|
+
function le({ r: e, g: t, b: n }) {
|
|
251
|
+
let r = e / 255, i = t / 255, a = n / 255, o = J(r), s = J(i), c = J(a), l = .4122214708 * o + .5363325363 * s + .0514459929 * c, u = .2119034982 * o + .6806995451 * s + .1073969566 * c, d = .0883024619 * o + .2817188376 * s + .6299787005 * c, f = Math.cbrt(l), p = Math.cbrt(u), m = Math.cbrt(d), h = .2104542553 * f + .793617785 * p - .0040720468 * m, g = 1.9779984951 * f - 2.428592205 * p + .4505937099 * m, _ = .0259040371 * f + .7827717662 * p - .808675766 * m, v = Math.sqrt(g * g + _ * _), y = 180 / Math.PI * Math.atan2(_, g);
|
|
193
252
|
return y < 0 && (y += 360), {
|
|
194
253
|
l: h,
|
|
195
254
|
c: v,
|
|
196
255
|
h: y
|
|
197
256
|
};
|
|
198
257
|
}
|
|
199
|
-
function
|
|
200
|
-
let i = n * Math.PI / 180, a = t * Math.cos(i), o = t * Math.sin(i), s = e + .3963377774 * a + .2158037573 * o, c = e - .1055613458 * a - .0638541728 * o, l = e - .0894841775 * a - 1.291485548 * o, u = r ?
|
|
258
|
+
function ue(e, t, n, r = !1) {
|
|
259
|
+
let i = n * Math.PI / 180, a = t * Math.cos(i), o = t * Math.sin(i), s = e + .3963377774 * a + .2158037573 * o, c = e - .1055613458 * a - .0638541728 * o, l = e - .0894841775 * a - 1.291485548 * o, u = r ? q(s) : s, d = r ? q(c) : c, f = r ? q(l) : l;
|
|
201
260
|
if (!r && (u < -1e-4 || u > 1.0001 || d < -1e-4 || d > 1.0001 || f < -1e-4 || f > 1.0001)) return null;
|
|
202
261
|
let p = u * u * u, m = d * d * d, h = f * f * f, g = 4.0767416621 * p - 3.3077115913 * m + .2309699292 * h, _ = -1.2684380046 * p + 2.6097574011 * m - .3413193965 * h, v = -.0041960863 * p - .7034186147 * m + 1.707614701 * h;
|
|
203
|
-
if (r) g =
|
|
262
|
+
if (r) g = q(g), _ = q(_), v = q(v);
|
|
204
263
|
else if (g < -1e-4 || g > 1.0001 || _ < -1e-4 || _ > 1.0001 || v < -1e-4 || v > 1.0001) return null;
|
|
205
|
-
let y =
|
|
264
|
+
let y = q(Y(g)), b = q(Y(_)), x = q(Y(v));
|
|
206
265
|
return {
|
|
207
266
|
r: Math.round(y * 255),
|
|
208
267
|
g: Math.round(b * 255),
|
|
209
268
|
b: Math.round(x * 255)
|
|
210
269
|
};
|
|
211
270
|
}
|
|
212
|
-
function
|
|
271
|
+
function de(e, t, n) {
|
|
213
272
|
let r = t;
|
|
214
273
|
for (let t = 0; t < 8; t += 1) {
|
|
215
|
-
let t =
|
|
274
|
+
let t = ue(e, r, n);
|
|
216
275
|
if (t) return t;
|
|
217
276
|
r *= .9;
|
|
218
277
|
}
|
|
219
|
-
return
|
|
278
|
+
return ue(e, q(r), n, !0) || {
|
|
220
279
|
r: 0,
|
|
221
280
|
g: 0,
|
|
222
281
|
b: 0
|
|
223
282
|
};
|
|
224
283
|
}
|
|
225
|
-
function
|
|
226
|
-
let t =
|
|
284
|
+
function fe(e) {
|
|
285
|
+
let t = G(e);
|
|
227
286
|
if (!t) return 0;
|
|
228
|
-
let n =
|
|
287
|
+
let n = J(t.r / 255), r = J(t.g / 255), i = J(t.b / 255);
|
|
229
288
|
return .2126 * n + .7152 * r + .0722 * i;
|
|
230
289
|
}
|
|
231
|
-
function
|
|
232
|
-
let n =
|
|
290
|
+
function X(e, t) {
|
|
291
|
+
let n = fe(e), r = fe(t), i = Math.max(n, r), a = Math.min(n, r);
|
|
233
292
|
return (i + .05) / (a + .05);
|
|
234
293
|
}
|
|
235
|
-
function
|
|
236
|
-
let r = n.minContrast ??
|
|
294
|
+
function pe(e, t, n = {}) {
|
|
295
|
+
let r = n.minContrast ?? I, i = n.preferDark !== !1, a = Math.max(.01, Math.min(.06, (e.c || .12) * (n.chromaScale ?? .25))), o = n.initialLightness ?? (i ? .24 : .94), s = i ? -1 : 1, c = n.step ?? .03, l = q(o), u = K(de(l, a, e.h)), d = X(t, u);
|
|
237
296
|
for (let n = 0; n < 48; n += 1) {
|
|
238
|
-
let n =
|
|
297
|
+
let n = K(de(l, a, e.h)), i = X(t, n);
|
|
239
298
|
if (i > d && (d = i, u = n), i >= r) return n;
|
|
240
|
-
if (l =
|
|
299
|
+
if (l = q(l + s * c), l === 0 || l === 1) break;
|
|
241
300
|
}
|
|
242
|
-
let f = "#000000", p = "#ffffff", m =
|
|
301
|
+
let f = "#000000", p = "#ffffff", m = X(t, f), h = X(t, p);
|
|
243
302
|
return m >= r || h >= r ? m >= h ? f : p : u;
|
|
244
303
|
}
|
|
245
|
-
function
|
|
246
|
-
let r = n.minContrast ??
|
|
304
|
+
function Z(e, t, n = {}) {
|
|
305
|
+
let r = n.minContrast ?? I, i = n.darkCandidate ?? "#101214", a = n.lightCandidate ?? "#ffffff", o = n.preferredCandidate, s = n.preferredMinContrast ?? r, c = n.preferredSwitchDelta ?? 0, l = X(t, i), u = X(t, a), d = l >= r, f = u >= r, p = u >= s, m = l >= s;
|
|
247
306
|
if (d || f) return o === "light" && p ? a : o === "dark" && m ? i : o === "light" && f ? !d || l - u <= c ? a : i : o === "dark" && d ? !f || u - l <= c ? i : a : d && f ? l >= u ? i : a : d ? i : a;
|
|
248
307
|
let h = l >= u;
|
|
249
|
-
return
|
|
308
|
+
return pe(e, t, {
|
|
250
309
|
minContrast: r,
|
|
251
310
|
preferDark: h,
|
|
252
311
|
initialLightness: h ? .2 : .96,
|
|
253
312
|
chromaScale: .1
|
|
254
313
|
});
|
|
255
314
|
}
|
|
256
|
-
let
|
|
315
|
+
let me = [
|
|
257
316
|
100,
|
|
258
317
|
200,
|
|
259
318
|
300,
|
|
@@ -264,7 +323,7 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
264
323
|
800,
|
|
265
324
|
900,
|
|
266
325
|
1e3
|
|
267
|
-
],
|
|
326
|
+
], he = [
|
|
268
327
|
.9,
|
|
269
328
|
.84,
|
|
270
329
|
.78,
|
|
@@ -275,7 +334,7 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
275
334
|
.5,
|
|
276
335
|
.44,
|
|
277
336
|
.38
|
|
278
|
-
],
|
|
337
|
+
], ge = [
|
|
279
338
|
.28,
|
|
280
339
|
.4,
|
|
281
340
|
.54,
|
|
@@ -287,19 +346,31 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
287
346
|
1.2,
|
|
288
347
|
1.24
|
|
289
348
|
];
|
|
290
|
-
function
|
|
349
|
+
function Q(e, t, n, r) {
|
|
291
350
|
let i = t[t.length - 1];
|
|
292
351
|
for (let i of t) {
|
|
293
352
|
let t = e[i];
|
|
294
|
-
if (t &&
|
|
353
|
+
if (t && X(t, n) >= r) return i;
|
|
295
354
|
}
|
|
296
355
|
return i;
|
|
297
356
|
}
|
|
298
|
-
function
|
|
299
|
-
let
|
|
300
|
-
|
|
357
|
+
function _e(e, t, n, r, i) {
|
|
358
|
+
for (let e of n) {
|
|
359
|
+
let n = t[e];
|
|
360
|
+
if (n && X(n, r) >= L) return n;
|
|
361
|
+
}
|
|
362
|
+
return pe(e, r, {
|
|
363
|
+
chromaScale: 1,
|
|
364
|
+
initialLightness: i ? .45 : .72,
|
|
365
|
+
minContrast: L,
|
|
366
|
+
preferDark: i
|
|
367
|
+
});
|
|
368
|
+
}
|
|
369
|
+
function ve(e) {
|
|
370
|
+
let t = e.l - he[5], n = e.c > .02 ? .02 : 0;
|
|
371
|
+
return me.reduce((r, i, a) => (r[i] = K(de(q(he[a] + t), Math.min(.4, Math.max(n, e.c * ge[a])), e.h)), r), {});
|
|
301
372
|
}
|
|
302
|
-
function
|
|
373
|
+
function ye(e, t) {
|
|
303
374
|
let n = [
|
|
304
375
|
100,
|
|
305
376
|
200,
|
|
@@ -308,14 +379,14 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
308
379
|
500,
|
|
309
380
|
600,
|
|
310
381
|
700
|
|
311
|
-
], r =
|
|
382
|
+
], r = Q(t, n, R, oe), i = n.indexOf(r), a = n[Math.min(i + 1, n.length - 1)], o = n[Math.min(i + 2, n.length - 1)], s = [
|
|
312
383
|
1e3,
|
|
313
384
|
900,
|
|
314
385
|
800,
|
|
315
386
|
700,
|
|
316
387
|
600,
|
|
317
388
|
500
|
|
318
|
-
], c =
|
|
389
|
+
], c = Q(t, s, z, oe), l = s.indexOf(c), u = s[Math.min(l + 1, s.length - 1)], d = s[Math.min(l + 2, s.length - 1)], f = Q(t, [
|
|
319
390
|
200,
|
|
320
391
|
300,
|
|
321
392
|
400,
|
|
@@ -323,25 +394,25 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
323
394
|
600,
|
|
324
395
|
700,
|
|
325
396
|
800
|
|
326
|
-
],
|
|
397
|
+
], R, ae), p = Q(t, [
|
|
327
398
|
900,
|
|
328
399
|
800,
|
|
329
400
|
700,
|
|
330
401
|
600,
|
|
331
402
|
500,
|
|
332
403
|
400
|
|
333
|
-
],
|
|
404
|
+
], z, ae), m = [
|
|
334
405
|
600,
|
|
335
406
|
700,
|
|
336
407
|
800,
|
|
337
408
|
900,
|
|
338
409
|
1e3
|
|
339
|
-
], h =
|
|
410
|
+
], h = Q(t, m, R, ie), g = m.indexOf(h), _ = m[Math.min(g + 1, m.length - 1)], v = m[Math.min(g + 2, m.length - 1)], y = [
|
|
340
411
|
400,
|
|
341
412
|
300,
|
|
342
413
|
200,
|
|
343
414
|
100
|
|
344
|
-
], b =
|
|
415
|
+
], b = Q(t, y, z, ie), x = y.indexOf(b), S = y[Math.min(x + 1, y.length - 1)], C = y[Math.min(x + 2, y.length - 1)], w = {
|
|
345
416
|
"--color-brand-surface-soft-light": t[r],
|
|
346
417
|
"--color-brand-surface-soft-hovered-light": t[a],
|
|
347
418
|
"--color-brand-surface-soft-pressed-light": t[o],
|
|
@@ -357,24 +428,35 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
357
428
|
"--color-brand-surface-strong-hovered-dark": t[S],
|
|
358
429
|
"--color-brand-surface-strong-pressed-dark": t[C]
|
|
359
430
|
}, T = t[600];
|
|
360
|
-
return w["--color-brand-on-soft-light"] =
|
|
361
|
-
minContrast:
|
|
431
|
+
return w["--color-brand-on-soft-light"] = X(w["--color-brand-surface-soft-light"], T) >= I ? T : Z(e, w["--color-brand-surface-soft-light"], { minContrast: I }), w["--color-brand-on-soft-dark"] = Z(e, w["--color-brand-surface-soft-dark"], { minContrast: I }), w["--color-brand-on-subtle-light"] = Z(e, w["--color-brand-surface-subtle-light"], {
|
|
432
|
+
minContrast: L,
|
|
362
433
|
preferredCandidate: "light",
|
|
363
|
-
preferredMinContrast:
|
|
364
|
-
preferredSwitchDelta:
|
|
365
|
-
}), w["--color-brand-on-subtle-dark"] =
|
|
366
|
-
minContrast:
|
|
434
|
+
preferredMinContrast: L,
|
|
435
|
+
preferredSwitchDelta: se
|
|
436
|
+
}), w["--color-brand-on-subtle-dark"] = Z(e, w["--color-brand-surface-subtle-dark"], { minContrast: I }), w["--color-brand-on-strong-light"] = Z(e, w["--color-brand-surface-strong-light"], {
|
|
437
|
+
minContrast: L,
|
|
367
438
|
preferredCandidate: "light",
|
|
368
|
-
preferredMinContrast:
|
|
369
|
-
preferredSwitchDelta:
|
|
370
|
-
}), w["--color-brand-on-strong-dark"] =
|
|
439
|
+
preferredMinContrast: L,
|
|
440
|
+
preferredSwitchDelta: se
|
|
441
|
+
}), w["--color-brand-on-strong-dark"] = Z(e, w["--color-brand-surface-strong-dark"], { minContrast: I }), w["--color-brand-text-light"] = _e(e, t, [
|
|
442
|
+
600,
|
|
443
|
+
700,
|
|
444
|
+
800,
|
|
445
|
+
900,
|
|
446
|
+
1e3
|
|
447
|
+
], R, !0), w["--color-brand-text-dark"] = _e(e, t, [
|
|
448
|
+
400,
|
|
449
|
+
300,
|
|
450
|
+
200,
|
|
451
|
+
100
|
|
452
|
+
], z, !1), w["--color-brand-icon-light"] = w["--color-brand-text-light"], w["--color-brand-icon-dark"] = w["--color-brand-text-dark"], w["--color-brand-border-light"] = w["--color-brand-text-light"], w["--color-brand-border-dark"] = w["--color-brand-text-dark"], w;
|
|
371
453
|
}
|
|
372
|
-
function
|
|
373
|
-
let t =
|
|
454
|
+
function be(e) {
|
|
455
|
+
let t = W(e);
|
|
374
456
|
if (!t) return null;
|
|
375
|
-
let n =
|
|
457
|
+
let n = G(t);
|
|
376
458
|
if (!n) return null;
|
|
377
|
-
let r =
|
|
459
|
+
let r = le(n), i = ve(r);
|
|
378
460
|
return i[600] = t, {
|
|
379
461
|
"--color-brand-seed": t,
|
|
380
462
|
"--color-brand-100": i[100],
|
|
@@ -387,27 +469,27 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
387
469
|
"--color-brand-800": i[800],
|
|
388
470
|
"--color-brand-900": i[900],
|
|
389
471
|
"--color-brand-1000": i[1e3],
|
|
390
|
-
...
|
|
472
|
+
...ye(r, i)
|
|
391
473
|
};
|
|
392
474
|
}
|
|
393
|
-
let
|
|
475
|
+
let xe = e(() => be(i.accentColor) ?? {}), $ = {
|
|
394
476
|
vars: {},
|
|
395
477
|
enabled: !!i.exposeGlobalAccent
|
|
396
478
|
};
|
|
397
|
-
return
|
|
479
|
+
return typeof document < "u" && j.push($), m(() => i.exposeGlobalAccent, (e) => {
|
|
398
480
|
$.enabled = !!e, a();
|
|
399
|
-
}, { immediate: !0 }), m(
|
|
481
|
+
}, { immediate: !0 }), m(xe, (e) => {
|
|
400
482
|
e && Object.keys(e).length > 0 ? $.vars = { ...e } : $.vars = {}, a();
|
|
401
483
|
}, { immediate: !0 }), (e, t) => (l(), n("div", {
|
|
402
484
|
class: "theme",
|
|
403
|
-
style: s(
|
|
485
|
+
style: s(xe.value)
|
|
404
486
|
}, [f(e.$slots, "default"), r("div", {
|
|
405
487
|
ref_key: "portalHost",
|
|
406
|
-
ref:
|
|
488
|
+
ref: w,
|
|
407
489
|
class: "theme__portal-host"
|
|
408
490
|
}, null, 512)], 4));
|
|
409
491
|
}
|
|
410
|
-
}),
|
|
492
|
+
}), V = /*#__PURE__*/ ((e, t) => {
|
|
411
493
|
let n = e.__vccOpts || e;
|
|
412
494
|
for (let [e, r] of t) n[e] = r;
|
|
413
495
|
return n;
|
|
@@ -437,20 +519,20 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
437
519
|
value: "dark",
|
|
438
520
|
label: "Dark"
|
|
439
521
|
}
|
|
440
|
-
].reduce((e, t) => (e[t.value] = t.label, e), {}),
|
|
441
|
-
|
|
442
|
-
let
|
|
443
|
-
return m(() =>
|
|
444
|
-
|
|
445
|
-
}), m(
|
|
446
|
-
if (!
|
|
447
|
-
|
|
522
|
+
].reduce((e, t) => (e[t.value] = t.label, e), {}), s = y, c = e, u = n, f = o("theme", null) !== null;
|
|
523
|
+
f || E();
|
|
524
|
+
let b = d(!1), x = C() ?? c.mode, S = d(s.includes(x) ? x : "auto");
|
|
525
|
+
return m(() => c.mode, (e) => {
|
|
526
|
+
s.includes(e) && e !== S.value && (S.value = e);
|
|
527
|
+
}), m(S, (e) => {
|
|
528
|
+
if (!s.includes(e)) {
|
|
529
|
+
S.value = "auto";
|
|
448
530
|
return;
|
|
449
531
|
}
|
|
450
|
-
|
|
532
|
+
b.value = !1, u("update:mode", e), w(e), f || E(e);
|
|
451
533
|
}, { immediate: !0 }), (e, n) => (l(), t(p(v), {
|
|
452
|
-
open:
|
|
453
|
-
"onUpdate:open": n[3] ||= (e) =>
|
|
534
|
+
open: b.value,
|
|
535
|
+
"onUpdate:open": n[3] ||= (e) => b.value = e,
|
|
454
536
|
text: "Theme",
|
|
455
537
|
"aria-label": "Select theme mode"
|
|
456
538
|
}, {
|
|
@@ -460,8 +542,8 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
460
542
|
}, {
|
|
461
543
|
default: h(() => [
|
|
462
544
|
i(p(_), {
|
|
463
|
-
checked:
|
|
464
|
-
"onUpdate:checked": n[0] ||= (e) =>
|
|
545
|
+
checked: S.value,
|
|
546
|
+
"onUpdate:checked": n[0] ||= (e) => S.value = e,
|
|
465
547
|
value: "auto",
|
|
466
548
|
label: p(a).auto,
|
|
467
549
|
"aria-label": `${p(a).auto} mode`
|
|
@@ -472,8 +554,8 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
472
554
|
]),
|
|
473
555
|
n[4] ||= r("hr", { class: "theme-switcher-divider" }, null, -1),
|
|
474
556
|
i(p(_), {
|
|
475
|
-
checked:
|
|
476
|
-
"onUpdate:checked": n[1] ||= (e) =>
|
|
557
|
+
checked: S.value,
|
|
558
|
+
"onUpdate:checked": n[1] ||= (e) => S.value = e,
|
|
477
559
|
value: "light",
|
|
478
560
|
label: p(a).light,
|
|
479
561
|
"aria-label": `${p(a).light} mode`
|
|
@@ -483,8 +565,8 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
483
565
|
"aria-label"
|
|
484
566
|
]),
|
|
485
567
|
i(p(_), {
|
|
486
|
-
checked:
|
|
487
|
-
"onUpdate:checked": n[2] ||= (e) =>
|
|
568
|
+
checked: S.value,
|
|
569
|
+
"onUpdate:checked": n[2] ||= (e) => S.value = e,
|
|
488
570
|
value: "dark",
|
|
489
571
|
label: p(a).dark,
|
|
490
572
|
"aria-label": `${p(a).dark} mode`
|
|
@@ -499,8 +581,75 @@ var M = [], N = /* @__PURE__ */ new Set(), ee = "(prefers-color-scheme: dark)",
|
|
|
499
581
|
_: 1
|
|
500
582
|
}, 8, ["open"]));
|
|
501
583
|
}
|
|
502
|
-
}), [["__scopeId", "data-v-
|
|
584
|
+
}), [["__scopeId", "data-v-80f281b2"]]), ce = "(prefers-color-scheme: dark)", H = "#ffffff", U = "oklch(100% 0 250)", W = "#1f2228", G = "oklch(15% 0.0045 250)";
|
|
585
|
+
function K() {
|
|
586
|
+
return {
|
|
587
|
+
name: "gospore-theme-bootstrap",
|
|
588
|
+
enforce: "pre",
|
|
589
|
+
transformIndexHtml: {
|
|
590
|
+
order: "pre",
|
|
591
|
+
handler: () => [{
|
|
592
|
+
tag: "style",
|
|
593
|
+
children: J(),
|
|
594
|
+
injectTo: "head"
|
|
595
|
+
}, {
|
|
596
|
+
tag: "script",
|
|
597
|
+
children: q(),
|
|
598
|
+
injectTo: "head"
|
|
599
|
+
}]
|
|
600
|
+
}
|
|
601
|
+
};
|
|
602
|
+
}
|
|
603
|
+
function q() {
|
|
604
|
+
return `(() => {
|
|
605
|
+
const storageKey = ${JSON.stringify(b)};
|
|
606
|
+
const validModes = ${JSON.stringify(y)};
|
|
607
|
+
const encodedKey = encodeURIComponent(storageKey) + "=";
|
|
608
|
+
const storedCookie = document.cookie
|
|
609
|
+
.split("; ")
|
|
610
|
+
.find((entry) => entry.startsWith(encodedKey));
|
|
611
|
+
let mode = "auto";
|
|
612
|
+
|
|
613
|
+
if (storedCookie) {
|
|
614
|
+
try {
|
|
615
|
+
const storedMode = decodeURIComponent(storedCookie.slice(encodedKey.length));
|
|
616
|
+
if (validModes.includes(storedMode)) mode = storedMode;
|
|
617
|
+
} catch {}
|
|
618
|
+
}
|
|
619
|
+
|
|
620
|
+
let systemDark = false;
|
|
621
|
+
if (mode === "auto") {
|
|
622
|
+
try {
|
|
623
|
+
systemDark =
|
|
624
|
+
typeof window.matchMedia === "function" &&
|
|
625
|
+
window.matchMedia(${JSON.stringify(ce)}).matches;
|
|
626
|
+
} catch {}
|
|
627
|
+
}
|
|
628
|
+
|
|
629
|
+
document.documentElement.setAttribute(
|
|
630
|
+
"dark-mode",
|
|
631
|
+
String(mode === "dark" || (mode === "auto" && systemDark)),
|
|
632
|
+
);
|
|
633
|
+
})();`;
|
|
634
|
+
}
|
|
635
|
+
function J() {
|
|
636
|
+
return `html {
|
|
637
|
+
background-color: ${H};
|
|
638
|
+
background-color: ${U};
|
|
639
|
+
color-scheme: light;
|
|
640
|
+
}
|
|
641
|
+
|
|
642
|
+
html[dark-mode="true"] {
|
|
643
|
+
background-color: ${W};
|
|
644
|
+
background-color: ${G};
|
|
645
|
+
color-scheme: dark;
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
body {
|
|
649
|
+
background-color: inherit;
|
|
650
|
+
}`;
|
|
651
|
+
}
|
|
503
652
|
//#endregion
|
|
504
|
-
export {
|
|
653
|
+
export { b as STORAGE_KEY, B as Theme, V as ThemeSwitcher, y as VALID_THEME_MODES, E as applyStoredModeToDocument, K as createThemeBootstrapPlugin, C as readStoredMode, A as themePortalHostKey, ee as useThemePortalTarget, w as writeStoredMode };
|
|
505
654
|
|
|
506
655
|
//# sourceMappingURL=theme.es.js.map
|