@vvedantb/ui 0.56.0 → 0.58.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 +24 -1
- package/dist/shell/src/AppShell.js +156 -125
- 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 +43 -19
- package/dist/shell/src/index.js +4 -1
- package/dist/shell/src/shell-panel-motion.js +62 -0
- package/dist/shell/src/shell-variant.js +8 -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/dist/tokens/src/tokens.css +21 -0
- package/package.json +1 -1
- package/shell/src/AppShell.tsx +20 -15
- 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 +16 -3
- package/shell/src/index.ts +18 -2
- package/shell/src/shell-panel-motion.ts +64 -0
- package/shell/src/shell-variant.ts +20 -1
- 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/tokens/src/tokens.css +21 -0
|
@@ -8,7 +8,8 @@ import { APP_ICONS } from "../../src/brand/AppIcons.js";
|
|
|
8
8
|
import { moveTabsPillXY } from "../../src/ui/tabsSliding.js";
|
|
9
9
|
import { SIDEBAR_RAIL_APP_ICON_SIZE, railGroupClass, railGroupPillClass, railTileClass, railTileStateClass } from "./app-shell-classes.js";
|
|
10
10
|
import { SidebarIconTooltip } from "./SidebarIconTooltip.js";
|
|
11
|
-
import {
|
|
11
|
+
import { toggleShellPanel } from "./shell-panel-motion.js";
|
|
12
|
+
import { useAppShellPanelDock, useAppShellVariant } from "./shell-variant.js";
|
|
12
13
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
13
14
|
/**
|
|
14
15
|
* Icon rail column. Width reads `--app-shell-rail-width`; override with `className`. Other props go to the root `<div>`.
|
|
@@ -693,39 +694,62 @@ export function RailDivider(t0) {
|
|
|
693
694
|
}
|
|
694
695
|
return t1;
|
|
695
696
|
}
|
|
696
|
-
|
|
697
|
+
|
|
698
|
+
/** Spread on the rail tile that the panel docks into, when it is not a `RailCollapseTile`. */
|
|
699
|
+
export const shellDockTileProps = {
|
|
700
|
+
"data-shell-dock-tile": ""
|
|
701
|
+
};
|
|
702
|
+
/**
|
|
703
|
+
* Rail tile that shows or hides the sidebar panel. In an `AppShell
|
|
704
|
+
* variant="rail"` (unless `panelMotion="none"`) the panel shrinks into this
|
|
705
|
+
* tile and grows back out of it (`toggleShellPanel`).
|
|
706
|
+
*/
|
|
697
707
|
export function RailCollapseTile(t0) {
|
|
698
|
-
const $ = _c(
|
|
708
|
+
const $ = _c(11);
|
|
699
709
|
const {
|
|
700
710
|
collapsed,
|
|
701
711
|
onToggle
|
|
702
712
|
} = t0;
|
|
713
|
+
const dock = useAppShellPanelDock();
|
|
703
714
|
const t1 = collapsed ? "Show sidebar" : "Hide sidebar";
|
|
704
715
|
let t2;
|
|
705
|
-
if ($[0] !== collapsed) {
|
|
706
|
-
t2 =
|
|
716
|
+
if ($[0] !== collapsed || $[1] !== dock || $[2] !== onToggle) {
|
|
717
|
+
t2 = dock ? () => toggleShellPanel(collapsed, onToggle) : onToggle;
|
|
718
|
+
$[0] = collapsed;
|
|
719
|
+
$[1] = dock;
|
|
720
|
+
$[2] = onToggle;
|
|
721
|
+
$[3] = t2;
|
|
722
|
+
} else {
|
|
723
|
+
t2 = $[3];
|
|
724
|
+
}
|
|
725
|
+
const t3 = dock ? shellDockTileProps : undefined;
|
|
726
|
+
let t4;
|
|
727
|
+
if ($[4] !== collapsed) {
|
|
728
|
+
t4 = collapsed ? /*#__PURE__*/_jsx(IconLayoutSidebarLeftExpandFilled, {
|
|
707
729
|
className: "size-[22px]"
|
|
708
730
|
}) : /*#__PURE__*/_jsx(IconLayoutSidebarLeftCollapse, {
|
|
709
731
|
className: "size-[22px]"
|
|
710
732
|
});
|
|
711
|
-
$[
|
|
712
|
-
$[
|
|
733
|
+
$[4] = collapsed;
|
|
734
|
+
$[5] = t4;
|
|
713
735
|
} else {
|
|
714
|
-
|
|
736
|
+
t4 = $[5];
|
|
715
737
|
}
|
|
716
|
-
let
|
|
717
|
-
if ($[
|
|
718
|
-
|
|
738
|
+
let t5;
|
|
739
|
+
if ($[6] !== t1 || $[7] !== t2 || $[8] !== t3 || $[9] !== t4) {
|
|
740
|
+
t5 = /*#__PURE__*/_jsx(RailItem, {
|
|
719
741
|
label: t1,
|
|
720
|
-
onClick:
|
|
721
|
-
|
|
742
|
+
onClick: t2,
|
|
743
|
+
...t3,
|
|
744
|
+
children: t4
|
|
722
745
|
});
|
|
723
|
-
$[
|
|
724
|
-
$[
|
|
725
|
-
$[
|
|
726
|
-
$[
|
|
746
|
+
$[6] = t1;
|
|
747
|
+
$[7] = t2;
|
|
748
|
+
$[8] = t3;
|
|
749
|
+
$[9] = t4;
|
|
750
|
+
$[10] = t5;
|
|
727
751
|
} else {
|
|
728
|
-
|
|
752
|
+
t5 = $[10];
|
|
729
753
|
}
|
|
730
|
-
return
|
|
754
|
+
return t5;
|
|
731
755
|
}
|
package/dist/shell/src/index.js
CHANGED
|
@@ -5,10 +5,13 @@ export { cn } from "./cn.js";
|
|
|
5
5
|
export { SessionsHoverCard } from "./SessionsHoverCard.js";
|
|
6
6
|
export { AppShell } from "./AppShell.js";
|
|
7
7
|
export { useAppShellVariant } from "./shell-variant.js";
|
|
8
|
+
export { popInShellPanelNextFrame, popOutShellPanel, toggleShellPanel } from "./shell-panel-motion.js";
|
|
9
|
+
export { ButtonTrack, buttonTrackClass } from "./ButtonTrack.js";
|
|
10
|
+
export { SidePanelTabs, popOutSidePanel, SIDE_PANEL_RAIL_WIDTH_PX, SIDE_PANEL_RAIL_LABELLED_WIDTH_PX } from "./SidePanelTabs.js";
|
|
8
11
|
export { AppSidebar } from "./AppSidebar.js";
|
|
9
12
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
10
13
|
export * from "./Sidebar.js";
|
|
11
|
-
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, useInRailGroup } from "./SidebarRail.js";
|
|
14
|
+
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProps, useInRailGroup } from "./SidebarRail.js";
|
|
12
15
|
export { SidebarResizeHandle, useAppShellResize } from "./SidebarResize.js";
|
|
13
16
|
export { SidebarIconTooltip } from "./SidebarIconTooltip.js";
|
|
14
17
|
export { SidebarPanel } from "./SidebarPanel.js";
|
|
@@ -0,0 +1,62 @@
|
|
|
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.js";
|
|
12
|
+
function dockPanel() {
|
|
13
|
+
if (typeof document === "undefined") return null;
|
|
14
|
+
return document.querySelector("[data-shell-dock-panel]");
|
|
15
|
+
}
|
|
16
|
+
function dockTile() {
|
|
17
|
+
if (typeof document === "undefined") return null;
|
|
18
|
+
return document.querySelector("[data-shell-dock-tile]");
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** The page beside the shell aside: its left margin follows the aside. */
|
|
22
|
+
function slideMainWithAside() {
|
|
23
|
+
const tile = dockTile();
|
|
24
|
+
if (!tile) return;
|
|
25
|
+
const shell = tile.closest("[data-shell-variant]");
|
|
26
|
+
slideWith((shell ?? document).querySelector("main"), tile.closest("aside"), "margin-left");
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/** Shrink the panel into the collapse tile, then run `hide`. */
|
|
30
|
+
export function popOutShellPanel(hide) {
|
|
31
|
+
dockPopOut(dockPanel(), dockTile(), "left", () => {
|
|
32
|
+
slideMainWithAside();
|
|
33
|
+
hide();
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Call right after the state change that shows the panel. React shows it in
|
|
39
|
+
* this event's commit; the next frame runs before it paints.
|
|
40
|
+
*/
|
|
41
|
+
export function popInShellPanelNextFrame() {
|
|
42
|
+
if (typeof requestAnimationFrame !== "function") return;
|
|
43
|
+
slideMainWithAside();
|
|
44
|
+
requestAnimationFrame(() => {
|
|
45
|
+
const shown = dockPanel();
|
|
46
|
+
if (shown) dockPopIn(shown, dockTile(), "left");
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Show or hide the sidebar panel with the dock motion. `collapsed` is the
|
|
52
|
+
* state before the toggle; `toggle` flips it. For a hotkey or a context
|
|
53
|
+
* setter that does not go through `RailCollapseTile`.
|
|
54
|
+
*/
|
|
55
|
+
export function toggleShellPanel(collapsed, toggle) {
|
|
56
|
+
if (collapsed) {
|
|
57
|
+
toggle();
|
|
58
|
+
popInShellPanelNextFrame();
|
|
59
|
+
} else {
|
|
60
|
+
popOutShellPanel(toggle);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -6,6 +6,8 @@ import { createContext, use } from "react";
|
|
|
6
6
|
* a sliding pill, and there are no divider lines.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
/** How the sidebar panel hides and shows in the `"rail"` variant. */
|
|
10
|
+
|
|
9
11
|
/**
|
|
10
12
|
* The `variant` input of `AppShell` and `AppShell.Root`, as a union keyed on
|
|
11
13
|
* `variant`. An input that only one variant takes goes on that arm, with
|
|
@@ -18,3 +20,9 @@ export const AppShellVariantContext = /*#__PURE__*/createContext("floating");
|
|
|
18
20
|
export function useAppShellVariant() {
|
|
19
21
|
return use(AppShellVariantContext);
|
|
20
22
|
}
|
|
23
|
+
export const AppShellPanelDockContext = /*#__PURE__*/createContext(false);
|
|
24
|
+
|
|
25
|
+
/** True inside an `AppShell variant="rail"` whose `panelMotion` is `"dock"`. */
|
|
26
|
+
export function useAppShellPanelDock() {
|
|
27
|
+
return use(AppShellPanelDockContext);
|
|
28
|
+
}
|
package/dist/src/client.js
CHANGED
|
@@ -31,6 +31,7 @@ export { SendQueueIcon } from "./ui/send-queue-icon.js";
|
|
|
31
31
|
export { BulkActionBar } from "./ui/bulk-action-bar.js";
|
|
32
32
|
export { CopyLinkMenuItem } from "./ui/copy-link-menu-item.js";
|
|
33
33
|
export { ToggleSearch } from "./ui/toggle-search.js";
|
|
34
|
+
export { DOCK_MOTION_EVENT, DockMotionEvent, dockMotionOff, dockNudge, dockPopIn, dockPopOut, slideNextResize, slideWith } from "./motion/dock-motion.js";
|
|
34
35
|
export { MotionProvider } from "./motion/motion-provider.js";
|
|
35
36
|
export { useReducedMotionSetting } from "./motion/reduced-motion.js";
|
|
36
37
|
export { MarqueeOnHover } from "./ui/marquee-on-hover.js";
|
|
@@ -171,10 +172,14 @@ export { SessionsHoverCard } from "../shell/src/SessionsHoverCard.js";
|
|
|
171
172
|
// App shell: sidebar and main page layout. Widths come from the
|
|
172
173
|
// `--app-shell-*` CSS variables that `AppShell` sets.
|
|
173
174
|
export { AppShell } from "../shell/src/AppShell.js";
|
|
175
|
+
export { useAppShellVariant } from "../shell/src/shell-variant.js";
|
|
176
|
+
export { popInShellPanelNextFrame, popOutShellPanel, toggleShellPanel } from "../shell/src/shell-panel-motion.js";
|
|
177
|
+
export { ButtonTrack, buttonTrackClass } from "../shell/src/ButtonTrack.js";
|
|
178
|
+
export { SidePanelTabs, popOutSidePanel, SIDE_PANEL_RAIL_WIDTH_PX, SIDE_PANEL_RAIL_LABELLED_WIDTH_PX } from "../shell/src/SidePanelTabs.js";
|
|
174
179
|
export { AppSidebar } from "../shell/src/AppSidebar.js";
|
|
175
180
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
176
181
|
export * from "../shell/src/Sidebar.js";
|
|
177
|
-
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, useInRailGroup } from "../shell/src/SidebarRail.js";
|
|
182
|
+
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProps, useInRailGroup } from "../shell/src/SidebarRail.js";
|
|
178
183
|
export { SidebarResizeHandle, useAppShellResize } from "../shell/src/SidebarResize.js";
|
|
179
184
|
export { SidebarIconTooltip } from "../shell/src/SidebarIconTooltip.js";
|
|
180
185
|
export { SidebarPanel } from "../shell/src/SidebarPanel.js";
|
package/dist/src/index.js
CHANGED
|
@@ -27,6 +27,7 @@ export { SendQueueIcon } from "./ui/send-queue-icon.js";
|
|
|
27
27
|
export { BulkActionBar } from "./ui/bulk-action-bar.js";
|
|
28
28
|
export { CopyLinkMenuItem } from "./ui/copy-link-menu-item.js";
|
|
29
29
|
export { ToggleSearch } from "./ui/toggle-search.js";
|
|
30
|
+
export { DOCK_MOTION_EVENT, DockMotionEvent, dockMotionOff, dockNudge, dockPopIn, dockPopOut, slideNextResize, slideWith } from "./motion/dock-motion.js";
|
|
30
31
|
export { MotionProvider } from "./motion/motion-provider.js";
|
|
31
32
|
export { useReducedMotionSetting } from "./motion/reduced-motion.js";
|
|
32
33
|
export { MarqueeOnHover } from "./ui/marquee-on-hover.js";
|
|
@@ -171,10 +172,14 @@ export { SessionsHoverCard } from "../shell/src/SessionsHoverCard.js";
|
|
|
171
172
|
// App shell: sidebar and main page layout. Widths come from the
|
|
172
173
|
// `--app-shell-*` CSS variables that `AppShell` sets.
|
|
173
174
|
export { AppShell } from "../shell/src/AppShell.js";
|
|
175
|
+
export { useAppShellVariant } from "../shell/src/shell-variant.js";
|
|
176
|
+
export { popInShellPanelNextFrame, popOutShellPanel, toggleShellPanel } from "../shell/src/shell-panel-motion.js";
|
|
177
|
+
export { ButtonTrack, buttonTrackClass } from "../shell/src/ButtonTrack.js";
|
|
178
|
+
export { SidePanelTabs, popOutSidePanel, SIDE_PANEL_RAIL_WIDTH_PX, SIDE_PANEL_RAIL_LABELLED_WIDTH_PX } from "../shell/src/SidePanelTabs.js";
|
|
174
179
|
export { AppSidebar } from "../shell/src/AppSidebar.js";
|
|
175
180
|
// Composable sidebar parts (`Sidebar.Root`, `Sidebar.Rail`, ...) and their prop types.
|
|
176
181
|
export * from "../shell/src/Sidebar.js";
|
|
177
|
-
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, useInRailGroup } from "../shell/src/SidebarRail.js";
|
|
182
|
+
export { SidebarRail, RailTile, RailDivider, RailCollapseTile, shellDockTileProps, useInRailGroup } from "../shell/src/SidebarRail.js";
|
|
178
183
|
export { SidebarResizeHandle, useAppShellResize } from "../shell/src/SidebarResize.js";
|
|
179
184
|
export { SidebarIconTooltip } from "../shell/src/SidebarIconTooltip.js";
|
|
180
185
|
export { SidebarPanel } from "../shell/src/SidebarPanel.js";
|
|
@@ -0,0 +1,209 @@
|
|
|
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.js";
|
|
13
|
+
|
|
14
|
+
/** Which edge of the panel touches the rail. */
|
|
15
|
+
|
|
16
|
+
/** How small the panel gets: close to the tile's size, not a dot. */
|
|
17
|
+
const DOCKED_SCALE = 0.12;
|
|
18
|
+
const POP_IN_MS = 380;
|
|
19
|
+
const POP_OUT_MS = 260;
|
|
20
|
+
const SWITCH_MS = 220;
|
|
21
|
+
/* Out-quint: fast start, long settle. The panel lands rather than stops. */
|
|
22
|
+
const SETTLE_EASE = "cubic-bezier(0.22, 1, 0.36, 1)";
|
|
23
|
+
/* In-cubic: accelerates into the tile, as a minimise does. */
|
|
24
|
+
const DOCK_EASE = "cubic-bezier(0.5, 0, 0.75, 0)";
|
|
25
|
+
const POP_OUT_ID = "dock-pop-out";
|
|
26
|
+
/* How long the docked frame holds after a hide: past the sidebar's 280 ms
|
|
27
|
+
width slide, so the panel never shows at full size while it leaves. */
|
|
28
|
+
const HOLD_MS = 400;
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Fired on the panel as a dock motion starts, and it bubbles. Overlays painted
|
|
32
|
+
* over the panel from elsewhere (an iframe host, say) cannot follow its
|
|
33
|
+
* transform, so they step aside for `ms`.
|
|
34
|
+
*/
|
|
35
|
+
export const DOCK_MOTION_EVENT = "dockmotion";
|
|
36
|
+
export class DockMotionEvent extends Event {
|
|
37
|
+
constructor(ms) {
|
|
38
|
+
super(DOCK_MOTION_EVENT, {
|
|
39
|
+
bubbles: true
|
|
40
|
+
});
|
|
41
|
+
this.ms = ms;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/** True while dock motion must not run. */
|
|
46
|
+
export function dockMotionOff() {
|
|
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, tile, edge) {
|
|
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) {
|
|
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, tile, edge, after) {
|
|
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
|
+
transform: `scale(${DOCKED_SCALE})`,
|
|
85
|
+
opacity: 0
|
|
86
|
+
}, {
|
|
87
|
+
transform: "scale(1.015)",
|
|
88
|
+
opacity: 1,
|
|
89
|
+
offset: 0.75
|
|
90
|
+
}, {
|
|
91
|
+
transform: "scale(1)",
|
|
92
|
+
opacity: 1
|
|
93
|
+
}], {
|
|
94
|
+
duration: POP_IN_MS,
|
|
95
|
+
easing: SETTLE_EASE
|
|
96
|
+
});
|
|
97
|
+
after?.animate([{
|
|
98
|
+
opacity: 0
|
|
99
|
+
}, {
|
|
100
|
+
opacity: 0,
|
|
101
|
+
offset: 0.6
|
|
102
|
+
}, {
|
|
103
|
+
opacity: 1
|
|
104
|
+
}], {
|
|
105
|
+
duration: POP_IN_MS
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** The tile changed with the panel shown: a short settle from the new tile. */
|
|
110
|
+
export function dockNudge(panel, tile, edge) {
|
|
111
|
+
if (!aimAt(panel, tile, edge)) return;
|
|
112
|
+
panel.dispatchEvent(new DockMotionEvent(SWITCH_MS));
|
|
113
|
+
panel.animate([{
|
|
114
|
+
transform: "scale(0.965)",
|
|
115
|
+
opacity: 0.4
|
|
116
|
+
}, {
|
|
117
|
+
transform: "scale(1)",
|
|
118
|
+
opacity: 1
|
|
119
|
+
}], {
|
|
120
|
+
duration: SWITCH_MS,
|
|
121
|
+
easing: SETTLE_EASE
|
|
122
|
+
});
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Hiding: shrink the panel back into the tile, then run `hide`. With no panel
|
|
127
|
+
* or tile on screen, or motion off, it hides at once. A second call while the
|
|
128
|
+
* panel is closing is ignored. `first` (an arrow) fades out early. The docked
|
|
129
|
+
* frame holds for 400 ms (or until the next `dockPopIn`): the caller may still
|
|
130
|
+
* slide the panel away, and it must stay invisible.
|
|
131
|
+
*/
|
|
132
|
+
export function dockPopOut(panel, tile, edge, hide, first) {
|
|
133
|
+
if (!panel || !aimAt(panel, tile, edge)) {
|
|
134
|
+
hide();
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
const closing = panel.getAnimations().some(a => a.id === POP_OUT_ID && a.playState === "running");
|
|
138
|
+
if (closing) return;
|
|
139
|
+
panel.dispatchEvent(new DockMotionEvent(POP_OUT_MS + HOLD_MS));
|
|
140
|
+
first?.animate([{
|
|
141
|
+
opacity: 1
|
|
142
|
+
}, {
|
|
143
|
+
opacity: 0
|
|
144
|
+
}], {
|
|
145
|
+
id: POP_OUT_ID,
|
|
146
|
+
duration: POP_OUT_MS / 3,
|
|
147
|
+
fill: "forwards"
|
|
148
|
+
});
|
|
149
|
+
const shrink = panel.animate([{
|
|
150
|
+
transform: "scale(1)",
|
|
151
|
+
opacity: 1
|
|
152
|
+
}, {
|
|
153
|
+
transform: `scale(${DOCKED_SCALE})`,
|
|
154
|
+
opacity: 0
|
|
155
|
+
}], {
|
|
156
|
+
id: POP_OUT_ID,
|
|
157
|
+
duration: POP_OUT_MS,
|
|
158
|
+
easing: DOCK_EASE,
|
|
159
|
+
fill: "forwards"
|
|
160
|
+
});
|
|
161
|
+
shrink.onfinish = () => {
|
|
162
|
+
hide();
|
|
163
|
+
setTimeout(() => {
|
|
164
|
+
releaseDocked(panel);
|
|
165
|
+
releaseDocked(first);
|
|
166
|
+
}, HOLD_MS);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Lets the panes of a resizable group slide to their next size instead of
|
|
172
|
+
* jumping, so the neighbour pane moves in step with a pop. It sets
|
|
173
|
+
* `data-dock-slide` and the `--dock-slide-dur` / `--dock-slide-ease` variables
|
|
174
|
+
* on `group` for one resize; the package CSS transitions `flex-grow` of its
|
|
175
|
+
* `[data-panel]` children (`react-resizable-panels`). Call it just before the
|
|
176
|
+
* resize. Only for this one toggle: a drag must stay 1:1 with the pointer.
|
|
177
|
+
*/
|
|
178
|
+
export function slideNextResize(group, direction) {
|
|
179
|
+
if (!group || dockMotionOff()) return;
|
|
180
|
+
const ms = direction === "open" ? POP_IN_MS : POP_OUT_MS;
|
|
181
|
+
group.style.setProperty("--dock-slide-dur", `${ms}ms`);
|
|
182
|
+
group.style.setProperty("--dock-slide-ease", SETTLE_EASE);
|
|
183
|
+
group.dataset.dockSlide = "";
|
|
184
|
+
window.clearTimeout(Number(group.dataset.dockSlideTimer));
|
|
185
|
+
group.dataset.dockSlideTimer = String(window.setTimeout(() => {
|
|
186
|
+
delete group.dataset.dockSlide;
|
|
187
|
+
}, ms + 50));
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
/**
|
|
191
|
+
* For one layout change, `follower` slides its `property` with the timing of
|
|
192
|
+
* `leader`'s own transition, so a neighbour the leader pushes moves in step
|
|
193
|
+
* instead of jumping (the main content beside a sidebar's sliding width). Call
|
|
194
|
+
* it just before the change. Fires `DOCK_MOTION_EVENT` on the follower, so
|
|
195
|
+
* overlays over it step aside while it moves.
|
|
196
|
+
*/
|
|
197
|
+
export function slideWith(follower, leader, property) {
|
|
198
|
+
if (!follower || !leader || dockMotionOff()) return;
|
|
199
|
+
const lead = getComputedStyle(leader);
|
|
200
|
+
const ms = parseFloat(lead.transitionDuration) * 1000;
|
|
201
|
+
if (!(ms > 0)) return;
|
|
202
|
+
follower.style.transition = `${property} ${lead.transitionDuration} ${lead.transitionTimingFunction}`;
|
|
203
|
+
follower.dispatchEvent(new DockMotionEvent(ms));
|
|
204
|
+
window.clearTimeout(Number(follower.dataset.slideWithTimer));
|
|
205
|
+
follower.dataset.slideWithTimer = String(window.setTimeout(() => {
|
|
206
|
+
follower.style.transition = "";
|
|
207
|
+
delete follower.dataset.slideWithTimer;
|
|
208
|
+
}, ms + 50));
|
|
209
|
+
}
|
|
@@ -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(*) {
|
|
@@ -246,6 +246,27 @@
|
|
|
246
246
|
--radius: 1rem;
|
|
247
247
|
--field-radius: min(var(--radius), 0.625rem);
|
|
248
248
|
}
|
|
249
|
+
|
|
250
|
+
/* Neutral: soft-dark grey surfaces. Opt in with `<html class="dark neutral">`;
|
|
251
|
+
status and accent colours come from `.dark`. */
|
|
252
|
+
.dark.neutral {
|
|
253
|
+
--background: rgb(34 35 37);
|
|
254
|
+
--border: rgb(78 79 82);
|
|
255
|
+
--default: rgb(68 69 72);
|
|
256
|
+
--field-background: rgb(48 49 52);
|
|
257
|
+
--field-placeholder: rgb(159 160 162);
|
|
258
|
+
--foreground: rgb(250 250 250);
|
|
259
|
+
--muted: rgb(159 160 162);
|
|
260
|
+
--overlay: rgb(48 49 52);
|
|
261
|
+
--scrollbar: rgb(159 160 162);
|
|
262
|
+
--segment: rgb(68 69 72);
|
|
263
|
+
--separator: rgb(58 59 62);
|
|
264
|
+
--surface: rgb(48 49 52);
|
|
265
|
+
--surface-secondary: rgb(58 59 62);
|
|
266
|
+
--surface-tertiary: rgb(68 69 72);
|
|
267
|
+
--surface-card: rgb(48 49 52);
|
|
268
|
+
--sidebar-accent: rgb(58 59 62);
|
|
269
|
+
}
|
|
249
270
|
}
|
|
250
271
|
|
|
251
272
|
@layer base {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vvedantb/ui",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.58.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "Shared React 19 UI for web apps: one main JavaScript entry (primitives, shell pieces, app helpers including the Convex and Clerk provider, VITE env parsing and ensure-user, artifact viewers over the @vvedantb/server artifacts core, native tokens), third-party brand logos (also @vvedantb/ui/logos), motion-driven animated SVG icons (@vvedantb/ui/icons/animated), a client entry without @vvedantb/server, convex or Clerk for Chrome extensions, design-token CSS, shared Tailwind v4 CSS, a Tailwind preset and packaged Instrument Sans fonts.",
|
|
6
6
|
"type": "module",
|
package/shell/src/AppShell.tsx
CHANGED
|
@@ -6,7 +6,7 @@ import {
|
|
|
6
6
|
useSidebarResizeState,
|
|
7
7
|
type SidebarResizeOptions,
|
|
8
8
|
} from "./SidebarResize";
|
|
9
|
-
import { AppShellVariantContext, useAppShellVariant, type AppShellVariantProps } from "./shell-variant";
|
|
9
|
+
import { AppShellPanelDockContext, AppShellVariantContext, useAppShellVariant, type AppShellVariantProps } from "./shell-variant";
|
|
10
10
|
|
|
11
11
|
type AppShellBaseProps = {
|
|
12
12
|
/** Rendered between the skip link and `<main>`, usually an `AppSidebar`. */
|
|
@@ -79,6 +79,7 @@ function Root({
|
|
|
79
79
|
mobileHeaderHeight = "calc(3.5rem + env(safe-area-inset-top, 0px))",
|
|
80
80
|
mainId = "main-content",
|
|
81
81
|
variant = "floating",
|
|
82
|
+
panelMotion,
|
|
82
83
|
className,
|
|
83
84
|
style,
|
|
84
85
|
...props
|
|
@@ -92,19 +93,21 @@ function Root({
|
|
|
92
93
|
return (
|
|
93
94
|
<AppShellContext.Provider value={{ mainId, panelHidden, scroll }}>
|
|
94
95
|
<AppShellVariantContext value={variant}>
|
|
95
|
-
<
|
|
96
|
-
<
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
96
|
+
<AppShellPanelDockContext value={variant === "rail" && panelMotion !== "none"}>
|
|
97
|
+
<SidebarResizeProvider value={resize}>
|
|
98
|
+
<div
|
|
99
|
+
{...props}
|
|
100
|
+
data-shell-variant={variant === "rail" ? "rail" : undefined}
|
|
101
|
+
className={cn(
|
|
102
|
+
scroll === "document"
|
|
103
|
+
? "relative min-h-dvh bg-background"
|
|
104
|
+
: "relative h-dvh overflow-hidden bg-background",
|
|
105
|
+
className,
|
|
106
|
+
)}
|
|
107
|
+
style={{ ...vars, ...style }}
|
|
108
|
+
/>
|
|
109
|
+
</SidebarResizeProvider>
|
|
110
|
+
</AppShellPanelDockContext>
|
|
108
111
|
</AppShellVariantContext>
|
|
109
112
|
</AppShellContext.Provider>
|
|
110
113
|
);
|
|
@@ -203,10 +206,12 @@ function LegacyAppShell({
|
|
|
203
206
|
skipLinkLabel,
|
|
204
207
|
mainId = "main-content",
|
|
205
208
|
variant = "floating",
|
|
209
|
+
panelMotion,
|
|
206
210
|
className,
|
|
207
211
|
mainClassName,
|
|
208
212
|
contentClassName,
|
|
209
213
|
}: AppShellProps) {
|
|
214
|
+
const layout: AppShellVariantProps = variant === "rail" ? { variant: "rail", panelMotion } : {};
|
|
210
215
|
return (
|
|
211
216
|
<Root
|
|
212
217
|
panelHidden={panelHidden}
|
|
@@ -216,7 +221,7 @@ function LegacyAppShell({
|
|
|
216
221
|
scroll={scroll}
|
|
217
222
|
mobileHeaderHeight={mobileHeaderHeight}
|
|
218
223
|
mainId={mainId}
|
|
219
|
-
|
|
224
|
+
{...layout}
|
|
220
225
|
className={className}
|
|
221
226
|
>
|
|
222
227
|
<SkipLink label={skipLinkLabel} targetId={mainId} />
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ComponentPropsWithoutRef } from "react";
|
|
2
|
+
import { cn } from "../../src/utils/cn";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* The trough of a `ButtonTrack`: the `Sidebar.RailGroup` tone as a row.
|
|
6
|
+
* Buttons on it are flat (the trough is their surface) and hover at half the
|
|
7
|
+
* pill tone. Empty, it takes no space.
|
|
8
|
+
*/
|
|
9
|
+
export const buttonTrackClass =
|
|
10
|
+
"flex shrink-0 items-center gap-0.5 rounded-xl bg-default p-0.5 empty:hidden [&_button]:bg-transparent [&_button:not([data-active]):not(:disabled):hover]:bg-segment/50";
|
|
11
|
+
|
|
12
|
+
export type ButtonTrackProps = ComponentPropsWithoutRef<"div"> & {
|
|
13
|
+
/** `"column"` stacks the buttons from `md` up (a side rail). Default `"row"`. */
|
|
14
|
+
direction?: "row" | "column";
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
/** A group of icon buttons on one trough, for example the actions of a page header. */
|
|
18
|
+
export function ButtonTrack({ direction = "row", className, ...props }: ButtonTrackProps) {
|
|
19
|
+
return (
|
|
20
|
+
<div
|
|
21
|
+
role="group"
|
|
22
|
+
{...props}
|
|
23
|
+
className={cn(buttonTrackClass, direction === "column" ? "gap-1 md:flex-col" : "flex-wrap justify-end", className)}
|
|
24
|
+
/>
|
|
25
|
+
);
|
|
26
|
+
}
|