@vvedantb/ui 0.55.0 → 0.57.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 +25 -1
- package/dist/shell/src/AppShell.js +213 -147
- package/dist/shell/src/ButtonTrack.js +57 -0
- package/dist/shell/src/SidePanelTabs.js +595 -0
- package/dist/shell/src/SidebarPanel.js +20 -15
- package/dist/shell/src/SidebarRail.js +121 -59
- package/dist/shell/src/index.js +5 -1
- package/dist/shell/src/shell-panel-motion.js +62 -0
- package/dist/shell/src/shell-variant.js +28 -0
- package/dist/src/client.js +6 -1
- package/dist/src/index.js +6 -1
- package/dist/src/motion/dock-motion.js +209 -0
- package/dist/tokens/src/css/motion.css +7 -1
- package/dist/tokens/src/css/tabs.css +4 -0
- package/package.json +1 -1
- package/shell/src/AppShell.tsx +45 -17
- package/shell/src/ButtonTrack.tsx +26 -0
- package/shell/src/SidePanelTabs.tsx +380 -0
- package/shell/src/SidebarPanel.tsx +3 -0
- package/shell/src/SidebarRail.tsx +33 -9
- package/shell/src/index.ts +19 -1
- package/shell/src/shell-panel-motion.ts +64 -0
- package/shell/src/shell-variant.ts +46 -0
- package/src/client.ts +30 -1
- package/src/index.ts +30 -1
- package/src/motion/dock-motion.ts +188 -0
- package/tokens/src/css/motion.css +7 -1
- package/tokens/src/css/tabs.css +4 -0
package/shell/src/index.ts
CHANGED
|
@@ -21,11 +21,29 @@ export type {
|
|
|
21
21
|
AppShellScroll,
|
|
22
22
|
AppShellSkipLinkProps,
|
|
23
23
|
} from "./AppShell.js";
|
|
24
|
+
export { useAppShellVariant } from "./shell-variant.js";
|
|
25
|
+
export type { AppShellPanelMotion, AppShellVariant } from "./shell-variant.js";
|
|
26
|
+
export { popInShellPanelNextFrame, popOutShellPanel, toggleShellPanel } from "./shell-panel-motion.js";
|
|
27
|
+
export { ButtonTrack, buttonTrackClass } from "./ButtonTrack.js";
|
|
28
|
+
export type { ButtonTrackProps } from "./ButtonTrack.js";
|
|
29
|
+
export {
|
|
30
|
+
SidePanelTabs,
|
|
31
|
+
popOutSidePanel,
|
|
32
|
+
SIDE_PANEL_RAIL_WIDTH_PX,
|
|
33
|
+
SIDE_PANEL_RAIL_LABELLED_WIDTH_PX,
|
|
34
|
+
} from "./SidePanelTabs.js";
|
|
35
|
+
export type {
|
|
36
|
+
SidePanelTabLayout,
|
|
37
|
+
SidePanelTabsFrameProps,
|
|
38
|
+
SidePanelTabsListProps,
|
|
39
|
+
SidePanelTabsRailProps,
|
|
40
|
+
SidePanelTabsTabProps,
|
|
41
|
+
} from "./SidePanelTabs.js";
|
|
24
42
|
export { AppSidebar } from "./AppSidebar.js";
|
|
25
43
|
export type { AppSidebarProps } from "./AppSidebar.js";
|
|
26
44
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
27
45
|
export * from "./Sidebar.js";
|
|
28
|
-
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, useInRailGroup } from "./SidebarRail.js";
|
|
46
|
+
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProps, useInRailGroup } from "./SidebarRail.js";
|
|
29
47
|
export type { SidebarRailProps, RailTileProps, RailDividerProps, RailCollapseTileProps } from "./SidebarRail.js";
|
|
30
48
|
export { SidebarResizeHandle, useAppShellResize } from "./SidebarResize.js";
|
|
31
49
|
export type {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dock motion of the sidebar panel in an `AppShell variant="rail"`, on hide
|
|
3
|
+
* and show only: the panel shrinks into the rail's collapse tile and grows
|
|
4
|
+
* back out of it. `Sidebar.Panel` marks the panel and `RailCollapseTile` the
|
|
5
|
+
* tile (`shellDockTileProps` for a tile of your own). The main content slides
|
|
6
|
+
* its margin with the aside's width, so it does not jump.
|
|
7
|
+
*
|
|
8
|
+
* Off with `MotionProvider reducedMotion` and `PageMotionProvider disabled`
|
|
9
|
+
* (`dockMotionOff`), and outside the rail variant: the toggle runs at once.
|
|
10
|
+
*/
|
|
11
|
+
import { dockPopIn, dockPopOut, slideWith } from "../../src/motion/dock-motion";
|
|
12
|
+
|
|
13
|
+
function dockPanel(): HTMLElement | null {
|
|
14
|
+
if (typeof document === "undefined") return null;
|
|
15
|
+
return document.querySelector<HTMLElement>("[data-shell-dock-panel]");
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function dockTile(): HTMLElement | null {
|
|
19
|
+
if (typeof document === "undefined") return null;
|
|
20
|
+
return document.querySelector<HTMLElement>("[data-shell-dock-tile]");
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** The page beside the shell aside: its left margin follows the aside. */
|
|
24
|
+
function slideMainWithAside() {
|
|
25
|
+
const tile = dockTile();
|
|
26
|
+
if (!tile) return;
|
|
27
|
+
const shell = tile.closest<HTMLElement>("[data-shell-variant]");
|
|
28
|
+
slideWith((shell ?? document).querySelector<HTMLElement>("main"), tile.closest<HTMLElement>("aside"), "margin-left");
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** Shrink the panel into the collapse tile, then run `hide`. */
|
|
32
|
+
export function popOutShellPanel(hide: () => void) {
|
|
33
|
+
dockPopOut(dockPanel(), dockTile(), "left", () => {
|
|
34
|
+
slideMainWithAside();
|
|
35
|
+
hide();
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Call right after the state change that shows the panel. React shows it in
|
|
41
|
+
* this event's commit; the next frame runs before it paints.
|
|
42
|
+
*/
|
|
43
|
+
export function popInShellPanelNextFrame() {
|
|
44
|
+
if (typeof requestAnimationFrame !== "function") return;
|
|
45
|
+
slideMainWithAside();
|
|
46
|
+
requestAnimationFrame(() => {
|
|
47
|
+
const shown = dockPanel();
|
|
48
|
+
if (shown) dockPopIn(shown, dockTile(), "left");
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* Show or hide the sidebar panel with the dock motion. `collapsed` is the
|
|
54
|
+
* state before the toggle; `toggle` flips it. For a hotkey or a context
|
|
55
|
+
* setter that does not go through `RailCollapseTile`.
|
|
56
|
+
*/
|
|
57
|
+
export function toggleShellPanel(collapsed: boolean, toggle: () => void) {
|
|
58
|
+
if (collapsed) {
|
|
59
|
+
toggle();
|
|
60
|
+
popInShellPanelNextFrame();
|
|
61
|
+
} else {
|
|
62
|
+
popOutShellPanel(toggle);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { createContext, use } from "react";
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Layout of the app shell. `"floating"` (default): the page is a rounded card
|
|
5
|
+
* beside a plain icon rail. `"rail"`: no card; rail tiles sit on troughs with
|
|
6
|
+
* a sliding pill, and there are no divider lines.
|
|
7
|
+
*/
|
|
8
|
+
export type AppShellVariant = "floating" | "rail";
|
|
9
|
+
|
|
10
|
+
/** How the sidebar panel hides and shows in the `"rail"` variant. */
|
|
11
|
+
export type AppShellPanelMotion = "dock" | "none";
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* The `variant` input of `AppShell` and `AppShell.Root`, as a union keyed on
|
|
15
|
+
* `variant`. An input that only one variant takes goes on that arm, with
|
|
16
|
+
* `?: never` on the other, so passing it to the wrong variant is a type error.
|
|
17
|
+
*/
|
|
18
|
+
export type AppShellVariantProps =
|
|
19
|
+
| {
|
|
20
|
+
/** Default `"floating"`. */
|
|
21
|
+
variant?: "floating";
|
|
22
|
+
panelMotion?: never;
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
variant: "rail";
|
|
26
|
+
/**
|
|
27
|
+
* Rail only. `"dock"` (default): `RailCollapseTile` shrinks the panel
|
|
28
|
+
* into the tile on hide and grows it back out on show. `"none"`: the
|
|
29
|
+
* panel shows and hides at once.
|
|
30
|
+
*/
|
|
31
|
+
panelMotion?: AppShellPanelMotion;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const AppShellVariantContext = createContext<AppShellVariant>("floating");
|
|
35
|
+
|
|
36
|
+
/** The `variant` of the nearest `AppShell`; `"floating"` outside one. */
|
|
37
|
+
export function useAppShellVariant(): AppShellVariant {
|
|
38
|
+
return use(AppShellVariantContext);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export const AppShellPanelDockContext = createContext(false);
|
|
42
|
+
|
|
43
|
+
/** True inside an `AppShell variant="rail"` whose `panelMotion` is `"dock"`. */
|
|
44
|
+
export function useAppShellPanelDock(): boolean {
|
|
45
|
+
return use(AppShellPanelDockContext);
|
|
46
|
+
}
|
package/src/client.ts
CHANGED
|
@@ -42,6 +42,17 @@ export type { BulkActionBarConfig, BulkActionBarProps, BulkBarAction, BulkBarLab
|
|
|
42
42
|
export { CopyLinkMenuItem } from "./ui/copy-link-menu-item";
|
|
43
43
|
export { ToggleSearch } from "./ui/toggle-search";
|
|
44
44
|
export type { ToggleSearchProps, ToggleSearchVariant } from "./ui/toggle-search";
|
|
45
|
+
export {
|
|
46
|
+
DOCK_MOTION_EVENT,
|
|
47
|
+
DockMotionEvent,
|
|
48
|
+
dockMotionOff,
|
|
49
|
+
dockNudge,
|
|
50
|
+
dockPopIn,
|
|
51
|
+
dockPopOut,
|
|
52
|
+
slideNextResize,
|
|
53
|
+
slideWith,
|
|
54
|
+
} from "./motion/dock-motion";
|
|
55
|
+
export type { DockEdge } from "./motion/dock-motion";
|
|
45
56
|
export { MotionProvider } from "./motion/motion-provider";
|
|
46
57
|
export { useReducedMotionSetting, type ReducedMotion } from "./motion/reduced-motion";
|
|
47
58
|
export { MarqueeOnHover } from "./ui/marquee-on-hover";
|
|
@@ -230,11 +241,29 @@ export type {
|
|
|
230
241
|
AppShellRootProps,
|
|
231
242
|
AppShellSkipLinkProps,
|
|
232
243
|
} from "../shell/src/AppShell";
|
|
244
|
+
export { useAppShellVariant } from "../shell/src/shell-variant";
|
|
245
|
+
export type { AppShellPanelMotion, AppShellVariant } from "../shell/src/shell-variant";
|
|
246
|
+
export { popInShellPanelNextFrame, popOutShellPanel, toggleShellPanel } from "../shell/src/shell-panel-motion";
|
|
247
|
+
export { ButtonTrack, buttonTrackClass } from "../shell/src/ButtonTrack";
|
|
248
|
+
export type { ButtonTrackProps } from "../shell/src/ButtonTrack";
|
|
249
|
+
export {
|
|
250
|
+
SidePanelTabs,
|
|
251
|
+
popOutSidePanel,
|
|
252
|
+
SIDE_PANEL_RAIL_WIDTH_PX,
|
|
253
|
+
SIDE_PANEL_RAIL_LABELLED_WIDTH_PX,
|
|
254
|
+
} from "../shell/src/SidePanelTabs";
|
|
255
|
+
export type {
|
|
256
|
+
SidePanelTabLayout,
|
|
257
|
+
SidePanelTabsFrameProps,
|
|
258
|
+
SidePanelTabsListProps,
|
|
259
|
+
SidePanelTabsRailProps,
|
|
260
|
+
SidePanelTabsTabProps,
|
|
261
|
+
} from "../shell/src/SidePanelTabs";
|
|
233
262
|
export { AppSidebar } from "../shell/src/AppSidebar";
|
|
234
263
|
export type { AppSidebarProps } from "../shell/src/AppSidebar";
|
|
235
264
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
236
265
|
export * from "../shell/src/Sidebar";
|
|
237
|
-
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, useInRailGroup } from "../shell/src/SidebarRail";
|
|
266
|
+
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProps, useInRailGroup } from "../shell/src/SidebarRail";
|
|
238
267
|
export type {
|
|
239
268
|
SidebarRailProps,
|
|
240
269
|
RailTileProps,
|
package/src/index.ts
CHANGED
|
@@ -38,6 +38,17 @@ export type { BulkActionBarConfig, BulkActionBarProps, BulkBarAction, BulkBarLab
|
|
|
38
38
|
export { CopyLinkMenuItem } from "./ui/copy-link-menu-item";
|
|
39
39
|
export { ToggleSearch } from "./ui/toggle-search";
|
|
40
40
|
export type { ToggleSearchProps, ToggleSearchVariant } from "./ui/toggle-search";
|
|
41
|
+
export {
|
|
42
|
+
DOCK_MOTION_EVENT,
|
|
43
|
+
DockMotionEvent,
|
|
44
|
+
dockMotionOff,
|
|
45
|
+
dockNudge,
|
|
46
|
+
dockPopIn,
|
|
47
|
+
dockPopOut,
|
|
48
|
+
slideNextResize,
|
|
49
|
+
slideWith,
|
|
50
|
+
} from "./motion/dock-motion";
|
|
51
|
+
export type { DockEdge } from "./motion/dock-motion";
|
|
41
52
|
export { MotionProvider } from "./motion/motion-provider";
|
|
42
53
|
export { useReducedMotionSetting, type ReducedMotion } from "./motion/reduced-motion";
|
|
43
54
|
export { MarqueeOnHover } from "./ui/marquee-on-hover";
|
|
@@ -231,11 +242,29 @@ export type {
|
|
|
231
242
|
AppShellScroll,
|
|
232
243
|
AppShellSkipLinkProps,
|
|
233
244
|
} from "../shell/src/AppShell";
|
|
245
|
+
export { useAppShellVariant } from "../shell/src/shell-variant";
|
|
246
|
+
export type { AppShellPanelMotion, AppShellVariant } from "../shell/src/shell-variant";
|
|
247
|
+
export { popInShellPanelNextFrame, popOutShellPanel, toggleShellPanel } from "../shell/src/shell-panel-motion";
|
|
248
|
+
export { ButtonTrack, buttonTrackClass } from "../shell/src/ButtonTrack";
|
|
249
|
+
export type { ButtonTrackProps } from "../shell/src/ButtonTrack";
|
|
250
|
+
export {
|
|
251
|
+
SidePanelTabs,
|
|
252
|
+
popOutSidePanel,
|
|
253
|
+
SIDE_PANEL_RAIL_WIDTH_PX,
|
|
254
|
+
SIDE_PANEL_RAIL_LABELLED_WIDTH_PX,
|
|
255
|
+
} from "../shell/src/SidePanelTabs";
|
|
256
|
+
export type {
|
|
257
|
+
SidePanelTabLayout,
|
|
258
|
+
SidePanelTabsFrameProps,
|
|
259
|
+
SidePanelTabsListProps,
|
|
260
|
+
SidePanelTabsRailProps,
|
|
261
|
+
SidePanelTabsTabProps,
|
|
262
|
+
} from "../shell/src/SidePanelTabs";
|
|
234
263
|
export { AppSidebar } from "../shell/src/AppSidebar";
|
|
235
264
|
export type { AppSidebarProps } from "../shell/src/AppSidebar";
|
|
236
265
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
237
266
|
export * from "../shell/src/Sidebar";
|
|
238
|
-
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, useInRailGroup } from "../shell/src/SidebarRail";
|
|
267
|
+
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProps, useInRailGroup } from "../shell/src/SidebarRail";
|
|
239
268
|
export type {
|
|
240
269
|
SidebarRailProps,
|
|
241
270
|
RailTileProps,
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dock motion for a panel that docks into a rail tile: it grows out of the
|
|
3
|
+
* tile when shown, shrinks back into it when hidden, and settles when the
|
|
4
|
+
* tile it belongs to changes. The Web Animations API drives it: the motions
|
|
5
|
+
* are one-shot and imperative, and a hide has to finish before the caller
|
|
6
|
+
* removes the panel.
|
|
7
|
+
*
|
|
8
|
+
* Off switch: `MotionProvider reducedMotion` (`prefersReducedMotion()`) and
|
|
9
|
+
* `PageMotionProvider disabled` (`html[data-page-motion="off"]`). With either
|
|
10
|
+
* on, nothing here animates: a show is instant and a hide runs at once.
|
|
11
|
+
*/
|
|
12
|
+
import { prefersReducedMotion } from "./reduced-motion";
|
|
13
|
+
|
|
14
|
+
/** Which edge of the panel touches the rail. */
|
|
15
|
+
export type DockEdge = "left" | "right";
|
|
16
|
+
|
|
17
|
+
/** How small the panel gets: close to the tile's size, not a dot. */
|
|
18
|
+
const DOCKED_SCALE = 0.12;
|
|
19
|
+
const POP_IN_MS = 380;
|
|
20
|
+
const POP_OUT_MS = 260;
|
|
21
|
+
const SWITCH_MS = 220;
|
|
22
|
+
/* Out-quint: fast start, long settle. The panel lands rather than stops. */
|
|
23
|
+
const SETTLE_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
24
|
+
/* In-cubic: accelerates into the tile, as a minimise does. */
|
|
25
|
+
const DOCK_EASE = "cubic-bezier(0.5, 0, 0.75, 0)";
|
|
26
|
+
const POP_OUT_ID = "dock-pop-out";
|
|
27
|
+
/* How long the docked frame holds after a hide: past the sidebar's 280 ms
|
|
28
|
+
width slide, so the panel never shows at full size while it leaves. */
|
|
29
|
+
const HOLD_MS = 400;
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Fired on the panel as a dock motion starts, and it bubbles. Overlays painted
|
|
33
|
+
* over the panel from elsewhere (an iframe host, say) cannot follow its
|
|
34
|
+
* transform, so they step aside for `ms`.
|
|
35
|
+
*/
|
|
36
|
+
export const DOCK_MOTION_EVENT = "dockmotion";
|
|
37
|
+
export class DockMotionEvent extends Event {
|
|
38
|
+
readonly ms: number;
|
|
39
|
+
constructor(ms: number) {
|
|
40
|
+
super(DOCK_MOTION_EVENT, { bubbles: true });
|
|
41
|
+
this.ms = ms;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True while dock motion must not run. */
|
|
46
|
+
export function dockMotionOff(): boolean {
|
|
47
|
+
if (typeof document === "undefined") return true;
|
|
48
|
+
return document.documentElement.dataset.pageMotion === "off" || prefersReducedMotion();
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* Points the panel's transform origin at the tile's centre, on the rail
|
|
53
|
+
* edge. False when either is not on screen, so the caller skips the motion.
|
|
54
|
+
* Measure before animating: a scaled panel reports a scaled rect.
|
|
55
|
+
*/
|
|
56
|
+
function aimAt(panel: HTMLElement, tile: HTMLElement | null, edge: DockEdge) {
|
|
57
|
+
if (!tile || dockMotionOff() || typeof panel.animate !== "function") return false;
|
|
58
|
+
const p = panel.getBoundingClientRect();
|
|
59
|
+
// Height, not width: a sidebar aside slides its width open from 0.
|
|
60
|
+
if (p.height === 0) return false;
|
|
61
|
+
const t = tile.getBoundingClientRect();
|
|
62
|
+
const x = edge === "left" ? "0%" : "100%";
|
|
63
|
+
panel.style.transformOrigin = `${x} ${Math.round(t.top + t.height / 2 - p.top)}px`;
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
/** Drops a finished pop-out's held frame (see `dockPopOut`). */
|
|
68
|
+
function releaseDocked(el: HTMLElement | null | undefined) {
|
|
69
|
+
if (!el || typeof el.getAnimations !== "function") return;
|
|
70
|
+
for (const a of el.getAnimations()) if (a.id === POP_OUT_ID) a.cancel();
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* Shown: the panel grows out of the tile. `after` (an arrow, a badge) fades in
|
|
75
|
+
* once the panel has nearly landed.
|
|
76
|
+
*/
|
|
77
|
+
export function dockPopIn(panel: HTMLElement, tile: HTMLElement | null, edge: DockEdge, after?: HTMLElement | null) {
|
|
78
|
+
// Always, even when the motion is skipped, or the panel stays invisible.
|
|
79
|
+
releaseDocked(panel);
|
|
80
|
+
releaseDocked(after);
|
|
81
|
+
if (!aimAt(panel, tile, edge)) return;
|
|
82
|
+
panel.dispatchEvent(new DockMotionEvent(POP_IN_MS));
|
|
83
|
+
panel.animate(
|
|
84
|
+
[
|
|
85
|
+
{ transform: `scale(${DOCKED_SCALE})`, opacity: 0 },
|
|
86
|
+
{ transform: "scale(1.015)", opacity: 1, offset: 0.75 },
|
|
87
|
+
{ transform: "scale(1)", opacity: 1 },
|
|
88
|
+
],
|
|
89
|
+
{ duration: POP_IN_MS, easing: SETTLE_EASE },
|
|
90
|
+
);
|
|
91
|
+
after?.animate([{ opacity: 0 }, { opacity: 0, offset: 0.6 }, { opacity: 1 }], { duration: POP_IN_MS });
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/** The tile changed with the panel shown: a short settle from the new tile. */
|
|
95
|
+
export function dockNudge(panel: HTMLElement, tile: HTMLElement | null, edge: DockEdge) {
|
|
96
|
+
if (!aimAt(panel, tile, edge)) return;
|
|
97
|
+
panel.dispatchEvent(new DockMotionEvent(SWITCH_MS));
|
|
98
|
+
panel.animate(
|
|
99
|
+
[
|
|
100
|
+
{ transform: "scale(0.965)", opacity: 0.4 },
|
|
101
|
+
{ transform: "scale(1)", opacity: 1 },
|
|
102
|
+
],
|
|
103
|
+
{ duration: SWITCH_MS, easing: SETTLE_EASE },
|
|
104
|
+
);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Hiding: shrink the panel back into the tile, then run `hide`. With no panel
|
|
109
|
+
* or tile on screen, or motion off, it hides at once. A second call while the
|
|
110
|
+
* panel is closing is ignored. `first` (an arrow) fades out early. The docked
|
|
111
|
+
* frame holds for 400 ms (or until the next `dockPopIn`): the caller may still
|
|
112
|
+
* slide the panel away, and it must stay invisible.
|
|
113
|
+
*/
|
|
114
|
+
export function dockPopOut(
|
|
115
|
+
panel: HTMLElement | null,
|
|
116
|
+
tile: HTMLElement | null,
|
|
117
|
+
edge: DockEdge,
|
|
118
|
+
hide: () => void,
|
|
119
|
+
first?: HTMLElement | null,
|
|
120
|
+
) {
|
|
121
|
+
if (!panel || !aimAt(panel, tile, edge)) {
|
|
122
|
+
hide();
|
|
123
|
+
return;
|
|
124
|
+
}
|
|
125
|
+
const closing = panel.getAnimations().some((a) => a.id === POP_OUT_ID && a.playState === "running");
|
|
126
|
+
if (closing) return;
|
|
127
|
+
panel.dispatchEvent(new DockMotionEvent(POP_OUT_MS + HOLD_MS));
|
|
128
|
+
first?.animate([{ opacity: 1 }, { opacity: 0 }], { id: POP_OUT_ID, duration: POP_OUT_MS / 3, fill: "forwards" });
|
|
129
|
+
const shrink = panel.animate(
|
|
130
|
+
[
|
|
131
|
+
{ transform: "scale(1)", opacity: 1 },
|
|
132
|
+
{ transform: `scale(${DOCKED_SCALE})`, opacity: 0 },
|
|
133
|
+
],
|
|
134
|
+
{ id: POP_OUT_ID, duration: POP_OUT_MS, easing: DOCK_EASE, fill: "forwards" },
|
|
135
|
+
);
|
|
136
|
+
shrink.onfinish = () => {
|
|
137
|
+
hide();
|
|
138
|
+
setTimeout(() => {
|
|
139
|
+
releaseDocked(panel);
|
|
140
|
+
releaseDocked(first);
|
|
141
|
+
}, HOLD_MS);
|
|
142
|
+
};
|
|
143
|
+
}
|
|
144
|
+
|
|
145
|
+
/**
|
|
146
|
+
* Lets the panes of a resizable group slide to their next size instead of
|
|
147
|
+
* jumping, so the neighbour pane moves in step with a pop. It sets
|
|
148
|
+
* `data-dock-slide` and the `--dock-slide-dur` / `--dock-slide-ease` variables
|
|
149
|
+
* on `group` for one resize; the package CSS transitions `flex-grow` of its
|
|
150
|
+
* `[data-panel]` children (`react-resizable-panels`). Call it just before the
|
|
151
|
+
* resize. Only for this one toggle: a drag must stay 1:1 with the pointer.
|
|
152
|
+
*/
|
|
153
|
+
export function slideNextResize(group: HTMLElement | null, direction: "open" | "close") {
|
|
154
|
+
if (!group || dockMotionOff()) return;
|
|
155
|
+
const ms = direction === "open" ? POP_IN_MS : POP_OUT_MS;
|
|
156
|
+
group.style.setProperty("--dock-slide-dur", `${ms}ms`);
|
|
157
|
+
group.style.setProperty("--dock-slide-ease", SETTLE_EASE);
|
|
158
|
+
group.dataset.dockSlide = "";
|
|
159
|
+
window.clearTimeout(Number(group.dataset.dockSlideTimer));
|
|
160
|
+
group.dataset.dockSlideTimer = String(
|
|
161
|
+
window.setTimeout(() => {
|
|
162
|
+
delete group.dataset.dockSlide;
|
|
163
|
+
}, ms + 50),
|
|
164
|
+
);
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* For one layout change, `follower` slides its `property` with the timing of
|
|
169
|
+
* `leader`'s own transition, so a neighbour the leader pushes moves in step
|
|
170
|
+
* instead of jumping (the main content beside a sidebar's sliding width). Call
|
|
171
|
+
* it just before the change. Fires `DOCK_MOTION_EVENT` on the follower, so
|
|
172
|
+
* overlays over it step aside while it moves.
|
|
173
|
+
*/
|
|
174
|
+
export function slideWith(follower: HTMLElement | null, leader: HTMLElement | null, property: string) {
|
|
175
|
+
if (!follower || !leader || dockMotionOff()) return;
|
|
176
|
+
const lead = getComputedStyle(leader);
|
|
177
|
+
const ms = parseFloat(lead.transitionDuration) * 1000;
|
|
178
|
+
if (!(ms > 0)) return;
|
|
179
|
+
follower.style.transition = `${property} ${lead.transitionDuration} ${lead.transitionTimingFunction}`;
|
|
180
|
+
follower.dispatchEvent(new DockMotionEvent(ms));
|
|
181
|
+
window.clearTimeout(Number(follower.dataset.slideWithTimer));
|
|
182
|
+
follower.dataset.slideWithTimer = String(
|
|
183
|
+
window.setTimeout(() => {
|
|
184
|
+
follower.style.transition = "";
|
|
185
|
+
delete follower.dataset.slideWithTimer;
|
|
186
|
+
}, ms + 50),
|
|
187
|
+
);
|
|
188
|
+
}
|
|
@@ -158,10 +158,16 @@
|
|
|
158
158
|
html[data-page-motion="off"] .t-modal,
|
|
159
159
|
html[data-page-motion="off"] .t-modal.is-closing,
|
|
160
160
|
html[data-page-motion="off"] .t-modal[data-state="closed"],
|
|
161
|
-
html[data-page-motion="off"] .t-tabs-pill
|
|
161
|
+
html[data-page-motion="off"] .t-tabs-pill,
|
|
162
|
+
html[data-page-motion="off"] .t-side-panel-arrow {
|
|
162
163
|
transition-duration: 0s !important;
|
|
163
164
|
}
|
|
164
165
|
|
|
166
|
+
/* `slideNextResize`: the panes of a resizable group slide for one resize. */
|
|
167
|
+
[data-dock-slide] > [data-panel] {
|
|
168
|
+
transition: flex-grow var(--dock-slide-dur) var(--dock-slide-ease);
|
|
169
|
+
}
|
|
170
|
+
|
|
165
171
|
html[data-page-motion="off"]::view-transition-group(*),
|
|
166
172
|
html[data-page-motion="off"]::view-transition-old(*),
|
|
167
173
|
html[data-page-motion="off"]::view-transition-new(*) {
|
package/tokens/src/css/tabs.css
CHANGED