uitheme-web 1.1.0 → 1.2.0
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 +149 -36
- package/dist/chunk-DFJEYTIW.js +12 -0
- package/dist/chunk-V3LMT5IJ.cjs +12 -0
- package/dist/chunk-W4YFUPGE.cjs +18 -0
- package/dist/chunk-WFG34KG5.js +18 -0
- package/dist/cli/index.js +22 -294
- package/dist/constants-DmZ7yAIL.d.cts +145 -0
- package/dist/constants-DmZ7yAIL.d.ts +145 -0
- package/dist/core/index.cjs +1 -270
- package/dist/core/index.d.cts +7 -3
- package/dist/core/index.d.ts +7 -3
- package/dist/core/index.js +1 -246
- package/dist/logo-DtwtRv4y.d.cts +4 -0
- package/dist/logo-DtwtRv4y.d.ts +4 -0
- package/dist/react/index.cjs +33 -1701
- package/dist/react/index.d.cts +78 -182
- package/dist/react/index.d.ts +78 -182
- package/dist/react/index.js +33 -1640
- package/dist/tanstack/index.cjs +1 -30
- package/dist/tanstack/index.d.cts +2 -2
- package/dist/tanstack/index.d.ts +2 -2
- package/dist/tanstack/index.js +1 -25
- package/package.json +18 -14
- package/dist/constants-n21pnuRC.d.cts +0 -106
- package/dist/constants-n21pnuRC.d.ts +0 -106
package/dist/core/index.cjs
CHANGED
|
@@ -1,270 +1 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
// src/core/types.ts
|
|
4
|
-
var ThemeAnimationType = /* @__PURE__ */ ((ThemeAnimationType2) => {
|
|
5
|
-
ThemeAnimationType2["CIRCLE"] = "circle";
|
|
6
|
-
ThemeAnimationType2["BLUR_CIRCLE"] = "blur-circle";
|
|
7
|
-
ThemeAnimationType2["SLIDE"] = "slide";
|
|
8
|
-
return ThemeAnimationType2;
|
|
9
|
-
})(ThemeAnimationType || {});
|
|
10
|
-
|
|
11
|
-
// src/core/constants.ts
|
|
12
|
-
var STORAGE_KEY = "theme";
|
|
13
|
-
var COLOR_STORAGE_KEY = "color-theme";
|
|
14
|
-
var GLOBAL_CLASS_NAME = "dark";
|
|
15
|
-
var COLOR_THEME_PREFIX = "theme-";
|
|
16
|
-
var DEFAULT_DURATION = 750;
|
|
17
|
-
var DEFAULT_EASING = "ease-in-out";
|
|
18
|
-
var DEFAULT_BLUR_AMOUNT = 2;
|
|
19
|
-
var DEFAULT_STYLE_ID = "ui-theme-style";
|
|
20
|
-
|
|
21
|
-
// src/core/animations.ts
|
|
22
|
-
var isBrowser = typeof window !== "undefined";
|
|
23
|
-
var getIsHighResolution = () => {
|
|
24
|
-
if (!isBrowser) return false;
|
|
25
|
-
return window.innerWidth >= 3e3 || window.innerHeight >= 2e3;
|
|
26
|
-
};
|
|
27
|
-
var injectBaseStyles = () => {
|
|
28
|
-
if (!isBrowser) return;
|
|
29
|
-
const styleId = "ui-theme-base-style";
|
|
30
|
-
if (document.getElementById(styleId)) return;
|
|
31
|
-
const style = document.createElement("style");
|
|
32
|
-
style.id = styleId;
|
|
33
|
-
const isHighResolution = getIsHighResolution();
|
|
34
|
-
style.textContent = `
|
|
35
|
-
::view-transition-old(root),
|
|
36
|
-
::view-transition-new(root) {
|
|
37
|
-
animation: none;
|
|
38
|
-
mix-blend-mode: normal;
|
|
39
|
-
${isHighResolution ? "transform: translateZ(0);" : ""}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
${isHighResolution ? `
|
|
43
|
-
::view-transition-group(root),
|
|
44
|
-
::view-transition-image-pair(root),
|
|
45
|
-
::view-transition-old(root),
|
|
46
|
-
::view-transition-new(root) {
|
|
47
|
-
backface-visibility: hidden;
|
|
48
|
-
perspective: 1000px;
|
|
49
|
-
transform: translate3d(0, 0, 0);
|
|
50
|
-
}
|
|
51
|
-
` : ""}
|
|
52
|
-
`;
|
|
53
|
-
document.head.appendChild(style);
|
|
54
|
-
};
|
|
55
|
-
var createBlurCircleMask = (blur) => {
|
|
56
|
-
const isHighResolution = getIsHighResolution();
|
|
57
|
-
const blurFilter = `<filter id="blur"><feGaussianBlur stdDeviation="${blur}" /></filter>`;
|
|
58
|
-
const circleRadius = isHighResolution ? 20 : 25;
|
|
59
|
-
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${blurFilter}</defs><circle cx="0" cy="0" r="${circleRadius}" fill="white" filter="url(%23blur)"/></svg>')`;
|
|
60
|
-
};
|
|
61
|
-
var getSystemTheme = () => {
|
|
62
|
-
if (!isBrowser) return "light";
|
|
63
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
64
|
-
};
|
|
65
|
-
var resolveTheme = (theme) => {
|
|
66
|
-
if (theme === "system") {
|
|
67
|
-
return getSystemTheme();
|
|
68
|
-
}
|
|
69
|
-
return theme === "dark" ? "dark" : "light";
|
|
70
|
-
};
|
|
71
|
-
var supportsViewTransitions = () => {
|
|
72
|
-
return isBrowser && "startViewTransition" in document;
|
|
73
|
-
};
|
|
74
|
-
var prefersReducedMotion = () => {
|
|
75
|
-
return isBrowser && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
76
|
-
};
|
|
77
|
-
var getSlideFromCoords = (direction) => {
|
|
78
|
-
switch (direction) {
|
|
79
|
-
case "left":
|
|
80
|
-
return { a: -100, b: 0 };
|
|
81
|
-
case "right":
|
|
82
|
-
return { a: 100, b: 0 };
|
|
83
|
-
case "top":
|
|
84
|
-
return { a: 0, b: -100 };
|
|
85
|
-
case "bottom":
|
|
86
|
-
return { a: 0, b: 100 };
|
|
87
|
-
case "top-left":
|
|
88
|
-
return { a: -100, b: -100 };
|
|
89
|
-
case "top-right":
|
|
90
|
-
return { a: 100, b: -100 };
|
|
91
|
-
case "bottom-left":
|
|
92
|
-
return { a: -100, b: 100 };
|
|
93
|
-
case "bottom-right":
|
|
94
|
-
return { a: 100, b: 100 };
|
|
95
|
-
default:
|
|
96
|
-
return { a: -100, b: 0 };
|
|
97
|
-
}
|
|
98
|
-
};
|
|
99
|
-
var createCircleAnimation = (config) => {
|
|
100
|
-
const { x, y, duration, easing } = config;
|
|
101
|
-
const topLeft = Math.hypot(x, y);
|
|
102
|
-
const topRight = Math.hypot(window.innerWidth - x, y);
|
|
103
|
-
const bottomLeft = Math.hypot(x, window.innerHeight - y);
|
|
104
|
-
const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y);
|
|
105
|
-
const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
|
106
|
-
document.documentElement.animate(
|
|
107
|
-
{
|
|
108
|
-
clipPath: [
|
|
109
|
-
`circle(0px at ${x}px ${y}px)`,
|
|
110
|
-
`circle(${maxRadius}px at ${x}px ${y}px)`
|
|
111
|
-
]
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
duration,
|
|
115
|
-
easing,
|
|
116
|
-
pseudoElement: "::view-transition-new(root)"
|
|
117
|
-
}
|
|
118
|
-
);
|
|
119
|
-
};
|
|
120
|
-
var createSlideAnimation = (config) => {
|
|
121
|
-
const {
|
|
122
|
-
a = -100,
|
|
123
|
-
b = 0,
|
|
124
|
-
x = 0,
|
|
125
|
-
y = 0,
|
|
126
|
-
duration,
|
|
127
|
-
styleId = DEFAULT_STYLE_ID
|
|
128
|
-
} = config;
|
|
129
|
-
const styleElement = document.createElement("style");
|
|
130
|
-
styleElement.id = styleId;
|
|
131
|
-
styleElement.textContent = `
|
|
132
|
-
::view-transition-old(root) {
|
|
133
|
-
animation-delay: ${duration}ms;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
::view-transition-new(root) {
|
|
137
|
-
animation: move-in ${duration}ms;
|
|
138
|
-
animation-timing-function: cubic-bezier(0.66, 0, 0.34, 1);
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
@keyframes move-in {
|
|
142
|
-
from {
|
|
143
|
-
translate: ${a}% ${b}%;
|
|
144
|
-
}
|
|
145
|
-
to {
|
|
146
|
-
translate: ${x}% ${y}%;
|
|
147
|
-
}
|
|
148
|
-
}
|
|
149
|
-
`;
|
|
150
|
-
document.head.appendChild(styleElement);
|
|
151
|
-
setTimeout(() => {
|
|
152
|
-
const el = document.getElementById(styleId);
|
|
153
|
-
if (el) {
|
|
154
|
-
el.remove();
|
|
155
|
-
}
|
|
156
|
-
}, duration);
|
|
157
|
-
};
|
|
158
|
-
var createBlurCircleAnimation = (config) => {
|
|
159
|
-
const {
|
|
160
|
-
x,
|
|
161
|
-
y,
|
|
162
|
-
duration,
|
|
163
|
-
easing,
|
|
164
|
-
blurAmount,
|
|
165
|
-
styleId = DEFAULT_STYLE_ID
|
|
166
|
-
} = config;
|
|
167
|
-
const existingStyle = document.getElementById(styleId);
|
|
168
|
-
if (existingStyle) {
|
|
169
|
-
existingStyle.remove();
|
|
170
|
-
}
|
|
171
|
-
const isHighResolution = getIsHighResolution();
|
|
172
|
-
const viewportSize = Math.max(window.innerWidth, window.innerHeight) + 200;
|
|
173
|
-
const scaleFactor = isHighResolution ? 2.5 : 4;
|
|
174
|
-
const optimalMaskSize = isHighResolution ? Math.min(viewportSize * scaleFactor, 5e3) : viewportSize * scaleFactor;
|
|
175
|
-
const topLeft = Math.hypot(x, y);
|
|
176
|
-
const topRight = Math.hypot(window.innerWidth - x, y);
|
|
177
|
-
const bottomLeft = Math.hypot(x, window.innerHeight - y);
|
|
178
|
-
const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y);
|
|
179
|
-
const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
|
180
|
-
const styleElement = document.createElement("style");
|
|
181
|
-
styleElement.id = styleId;
|
|
182
|
-
const blurFactor = isHighResolution ? 1.5 : 1.2;
|
|
183
|
-
const finalMaskSize = Math.max(optimalMaskSize, maxRadius * 2.5);
|
|
184
|
-
styleElement.textContent = `
|
|
185
|
-
::view-transition-group(root) {
|
|
186
|
-
animation-duration: ${duration}ms;
|
|
187
|
-
animation-timing-function: ${isHighResolution ? "cubic-bezier(0.2, 0, 0.2, 1)" : "linear(0 0%, 0.2342 12.49%, 0.4374 24.99%,0.6093 37.49%, 0.6835 43.74%,0.7499 49.99%, 0.8086 56.25%,0.8593 62.5%, 0.9023 68.75%, 0.9375 75%,0.9648 81.25%, 0.9844 87.5%,0.9961 93.75%, 1 100%)"};
|
|
188
|
-
will-change: transform;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
::view-transition-new(root) {
|
|
192
|
-
mask: ${createBlurCircleMask(blurAmount * blurFactor)} 0 0 / 100% 100% no-repeat;
|
|
193
|
-
mask-position: ${x}px ${y}px;
|
|
194
|
-
animation: ui-theme-mask-scale ${duration}ms ${easing};
|
|
195
|
-
transform-origin: ${x}px ${y}px;
|
|
196
|
-
will-change: mask-size, mask-position;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
::view-transition-old(root),
|
|
200
|
-
.dark::view-transition-old(root) {
|
|
201
|
-
animation: ui-theme-mask-scale ${duration}ms ${easing};
|
|
202
|
-
transform-origin: ${x}px ${y}px;
|
|
203
|
-
z-index: -1;
|
|
204
|
-
will-change: mask-size, mask-position;
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
@keyframes ui-theme-mask-scale {
|
|
208
|
-
0% {
|
|
209
|
-
mask-size: 0px;
|
|
210
|
-
mask-position: ${x}px ${y}px;
|
|
211
|
-
}
|
|
212
|
-
100% {
|
|
213
|
-
mask-size: ${finalMaskSize}px;
|
|
214
|
-
mask-position: ${x - finalMaskSize / 2}px ${y - finalMaskSize / 2}px;
|
|
215
|
-
}
|
|
216
|
-
}
|
|
217
|
-
`;
|
|
218
|
-
document.head.appendChild(styleElement);
|
|
219
|
-
setTimeout(() => {
|
|
220
|
-
const el = document.getElementById(styleId);
|
|
221
|
-
if (el) {
|
|
222
|
-
el.remove();
|
|
223
|
-
}
|
|
224
|
-
}, duration);
|
|
225
|
-
};
|
|
226
|
-
|
|
227
|
-
// src/core/storage.ts
|
|
228
|
-
var isBrowser2 = typeof window !== "undefined";
|
|
229
|
-
var getStoredTheme = (key = STORAGE_KEY, validThemes = ["light", "dark", "system"], defaultTheme = "system") => {
|
|
230
|
-
if (!isBrowser2) return defaultTheme;
|
|
231
|
-
const saved = localStorage.getItem(key);
|
|
232
|
-
return saved && validThemes.includes(saved) ? saved : defaultTheme;
|
|
233
|
-
};
|
|
234
|
-
var setStoredTheme = (theme, key = STORAGE_KEY) => {
|
|
235
|
-
if (!isBrowser2) return;
|
|
236
|
-
localStorage.setItem(key, theme);
|
|
237
|
-
};
|
|
238
|
-
var getStoredColorTheme = (key = COLOR_STORAGE_KEY, validColorThemes = ["default"], defaultColorTheme = "default") => {
|
|
239
|
-
if (!isBrowser2) return defaultColorTheme;
|
|
240
|
-
const saved = localStorage.getItem(key);
|
|
241
|
-
return saved && validColorThemes.includes(saved) ? saved : defaultColorTheme;
|
|
242
|
-
};
|
|
243
|
-
var setStoredColorTheme = (colorTheme, key = COLOR_STORAGE_KEY) => {
|
|
244
|
-
if (!isBrowser2) return;
|
|
245
|
-
localStorage.setItem(key, colorTheme);
|
|
246
|
-
};
|
|
247
|
-
|
|
248
|
-
exports.COLOR_STORAGE_KEY = COLOR_STORAGE_KEY;
|
|
249
|
-
exports.COLOR_THEME_PREFIX = COLOR_THEME_PREFIX;
|
|
250
|
-
exports.DEFAULT_BLUR_AMOUNT = DEFAULT_BLUR_AMOUNT;
|
|
251
|
-
exports.DEFAULT_DURATION = DEFAULT_DURATION;
|
|
252
|
-
exports.DEFAULT_EASING = DEFAULT_EASING;
|
|
253
|
-
exports.DEFAULT_STYLE_ID = DEFAULT_STYLE_ID;
|
|
254
|
-
exports.GLOBAL_CLASS_NAME = GLOBAL_CLASS_NAME;
|
|
255
|
-
exports.STORAGE_KEY = STORAGE_KEY;
|
|
256
|
-
exports.ThemeAnimationType = ThemeAnimationType;
|
|
257
|
-
exports.createBlurCircleAnimation = createBlurCircleAnimation;
|
|
258
|
-
exports.createBlurCircleMask = createBlurCircleMask;
|
|
259
|
-
exports.createCircleAnimation = createCircleAnimation;
|
|
260
|
-
exports.createSlideAnimation = createSlideAnimation;
|
|
261
|
-
exports.getSlideFromCoords = getSlideFromCoords;
|
|
262
|
-
exports.getStoredColorTheme = getStoredColorTheme;
|
|
263
|
-
exports.getStoredTheme = getStoredTheme;
|
|
264
|
-
exports.getSystemTheme = getSystemTheme;
|
|
265
|
-
exports.injectBaseStyles = injectBaseStyles;
|
|
266
|
-
exports.prefersReducedMotion = prefersReducedMotion;
|
|
267
|
-
exports.resolveTheme = resolveTheme;
|
|
268
|
-
exports.setStoredColorTheme = setStoredColorTheme;
|
|
269
|
-
exports.setStoredTheme = setStoredTheme;
|
|
270
|
-
exports.supportsViewTransitions = supportsViewTransitions;
|
|
1
|
+
'use strict';var chunkV3LMT5IJ_cjs=require('../chunk-V3LMT5IJ.cjs'),chunkW4YFUPGE_cjs=require('../chunk-W4YFUPGE.cjs');Object.defineProperty(exports,"TRANSITION_DIRECTIONS",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.b}});Object.defineProperty(exports,"ThemeAnimationType",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.a}});Object.defineProperty(exports,"getStoredColorTheme",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.h}});Object.defineProperty(exports,"getStoredTheme",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.f}});Object.defineProperty(exports,"preloadThemeLogo",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.d}});Object.defineProperty(exports,"runThemeTransition",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.e}});Object.defineProperty(exports,"setStoredColorTheme",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.i}});Object.defineProperty(exports,"setStoredTheme",{enumerable:true,get:function(){return chunkV3LMT5IJ_cjs.g}});Object.defineProperty(exports,"COLOR_STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.r}});Object.defineProperty(exports,"COLOR_THEME_PREFIX",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.t}});Object.defineProperty(exports,"DEFAULT_BLUR_AMOUNT",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.w}});Object.defineProperty(exports,"DEFAULT_DURATION",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.u}});Object.defineProperty(exports,"DEFAULT_EASING",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.v}});Object.defineProperty(exports,"DEFAULT_STYLE_ID",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.x}});Object.defineProperty(exports,"GLOBAL_CLASS_NAME",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.s}});Object.defineProperty(exports,"STORAGE_KEY",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.q}});Object.defineProperty(exports,"createBlurCircleAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.p}});Object.defineProperty(exports,"createBlurCircleMask",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.b}});Object.defineProperty(exports,"createCircleAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.n}});Object.defineProperty(exports,"createClipPathAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.j}});Object.defineProperty(exports,"createPolygonGradientAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.k}});Object.defineProperty(exports,"createSlideAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.o}});Object.defineProperty(exports,"createSvgLogoAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.m}});Object.defineProperty(exports,"createTriangleAnimation",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.l}});Object.defineProperty(exports,"getAnimationPosition",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.i}});Object.defineProperty(exports,"getSlideFromCoords",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.h}});Object.defineProperty(exports,"getSystemTheme",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.c}});Object.defineProperty(exports,"injectBaseStyles",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.a}});Object.defineProperty(exports,"prefersReducedMotion",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.g}});Object.defineProperty(exports,"resolveTheme",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.d}});Object.defineProperty(exports,"supportsViewTransitions",{enumerable:true,get:function(){return chunkW4YFUPGE_cjs.f}});
|
package/dist/core/index.d.cts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { A as AnimationConfig, C as ColorTheme, T as Theme } from '../constants-DmZ7yAIL.cjs';
|
|
2
|
+
export { a as AnimationPosition, b as COLOR_STORAGE_KEY, c as COLOR_THEME_PREFIX, D as DEFAULT_BLUR_AMOUNT, d as DEFAULT_DURATION, e as DEFAULT_EASING, f as DEFAULT_STYLE_ID, G as GLOBAL_CLASS_NAME, S as STORAGE_KEY, g as SlideDirection, h as TRANSITION_DIRECTIONS, i as ThemeAnimationOptions, j as ThemeAnimationType, k as ThemeConfig, l as ThemeLogoOptions, m as ThemeState, n as TransitionDirection, o as createBlurCircleAnimation, p as createBlurCircleMask, q as createCircleAnimation, r as createClipPathAnimation, s as createPolygonGradientAnimation, t as createSlideAnimation, u as createSvgLogoAnimation, v as createTriangleAnimation, w as getAnimationPosition, x as getSlideFromCoords, y as getSystemTheme, z as injectBaseStyles, B as prefersReducedMotion, E as resolveTheme, F as supportsViewTransitions } from '../constants-DmZ7yAIL.cjs';
|
|
3
|
+
export { p as preloadThemeLogo } from '../logo-DtwtRv4y.cjs';
|
|
4
|
+
|
|
5
|
+
/** Latest request wins visually; every requested state update still runs once. */
|
|
6
|
+
declare const runThemeTransition: (update: () => void, config: AnimationConfig | null) => Promise<void>;
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* Gets the stored theme from localStorage
|
|
@@ -30,4 +34,4 @@ declare const getStoredColorTheme: (key?: string, validColorThemes?: ColorTheme[
|
|
|
30
34
|
*/
|
|
31
35
|
declare const setStoredColorTheme: (colorTheme: ColorTheme, key?: string) => void;
|
|
32
36
|
|
|
33
|
-
export { ColorTheme, Theme, getStoredColorTheme, getStoredTheme, setStoredColorTheme, setStoredTheme };
|
|
37
|
+
export { AnimationConfig, ColorTheme, Theme, getStoredColorTheme, getStoredTheme, runThemeTransition, setStoredColorTheme, setStoredTheme };
|
package/dist/core/index.d.ts
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export {
|
|
1
|
+
import { A as AnimationConfig, C as ColorTheme, T as Theme } from '../constants-DmZ7yAIL.js';
|
|
2
|
+
export { a as AnimationPosition, b as COLOR_STORAGE_KEY, c as COLOR_THEME_PREFIX, D as DEFAULT_BLUR_AMOUNT, d as DEFAULT_DURATION, e as DEFAULT_EASING, f as DEFAULT_STYLE_ID, G as GLOBAL_CLASS_NAME, S as STORAGE_KEY, g as SlideDirection, h as TRANSITION_DIRECTIONS, i as ThemeAnimationOptions, j as ThemeAnimationType, k as ThemeConfig, l as ThemeLogoOptions, m as ThemeState, n as TransitionDirection, o as createBlurCircleAnimation, p as createBlurCircleMask, q as createCircleAnimation, r as createClipPathAnimation, s as createPolygonGradientAnimation, t as createSlideAnimation, u as createSvgLogoAnimation, v as createTriangleAnimation, w as getAnimationPosition, x as getSlideFromCoords, y as getSystemTheme, z as injectBaseStyles, B as prefersReducedMotion, E as resolveTheme, F as supportsViewTransitions } from '../constants-DmZ7yAIL.js';
|
|
3
|
+
export { p as preloadThemeLogo } from '../logo-DtwtRv4y.js';
|
|
4
|
+
|
|
5
|
+
/** Latest request wins visually; every requested state update still runs once. */
|
|
6
|
+
declare const runThemeTransition: (update: () => void, config: AnimationConfig | null) => Promise<void>;
|
|
3
7
|
|
|
4
8
|
/**
|
|
5
9
|
* Gets the stored theme from localStorage
|
|
@@ -30,4 +34,4 @@ declare const getStoredColorTheme: (key?: string, validColorThemes?: ColorTheme[
|
|
|
30
34
|
*/
|
|
31
35
|
declare const setStoredColorTheme: (colorTheme: ColorTheme, key?: string) => void;
|
|
32
36
|
|
|
33
|
-
export { ColorTheme, Theme, getStoredColorTheme, getStoredTheme, setStoredColorTheme, setStoredTheme };
|
|
37
|
+
export { AnimationConfig, ColorTheme, Theme, getStoredColorTheme, getStoredTheme, runThemeTransition, setStoredColorTheme, setStoredTheme };
|
package/dist/core/index.js
CHANGED
|
@@ -1,246 +1 @@
|
|
|
1
|
-
|
|
2
|
-
var ThemeAnimationType = /* @__PURE__ */ ((ThemeAnimationType2) => {
|
|
3
|
-
ThemeAnimationType2["CIRCLE"] = "circle";
|
|
4
|
-
ThemeAnimationType2["BLUR_CIRCLE"] = "blur-circle";
|
|
5
|
-
ThemeAnimationType2["SLIDE"] = "slide";
|
|
6
|
-
return ThemeAnimationType2;
|
|
7
|
-
})(ThemeAnimationType || {});
|
|
8
|
-
|
|
9
|
-
// src/core/constants.ts
|
|
10
|
-
var STORAGE_KEY = "theme";
|
|
11
|
-
var COLOR_STORAGE_KEY = "color-theme";
|
|
12
|
-
var GLOBAL_CLASS_NAME = "dark";
|
|
13
|
-
var COLOR_THEME_PREFIX = "theme-";
|
|
14
|
-
var DEFAULT_DURATION = 750;
|
|
15
|
-
var DEFAULT_EASING = "ease-in-out";
|
|
16
|
-
var DEFAULT_BLUR_AMOUNT = 2;
|
|
17
|
-
var DEFAULT_STYLE_ID = "ui-theme-style";
|
|
18
|
-
|
|
19
|
-
// src/core/animations.ts
|
|
20
|
-
var isBrowser = typeof window !== "undefined";
|
|
21
|
-
var getIsHighResolution = () => {
|
|
22
|
-
if (!isBrowser) return false;
|
|
23
|
-
return window.innerWidth >= 3e3 || window.innerHeight >= 2e3;
|
|
24
|
-
};
|
|
25
|
-
var injectBaseStyles = () => {
|
|
26
|
-
if (!isBrowser) return;
|
|
27
|
-
const styleId = "ui-theme-base-style";
|
|
28
|
-
if (document.getElementById(styleId)) return;
|
|
29
|
-
const style = document.createElement("style");
|
|
30
|
-
style.id = styleId;
|
|
31
|
-
const isHighResolution = getIsHighResolution();
|
|
32
|
-
style.textContent = `
|
|
33
|
-
::view-transition-old(root),
|
|
34
|
-
::view-transition-new(root) {
|
|
35
|
-
animation: none;
|
|
36
|
-
mix-blend-mode: normal;
|
|
37
|
-
${isHighResolution ? "transform: translateZ(0);" : ""}
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
${isHighResolution ? `
|
|
41
|
-
::view-transition-group(root),
|
|
42
|
-
::view-transition-image-pair(root),
|
|
43
|
-
::view-transition-old(root),
|
|
44
|
-
::view-transition-new(root) {
|
|
45
|
-
backface-visibility: hidden;
|
|
46
|
-
perspective: 1000px;
|
|
47
|
-
transform: translate3d(0, 0, 0);
|
|
48
|
-
}
|
|
49
|
-
` : ""}
|
|
50
|
-
`;
|
|
51
|
-
document.head.appendChild(style);
|
|
52
|
-
};
|
|
53
|
-
var createBlurCircleMask = (blur) => {
|
|
54
|
-
const isHighResolution = getIsHighResolution();
|
|
55
|
-
const blurFilter = `<filter id="blur"><feGaussianBlur stdDeviation="${blur}" /></filter>`;
|
|
56
|
-
const circleRadius = isHighResolution ? 20 : 25;
|
|
57
|
-
return `url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="-50 -50 100 100"><defs>${blurFilter}</defs><circle cx="0" cy="0" r="${circleRadius}" fill="white" filter="url(%23blur)"/></svg>')`;
|
|
58
|
-
};
|
|
59
|
-
var getSystemTheme = () => {
|
|
60
|
-
if (!isBrowser) return "light";
|
|
61
|
-
return window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
|
|
62
|
-
};
|
|
63
|
-
var resolveTheme = (theme) => {
|
|
64
|
-
if (theme === "system") {
|
|
65
|
-
return getSystemTheme();
|
|
66
|
-
}
|
|
67
|
-
return theme === "dark" ? "dark" : "light";
|
|
68
|
-
};
|
|
69
|
-
var supportsViewTransitions = () => {
|
|
70
|
-
return isBrowser && "startViewTransition" in document;
|
|
71
|
-
};
|
|
72
|
-
var prefersReducedMotion = () => {
|
|
73
|
-
return isBrowser && window.matchMedia("(prefers-reduced-motion: reduce)").matches;
|
|
74
|
-
};
|
|
75
|
-
var getSlideFromCoords = (direction) => {
|
|
76
|
-
switch (direction) {
|
|
77
|
-
case "left":
|
|
78
|
-
return { a: -100, b: 0 };
|
|
79
|
-
case "right":
|
|
80
|
-
return { a: 100, b: 0 };
|
|
81
|
-
case "top":
|
|
82
|
-
return { a: 0, b: -100 };
|
|
83
|
-
case "bottom":
|
|
84
|
-
return { a: 0, b: 100 };
|
|
85
|
-
case "top-left":
|
|
86
|
-
return { a: -100, b: -100 };
|
|
87
|
-
case "top-right":
|
|
88
|
-
return { a: 100, b: -100 };
|
|
89
|
-
case "bottom-left":
|
|
90
|
-
return { a: -100, b: 100 };
|
|
91
|
-
case "bottom-right":
|
|
92
|
-
return { a: 100, b: 100 };
|
|
93
|
-
default:
|
|
94
|
-
return { a: -100, b: 0 };
|
|
95
|
-
}
|
|
96
|
-
};
|
|
97
|
-
var createCircleAnimation = (config) => {
|
|
98
|
-
const { x, y, duration, easing } = config;
|
|
99
|
-
const topLeft = Math.hypot(x, y);
|
|
100
|
-
const topRight = Math.hypot(window.innerWidth - x, y);
|
|
101
|
-
const bottomLeft = Math.hypot(x, window.innerHeight - y);
|
|
102
|
-
const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y);
|
|
103
|
-
const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
|
104
|
-
document.documentElement.animate(
|
|
105
|
-
{
|
|
106
|
-
clipPath: [
|
|
107
|
-
`circle(0px at ${x}px ${y}px)`,
|
|
108
|
-
`circle(${maxRadius}px at ${x}px ${y}px)`
|
|
109
|
-
]
|
|
110
|
-
},
|
|
111
|
-
{
|
|
112
|
-
duration,
|
|
113
|
-
easing,
|
|
114
|
-
pseudoElement: "::view-transition-new(root)"
|
|
115
|
-
}
|
|
116
|
-
);
|
|
117
|
-
};
|
|
118
|
-
var createSlideAnimation = (config) => {
|
|
119
|
-
const {
|
|
120
|
-
a = -100,
|
|
121
|
-
b = 0,
|
|
122
|
-
x = 0,
|
|
123
|
-
y = 0,
|
|
124
|
-
duration,
|
|
125
|
-
styleId = DEFAULT_STYLE_ID
|
|
126
|
-
} = config;
|
|
127
|
-
const styleElement = document.createElement("style");
|
|
128
|
-
styleElement.id = styleId;
|
|
129
|
-
styleElement.textContent = `
|
|
130
|
-
::view-transition-old(root) {
|
|
131
|
-
animation-delay: ${duration}ms;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
::view-transition-new(root) {
|
|
135
|
-
animation: move-in ${duration}ms;
|
|
136
|
-
animation-timing-function: cubic-bezier(0.66, 0, 0.34, 1);
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
@keyframes move-in {
|
|
140
|
-
from {
|
|
141
|
-
translate: ${a}% ${b}%;
|
|
142
|
-
}
|
|
143
|
-
to {
|
|
144
|
-
translate: ${x}% ${y}%;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
`;
|
|
148
|
-
document.head.appendChild(styleElement);
|
|
149
|
-
setTimeout(() => {
|
|
150
|
-
const el = document.getElementById(styleId);
|
|
151
|
-
if (el) {
|
|
152
|
-
el.remove();
|
|
153
|
-
}
|
|
154
|
-
}, duration);
|
|
155
|
-
};
|
|
156
|
-
var createBlurCircleAnimation = (config) => {
|
|
157
|
-
const {
|
|
158
|
-
x,
|
|
159
|
-
y,
|
|
160
|
-
duration,
|
|
161
|
-
easing,
|
|
162
|
-
blurAmount,
|
|
163
|
-
styleId = DEFAULT_STYLE_ID
|
|
164
|
-
} = config;
|
|
165
|
-
const existingStyle = document.getElementById(styleId);
|
|
166
|
-
if (existingStyle) {
|
|
167
|
-
existingStyle.remove();
|
|
168
|
-
}
|
|
169
|
-
const isHighResolution = getIsHighResolution();
|
|
170
|
-
const viewportSize = Math.max(window.innerWidth, window.innerHeight) + 200;
|
|
171
|
-
const scaleFactor = isHighResolution ? 2.5 : 4;
|
|
172
|
-
const optimalMaskSize = isHighResolution ? Math.min(viewportSize * scaleFactor, 5e3) : viewportSize * scaleFactor;
|
|
173
|
-
const topLeft = Math.hypot(x, y);
|
|
174
|
-
const topRight = Math.hypot(window.innerWidth - x, y);
|
|
175
|
-
const bottomLeft = Math.hypot(x, window.innerHeight - y);
|
|
176
|
-
const bottomRight = Math.hypot(window.innerWidth - x, window.innerHeight - y);
|
|
177
|
-
const maxRadius = Math.max(topLeft, topRight, bottomLeft, bottomRight);
|
|
178
|
-
const styleElement = document.createElement("style");
|
|
179
|
-
styleElement.id = styleId;
|
|
180
|
-
const blurFactor = isHighResolution ? 1.5 : 1.2;
|
|
181
|
-
const finalMaskSize = Math.max(optimalMaskSize, maxRadius * 2.5);
|
|
182
|
-
styleElement.textContent = `
|
|
183
|
-
::view-transition-group(root) {
|
|
184
|
-
animation-duration: ${duration}ms;
|
|
185
|
-
animation-timing-function: ${isHighResolution ? "cubic-bezier(0.2, 0, 0.2, 1)" : "linear(0 0%, 0.2342 12.49%, 0.4374 24.99%,0.6093 37.49%, 0.6835 43.74%,0.7499 49.99%, 0.8086 56.25%,0.8593 62.5%, 0.9023 68.75%, 0.9375 75%,0.9648 81.25%, 0.9844 87.5%,0.9961 93.75%, 1 100%)"};
|
|
186
|
-
will-change: transform;
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
::view-transition-new(root) {
|
|
190
|
-
mask: ${createBlurCircleMask(blurAmount * blurFactor)} 0 0 / 100% 100% no-repeat;
|
|
191
|
-
mask-position: ${x}px ${y}px;
|
|
192
|
-
animation: ui-theme-mask-scale ${duration}ms ${easing};
|
|
193
|
-
transform-origin: ${x}px ${y}px;
|
|
194
|
-
will-change: mask-size, mask-position;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
::view-transition-old(root),
|
|
198
|
-
.dark::view-transition-old(root) {
|
|
199
|
-
animation: ui-theme-mask-scale ${duration}ms ${easing};
|
|
200
|
-
transform-origin: ${x}px ${y}px;
|
|
201
|
-
z-index: -1;
|
|
202
|
-
will-change: mask-size, mask-position;
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
@keyframes ui-theme-mask-scale {
|
|
206
|
-
0% {
|
|
207
|
-
mask-size: 0px;
|
|
208
|
-
mask-position: ${x}px ${y}px;
|
|
209
|
-
}
|
|
210
|
-
100% {
|
|
211
|
-
mask-size: ${finalMaskSize}px;
|
|
212
|
-
mask-position: ${x - finalMaskSize / 2}px ${y - finalMaskSize / 2}px;
|
|
213
|
-
}
|
|
214
|
-
}
|
|
215
|
-
`;
|
|
216
|
-
document.head.appendChild(styleElement);
|
|
217
|
-
setTimeout(() => {
|
|
218
|
-
const el = document.getElementById(styleId);
|
|
219
|
-
if (el) {
|
|
220
|
-
el.remove();
|
|
221
|
-
}
|
|
222
|
-
}, duration);
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
// src/core/storage.ts
|
|
226
|
-
var isBrowser2 = typeof window !== "undefined";
|
|
227
|
-
var getStoredTheme = (key = STORAGE_KEY, validThemes = ["light", "dark", "system"], defaultTheme = "system") => {
|
|
228
|
-
if (!isBrowser2) return defaultTheme;
|
|
229
|
-
const saved = localStorage.getItem(key);
|
|
230
|
-
return saved && validThemes.includes(saved) ? saved : defaultTheme;
|
|
231
|
-
};
|
|
232
|
-
var setStoredTheme = (theme, key = STORAGE_KEY) => {
|
|
233
|
-
if (!isBrowser2) return;
|
|
234
|
-
localStorage.setItem(key, theme);
|
|
235
|
-
};
|
|
236
|
-
var getStoredColorTheme = (key = COLOR_STORAGE_KEY, validColorThemes = ["default"], defaultColorTheme = "default") => {
|
|
237
|
-
if (!isBrowser2) return defaultColorTheme;
|
|
238
|
-
const saved = localStorage.getItem(key);
|
|
239
|
-
return saved && validColorThemes.includes(saved) ? saved : defaultColorTheme;
|
|
240
|
-
};
|
|
241
|
-
var setStoredColorTheme = (colorTheme, key = COLOR_STORAGE_KEY) => {
|
|
242
|
-
if (!isBrowser2) return;
|
|
243
|
-
localStorage.setItem(key, colorTheme);
|
|
244
|
-
};
|
|
245
|
-
|
|
246
|
-
export { COLOR_STORAGE_KEY, COLOR_THEME_PREFIX, DEFAULT_BLUR_AMOUNT, DEFAULT_DURATION, DEFAULT_EASING, DEFAULT_STYLE_ID, GLOBAL_CLASS_NAME, STORAGE_KEY, ThemeAnimationType, createBlurCircleAnimation, createBlurCircleMask, createCircleAnimation, createSlideAnimation, getSlideFromCoords, getStoredColorTheme, getStoredTheme, getSystemTheme, injectBaseStyles, prefersReducedMotion, resolveTheme, setStoredColorTheme, setStoredTheme, supportsViewTransitions };
|
|
1
|
+
export{b as TRANSITION_DIRECTIONS,a as ThemeAnimationType,h as getStoredColorTheme,f as getStoredTheme,d as preloadThemeLogo,e as runThemeTransition,i as setStoredColorTheme,g as setStoredTheme}from'../chunk-DFJEYTIW.js';export{r as COLOR_STORAGE_KEY,t as COLOR_THEME_PREFIX,w as DEFAULT_BLUR_AMOUNT,u as DEFAULT_DURATION,v as DEFAULT_EASING,x as DEFAULT_STYLE_ID,s as GLOBAL_CLASS_NAME,q as STORAGE_KEY,p as createBlurCircleAnimation,b as createBlurCircleMask,n as createCircleAnimation,j as createClipPathAnimation,k as createPolygonGradientAnimation,o as createSlideAnimation,m as createSvgLogoAnimation,l as createTriangleAnimation,i as getAnimationPosition,h as getSlideFromCoords,c as getSystemTheme,a as injectBaseStyles,g as prefersReducedMotion,d as resolveTheme,f as supportsViewTransitions}from'../chunk-WFG34KG5.js';
|