musae 1.1.0 → 1.1.1-beta.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.
|
@@ -185,7 +185,7 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
185
185
|
});
|
|
186
186
|
});
|
|
187
187
|
// dark, light mode switch
|
|
188
|
-
var toggle = relax.useEvent(function (event) {
|
|
188
|
+
var toggle = relax.useEvent(function (event, options) {
|
|
189
189
|
var isDarking = mode === "light";
|
|
190
190
|
var nextMode = isDarking ? "dark" : "light";
|
|
191
191
|
// dom not support animation
|
|
@@ -199,7 +199,7 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
199
199
|
(_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(nextMode);
|
|
200
200
|
});
|
|
201
201
|
animation.ready.then(function () {
|
|
202
|
-
var _event$clientX, _event$clientY;
|
|
202
|
+
var _event$clientX, _event$clientY, _options$duration;
|
|
203
203
|
var x = (_event$clientX = event === null || event === void 0 ? void 0 : event.clientX) !== null && _event$clientX !== void 0 ? _event$clientX : 0;
|
|
204
204
|
var y = (_event$clientY = event === null || event === void 0 ? void 0 : event.clientY) !== null && _event$clientY !== void 0 ? _event$clientY : 0;
|
|
205
205
|
var radius = Math.hypot(Math.max(x, window.innerWidth - x), Math.max(y, window.innerHeight - y));
|
|
@@ -207,7 +207,7 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
207
207
|
document.documentElement.animate({
|
|
208
208
|
clipPath: isDarking ? clipPath : clipPath.toReversed()
|
|
209
209
|
}, {
|
|
210
|
-
duration: 300,
|
|
210
|
+
duration: (_options$duration = options === null || options === void 0 ? void 0 : options.duration) !== null && _options$duration !== void 0 ? _options$duration : 300,
|
|
211
211
|
easing: "ease-in",
|
|
212
212
|
fill: "forwards",
|
|
213
213
|
pseudoElement: isDarking ? "::view-transition-new(root)" : "::view-transition-old(root)"
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MouseEvent } from "react";
|
|
2
|
-
import type { Palette, ContextValue, Theme, Mode } from "../../types/theme";
|
|
2
|
+
import type { Palette, ContextValue, Theme, Mode, ToggleOptions } from "../../types/theme";
|
|
3
3
|
export declare const PALETTE: Readonly<Palette>;
|
|
4
4
|
/**
|
|
5
5
|
* @description
|
|
@@ -26,6 +26,6 @@ export declare const useSwitchable: ({ theme, defaultMode, }: {
|
|
|
26
26
|
defaultMode?: Mode;
|
|
27
27
|
}) => {
|
|
28
28
|
mode: Mode;
|
|
29
|
-
toggle: (event?: MouseEvent) => Mode;
|
|
29
|
+
toggle: (event?: MouseEvent, options?: ToggleOptions) => Mode;
|
|
30
30
|
colors: Record<import("../../utils/color-role").ColorRole, string>;
|
|
31
31
|
};
|
|
@@ -183,7 +183,7 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
183
183
|
});
|
|
184
184
|
});
|
|
185
185
|
// dark, light mode switch
|
|
186
|
-
var toggle = useEvent(function (event) {
|
|
186
|
+
var toggle = useEvent(function (event, options) {
|
|
187
187
|
var isDarking = mode === "light";
|
|
188
188
|
var nextMode = isDarking ? "dark" : "light";
|
|
189
189
|
// dom not support animation
|
|
@@ -197,7 +197,7 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
197
197
|
(_trigger$current2 = trigger.current) === null || _trigger$current2 === void 0 || _trigger$current2.next(nextMode);
|
|
198
198
|
});
|
|
199
199
|
animation.ready.then(function () {
|
|
200
|
-
var _event$clientX, _event$clientY;
|
|
200
|
+
var _event$clientX, _event$clientY, _options$duration;
|
|
201
201
|
var x = (_event$clientX = event === null || event === void 0 ? void 0 : event.clientX) !== null && _event$clientX !== void 0 ? _event$clientX : 0;
|
|
202
202
|
var y = (_event$clientY = event === null || event === void 0 ? void 0 : event.clientY) !== null && _event$clientY !== void 0 ? _event$clientY : 0;
|
|
203
203
|
var radius = Math.hypot(Math.max(x, window.innerWidth - x), Math.max(y, window.innerHeight - y));
|
|
@@ -205,7 +205,7 @@ var useSwitchable = function useSwitchable(_ref) {
|
|
|
205
205
|
document.documentElement.animate({
|
|
206
206
|
clipPath: isDarking ? clipPath : clipPath.toReversed()
|
|
207
207
|
}, {
|
|
208
|
-
duration: 300,
|
|
208
|
+
duration: (_options$duration = options === null || options === void 0 ? void 0 : options.duration) !== null && _options$duration !== void 0 ? _options$duration : 300,
|
|
209
209
|
easing: "ease-in",
|
|
210
210
|
fill: "forwards",
|
|
211
211
|
pseudoElement: isDarking ? "::view-transition-new(root)" : "::view-transition-old(root)"
|
package/dist/types/theme.d.ts
CHANGED
|
@@ -44,6 +44,17 @@ declare enum ColorProperty {
|
|
|
44
44
|
* palette
|
|
45
45
|
*/
|
|
46
46
|
export type Palette = Record<Exclude<ColorProperty, ColorProperty.Success | ColorProperty.Warning>, Record<0 | 10 | 20 | 30 | 40 | 50 | 60 | 70 | 80 | 90 | 95 | 99 | 100, string>> & Record<ColorProperty.Success | ColorProperty.Warning, Record<0 | 100, string>>;
|
|
47
|
+
/**
|
|
48
|
+
* @zh 主题切换选项
|
|
49
|
+
* @en theme toggle options
|
|
50
|
+
*/
|
|
51
|
+
export interface ToggleOptions {
|
|
52
|
+
/**
|
|
53
|
+
* @zh 动画持续时间(毫秒),默认 300
|
|
54
|
+
* @en animation duration in milliseconds, defaults to 300
|
|
55
|
+
*/
|
|
56
|
+
duration?: number;
|
|
57
|
+
}
|
|
47
58
|
/**
|
|
48
59
|
* @author murukal
|
|
49
60
|
*
|
|
@@ -67,6 +78,6 @@ export interface ContextValue {
|
|
|
67
78
|
* @zh 切换主题模式,返回更新后的模式
|
|
68
79
|
* @en toggle theme mode, returns the updated mode
|
|
69
80
|
*/
|
|
70
|
-
toggle: (event?: MouseEvent) => Mode;
|
|
81
|
+
toggle: (event?: MouseEvent, options?: ToggleOptions) => Mode;
|
|
71
82
|
}
|
|
72
83
|
export {};
|