@widgetic/design-system 0.5.31 → 0.5.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.
- package/dist/components/EmptyState.svelte +5 -2
- package/dist/components/modals/ActionModal.svelte +10 -9
- package/dist/components/modals/README.md +1 -1
- package/dist/components/shell/SettingsDialog.svelte +53 -10
- package/dist/components/shell/WidgetRow.svelte +8 -1
- package/dist/components/shell/WidgetRow.svelte.d.ts +2 -0
- package/dist/components/toast/ToasterModal.svelte +54 -10
- package/dist/components/toast/ToasterModal.svelte.d.ts +6 -1
- package/dist/components/toast/toastDismissCountdown.d.ts +5 -0
- package/dist/components/toast/toastDismissCountdown.js +47 -0
- package/dist/components/toast/toastDismissCountdownPayload.d.ts +16 -0
- package/dist/components/toast/toastDismissCountdownPayload.js +24 -0
- package/dist/components/ui/dialog/DialogLayerSync.svelte +38 -0
- package/dist/components/ui/dialog/DialogLayerSync.svelte.d.ts +8 -0
- package/dist/components/ui/dialog/dialog-content.svelte +63 -20
- package/dist/components/ui/dialog/dialog-content.svelte.d.ts +1 -0
- package/dist/components/ui/dialog/dialog-overlay.svelte +24 -20
- package/dist/components/ui/dialog/overlay-layer-context.d.ts +8 -0
- package/dist/components/ui/dialog/overlay-layer-context.js +1 -0
- package/dist/components/ui/drawer/drawer-content.svelte +25 -1
- package/dist/components/ui/drawer/drawer-overlay.svelte +32 -5
- package/dist/components/ui/dropdown-menu/dropdown-menu-content.svelte +3 -1
- package/dist/components/ui/dropdown-menu/dropdown-menu-sub-content.svelte +3 -1
- package/dist/components/ui/hover-card/hover-card-content.svelte +3 -1
- package/dist/components/ui/popover/popover-content.svelte +3 -1
- package/dist/components/ui/select/select-content.svelte +3 -1
- package/dist/components/ui/tooltip/tooltip-content.svelte +3 -1
- package/dist/styles/global.css +33 -61
- package/dist/utils/overlayLayerStack.d.ts +54 -0
- package/dist/utils/overlayLayerStack.js +89 -0
- package/dist/utils/overlayMotion.d.ts +14 -46
- package/dist/utils/overlayMotion.js +36 -63
- package/package.json +1 -1
|
@@ -1,86 +1,59 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Shared overlay motion tokens so BaseModal, bits-ui Dialog, and related surfaces stay in sync.
|
|
3
|
-
* FilePreview / legacy modals: backdrop fades 200ms with cubicOut; the card scales from 0.95 with the same timing.
|
|
4
|
-
* Change here when Figma updates overlay motion.
|
|
5
3
|
*/
|
|
6
4
|
import { cubicOut } from 'svelte/easing';
|
|
7
|
-
/** Backdrop scrim + card motion duration (ms).
|
|
5
|
+
/** Backdrop scrim + card motion duration (ms). */
|
|
8
6
|
export const overlayTransitionDurationMs = 200;
|
|
9
|
-
/** Easing for open/close (Svelte transition easing function — matches “cubic out” in the legacy modals). */
|
|
10
7
|
export const overlayTransitionEasing = cubicOut;
|
|
11
|
-
/**
|
|
12
|
-
* Backdrop blur (px) of the scrim behind every modal, dialog, drawer and sheet. It is the Figma effect style
|
|
13
|
-
* `Overlay/Scrim blur` (a background blur of 3).
|
|
14
|
-
*/
|
|
15
8
|
export const overlayBackdropBlurPx = 3;
|
|
16
|
-
/** Content scale at the start of the open transition / end of the close transition. */
|
|
17
9
|
export const overlayContentScaleStart = 0.95;
|
|
18
|
-
/**
|
|
19
|
-
* Centred dialogs slide this many pixels up on open and down on close, with the same duration as the fade.
|
|
20
|
-
* Tailwind spacing step (5 → 20px with the design-system scale).
|
|
21
|
-
*/
|
|
22
10
|
export const overlayContentSlideDistance = 5;
|
|
23
|
-
/** Pixel slide distance for Svelte `fly` on centred modals (Tailwind spacing step 5 → 20px). */
|
|
24
11
|
export const overlayContentSlidePx = overlayContentSlideDistance * 4;
|
|
25
|
-
/** Tailwind slide utilities for centred dialog panels (not drawers/sheets that enter from the side). */
|
|
26
12
|
export const overlayDialogContentSlideClasses = [
|
|
27
13
|
`data-[state=closed]:slide-out-to-bottom-${overlayContentSlideDistance}`,
|
|
28
14
|
`data-[state=open]:slide-in-from-bottom-${overlayContentSlideDistance}`
|
|
29
15
|
];
|
|
30
|
-
/**
|
|
31
|
-
* Tailwind duration class — must be a source literal so Tailwind's scanner emits `duration-[200ms]`.
|
|
32
|
-
* Kept in sync with `overlayTransitionDurationMs` (see tests/overlayMotionDuration.test.ts).
|
|
33
|
-
*/
|
|
34
16
|
export const overlayDurationClass = 'duration-[200ms]';
|
|
35
|
-
/**
|
|
36
|
-
* bits-ui applies `data-[state=open]:animate-in` at specificity 0,2,0 with a 150ms default duration, which beats a
|
|
37
|
-
* plain `duration-[200ms]` (0,1,0). These state-scoped arbitrary properties match open/closed and win in cascade.
|
|
38
|
-
* Literal strings — keep in sync with `overlayTransitionDurationMs`.
|
|
39
|
-
*/
|
|
40
|
-
export const overlayDialogOpenClosedAnimationDurationClasses = [
|
|
41
|
-
'data-[state=open]:[animation-duration:200ms]',
|
|
42
|
-
'data-[state=closed]:[animation-duration:200ms]'
|
|
43
|
-
];
|
|
44
|
-
/**
|
|
45
|
-
* The scrim colour: the muted foreground token (neutral 550 in the design system) at 80%. The opacity is part of the colour, not of
|
|
46
|
-
* the layer, because an element that is itself translucent would not blur what is behind it. Literal so Tailwind's
|
|
47
|
-
* scanner emits it; `bg-muted-foreground/80` is the Figma scrim (`Foundations / Overlay`).
|
|
48
|
-
*/
|
|
49
17
|
export const overlayScrimColorClass = 'bg-muted-foreground/80';
|
|
50
|
-
/** Backdrop blur class — matches `overlayBackdropBlurPx`. Literal for the same reason as the colour. */
|
|
51
18
|
export const overlayBackdropBlurClass = 'backdrop-blur-[3px]';
|
|
52
|
-
/**
|
|
53
|
-
* The whole scrim: colour and blur. Every surface that dims the page behind a panel (dialogs, modals, drawers, the
|
|
54
|
-
* navigation drawer) uses these two classes, so the overlay looks the same everywhere. Written out, not joined from the
|
|
55
|
-
* two constants above, so the scanner of Tailwind finds both classes in this one literal as well.
|
|
56
|
-
*/
|
|
57
19
|
export const overlayScrimClasses = 'bg-muted-foreground/80 backdrop-blur-[3px]';
|
|
58
|
-
/** Tailwind arbitrary easing approximating Svelte `cubicOut` (ease-out cubic, 1 − (1 − t)³). */
|
|
59
20
|
export const overlayEasingClass = 'ease-[cubic-bezier(0.33,1,0.68,1)]';
|
|
60
|
-
/**
|
|
61
|
-
* A scrim drawn over another scrim only dims: the one below blurs the page already, and two backdrop blurs that fade
|
|
62
|
-
* in together flicker. `markStackedScrim` (`overlayStacking.ts`) puts `data-stacked` on such a scrim, and this takes its
|
|
63
|
-
* blur off. Literal so Tailwind's scanner emits it.
|
|
64
|
-
*/
|
|
65
21
|
export const overlayStackedScrimClass = 'data-[stacked]:backdrop-blur-none';
|
|
66
|
-
/**
|
|
22
|
+
/** Scrim surface classes only (motion is Svelte `fade` on the overlay child element). */
|
|
67
23
|
export const overlayDialogOverlayClasses = [
|
|
68
24
|
overlayScrimClasses,
|
|
69
|
-
overlayStackedScrimClass
|
|
70
|
-
overlayDurationClass,
|
|
71
|
-
overlayEasingClass,
|
|
72
|
-
...overlayDialogOpenClosedAnimationDurationClasses,
|
|
73
|
-
`data-[state=open]:animate-in`,
|
|
74
|
-
`data-[state=closed]:animate-out`,
|
|
75
|
-
`data-[state=closed]:fade-out-0`,
|
|
76
|
-
`data-[state=open]:fade-in-0`
|
|
77
|
-
].join(' ');
|
|
78
|
-
/** Centred dialog panel motion is keyed in global.css (`widgetic-dialog-enter/exit`) so slide composes with -translate-x/y-1/2. */
|
|
79
|
-
export const overlayDialogContentClasses = [
|
|
80
|
-
overlayDurationClass,
|
|
81
|
-
overlayEasingClass,
|
|
82
|
-
'widgetic-dialog-panel-motion',
|
|
83
|
-
...overlayDialogOpenClosedAnimationDurationClasses
|
|
25
|
+
overlayStackedScrimClass
|
|
84
26
|
].join(' ');
|
|
85
|
-
/**
|
|
86
|
-
export const
|
|
27
|
+
/** Card chrome inside the flex-centred dialog host (no fixed positioning on the card itself). */
|
|
28
|
+
export const overlayDialogPanelCardClasses = 'relative';
|
|
29
|
+
/** Full-viewport host that centres the card (see `dialog-content.svelte`). */
|
|
30
|
+
export const overlayDialogPanelLayoutClasses = 'fixed inset-0 flex items-center justify-center';
|
|
31
|
+
/** @deprecated Kept for grep tests; motion no longer uses Tailwind animate utilities. */
|
|
32
|
+
export const overlayDialogContentClasses = overlayDialogPanelLayoutClasses;
|
|
33
|
+
/** @deprecated */
|
|
34
|
+
export const overlayDialogContentMotionClasses = overlayDialogPanelLayoutClasses;
|
|
35
|
+
export const overlayReducedMotionClasses = 'motion-reduce:transition-none';
|
|
36
|
+
export function prefersReducedOverlayMotion() {
|
|
37
|
+
if (typeof window === 'undefined' || typeof window.matchMedia !== 'function')
|
|
38
|
+
return false;
|
|
39
|
+
return window.matchMedia('(prefers-reduced-motion: reduce)').matches;
|
|
40
|
+
}
|
|
41
|
+
function isVitestEnvironment() {
|
|
42
|
+
return typeof process !== 'undefined' && (process.env.VITEST === 'true' || process.env.NODE_ENV === 'test');
|
|
43
|
+
}
|
|
44
|
+
export function overlayScrimFadeTransition(reducedMotion = prefersReducedOverlayMotion()) {
|
|
45
|
+
if (isVitestEnvironment() || reducedMotion)
|
|
46
|
+
return { duration: 0 };
|
|
47
|
+
return { duration: overlayTransitionDurationMs, easing: overlayTransitionEasing };
|
|
48
|
+
}
|
|
49
|
+
export function overlayPanelFlyTransition(reducedMotion = prefersReducedOverlayMotion()) {
|
|
50
|
+
if (isVitestEnvironment() || reducedMotion) {
|
|
51
|
+
return { duration: 0, y: 0, opacity: 1 };
|
|
52
|
+
}
|
|
53
|
+
return {
|
|
54
|
+
duration: overlayTransitionDurationMs,
|
|
55
|
+
y: overlayContentSlidePx,
|
|
56
|
+
opacity: 0,
|
|
57
|
+
easing: overlayTransitionEasing
|
|
58
|
+
};
|
|
59
|
+
}
|