@djangocfg/layouts 2.1.634 → 2.1.636

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.634",
3
+ "version": "2.1.636",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -91,11 +91,11 @@
91
91
  "test": "vitest run"
92
92
  },
93
93
  "peerDependencies": {
94
- "@djangocfg/analytics": "^2.1.634",
95
- "@djangocfg/api": "^2.1.634",
96
- "@djangocfg/devtools": "^2.1.634",
97
- "@djangocfg/i18n": "^2.1.634",
98
- "@djangocfg/ui-core": "^2.1.634",
94
+ "@djangocfg/analytics": "^2.1.636",
95
+ "@djangocfg/api": "^2.1.636",
96
+ "@djangocfg/devtools": "^2.1.636",
97
+ "@djangocfg/i18n": "^2.1.636",
98
+ "@djangocfg/ui-core": "^2.1.636",
99
99
  "@hookform/resolvers": "^5.2.2 || ^7.0.2",
100
100
  "consola": "^3.4.2",
101
101
  "lucide-react": "^1.68.0",
@@ -123,12 +123,12 @@
123
123
  "qrcode.react": "^4.2.0"
124
124
  },
125
125
  "devDependencies": {
126
- "@djangocfg/analytics": "^2.1.634",
127
- "@djangocfg/api": "^2.1.634",
128
- "@djangocfg/devtools": "^2.1.634",
129
- "@djangocfg/i18n": "^2.1.634",
130
- "@djangocfg/typescript-config": "^2.1.634",
131
- "@djangocfg/ui-core": "^2.1.634",
126
+ "@djangocfg/analytics": "^2.1.636",
127
+ "@djangocfg/api": "^2.1.636",
128
+ "@djangocfg/devtools": "^2.1.636",
129
+ "@djangocfg/i18n": "^2.1.636",
130
+ "@djangocfg/typescript-config": "^2.1.636",
131
+ "@djangocfg/ui-core": "^2.1.636",
132
132
  "@storybook/react-vite": "^10.6.5",
133
133
  "@types/node": "^25.9.5",
134
134
  "@types/react": "19.3.0",
@@ -14,8 +14,6 @@ import { useSettingsDialogStore } from '../../layouts/SettingsLayout/store';
14
14
  import { useLayoutI18nOptional } from '../../shared/LayoutI18nProvider';
15
15
  import type { UserMenuGroup, UserMenuLocaleConfig } from '../../layouts/types';
16
16
 
17
- const SETTINGS_SHORTCUT = '⇧⌘,';
18
-
19
17
  export interface UseAccountMenuItemsOptions {
20
18
  /** Items placed after the language submenu, before Sign out (app links). */
21
19
  extra?: MenuItem[];
@@ -78,17 +76,15 @@ export function useAccountMenuItems({ extra, groups, label, language = true, i18
78
76
  id: 'settings',
79
77
  label: settingsLabel,
80
78
  icon: SettingsIcon,
81
- shortcut: SETTINGS_SHORTCUT,
82
79
  onSelect: () => useSettingsDialogStore.getState().open(),
83
80
  });
84
81
  }
85
- (settings ? sections : []).forEach((section, index) => {
82
+ (settings ? sections : []).forEach((section) => {
86
83
  items.push({
87
84
  kind: 'item',
88
85
  id: `settings-${section.id}`,
89
86
  label: section.label,
90
87
  icon: section.icon,
91
- shortcut: index === 0 ? SETTINGS_SHORTCUT : undefined,
92
88
  onSelect: () => useSettingsDialogStore.getState().open(section.id),
93
89
  });
94
90
  });
@@ -152,7 +152,7 @@ For pages like Kanban boards where the shell must be exactly one viewport tall a
152
152
  |---|---|---|
153
153
  | `label` | `string` | Group title. Empty string → flat group (no header). |
154
154
  | `items` | `SidebarItem[]` | Nav links, or `settingsSection` rows (below). A group whose rows are all launchers for unregistered sections is not rendered. |
155
- | `separated` | `boolean` | A secondary group (setup, connect): a full divider with air above it, then the label. Ordinary groups are only a hairline apart. Same in the docked sidebar, the peek panel and the drawer (there is no icon rail: a collapsed sidebar is hidden). |
155
+ | `separated` | `boolean` | A secondary group (setup, connect): a full divider with air above it, then the label. Ordinary groups are told apart by air only (8px between them, 6px in the drawer), no rule. Same in the docked sidebar, the peek panel and the drawer (there is no icon rail: a collapsed sidebar is hidden). |
156
156
  | `dynamic` | `boolean` | Hide group when `items` is empty (for extension-driven groups). |
157
157
  | `collapsible` | `boolean` | Render as accordion. Label becomes a clickable trigger; auto-expanded if a child is active. |
158
158
  | `defaultOpen` | `boolean` | Initial open state for collapsible groups. |
@@ -280,7 +280,7 @@ const header: HeaderConfig = {
280
280
  |---|---|
281
281
  | Docked | Width from `--sidebar-width`; drag the right edge, arrow keys, double-click to reset. |
282
282
  | Collapsed (desktop) | Hidden. The top bar (toggle top-left, title, actions, avatar) shows; resting the pointer at the left screen edge (not on the toggle) floats the sidebar over the page. The panel stays while the pointer is on it or a menu opened from it is open; Esc, navigation and moving away close it. Clicking the trigger docks it. |
283
- | Mobile (< md) | Drawer 88vw wide (max 22rem, the dimmed strip taps it closed) and full height (`fixed inset-y-0`: the real visible area in a browser tab and in an iOS standalone PWA): 40px rows (44px hit area), 14px text, 20px icons, 8px container gutter + 10px row padding (icon column and logo at 18px; dividers, highlighted rows and footer share the 8px gutter), header is the brand only (48px under safe-top, no toggle or close button; it closes by backdrop tap, swipe, Escape or navigating). Three zones: pinned header (gets a bottom hairline once the nav scrolls), the nav as the ONLY scroller (`overscroll-contain`), pinned footer with a full-width top border and its own background; the drawer panel itself is `overflow-hidden` (`DrawerContent bare`). Header and footer respect the safe areas on top, bottom and sides (at least 1rem vertically). On a phone (below md) the layout draws a plain top bar: `safe-top + 3rem` tall (`--layout-bar-height`, `0px` from md up and without a sidebar), `bg-background` with a 1px bottom border, holding the sidebar toggle (the same ghost button as in the sidebar header) and `header.title`. It overlays the content column and never hides on scroll. Content starts below the bar for every page, so pages do nothing; apps may use `--layout-bar-height` to offset their own sticky elements. `PrivateLayout` takes `topBar={{ title, actions }}` (types: `PrivateTopBarConfig`): `title` replaces `header.title` in the bar, `actions` is a ReactNode on the right (vertically centred, never shrinks the toggle; the title takes the rest and truncates). The same bar shows on desktop while the sidebar is collapsed (static: it never hides on scroll) and carries the account avatar for a signed-in user (`topBar.account={false}` to opt out); on a phone the drawer then has no footer account. Recommended actions are compact ghost icon `Button`s (36px); several are fine, keep them few. The toggle stays left and is not configurable. It is rendered by the phone bar only; desktop shows nothing (the sidebar is the navigation). |
283
+ | Mobile (< md) | Drawer 88vw wide (max 22rem, the dimmed strip taps it closed) and full height (`fixed inset-y-0`: the real visible area in a browser tab and in an iOS standalone PWA): 40px rows (44px hit area), 14px text, 20px icons, 8px container gutter + 10px row padding (icon column and logo at 18px; highlighted rows and footer share the 8px gutter), header is the brand only (48px under safe-top, no toggle or close button; it closes by backdrop tap, swipe, Escape or navigating). Three zones: pinned header (gets a bottom hairline once the nav scrolls), the nav as the ONLY scroller (`overscroll-contain`), pinned footer with a full-width top border and its own background; the drawer panel itself is `overflow-hidden` (`DrawerContent bare`). Header and footer respect the safe areas on top, bottom and sides (at least 1rem vertically). On a phone (below md) the layout draws a plain top bar: `safe-top + 3rem` tall (`--layout-bar-height`, `0px` from md up and without a sidebar), `bg-background` with a 1px bottom border, holding the sidebar toggle (the same ghost button as in the sidebar header) and `header.title`. It overlays the content column and never hides on scroll. Content starts below the bar for every page, so pages do nothing; apps may use `--layout-bar-height` to offset their own sticky elements. `PrivateLayout` takes `topBar={{ title, actions }}` (types: `PrivateTopBarConfig`): `title` replaces `header.title` in the bar, `actions` is a ReactNode on the right (vertically centred, never shrinks the toggle; the title takes the rest and truncates). The same bar shows on desktop while the sidebar is collapsed (static: it never hides on scroll) and carries the account avatar for a signed-in user (`topBar.account={false}` to opt out); on a phone the drawer then has no footer account. Recommended actions are compact ghost icon `Button`s (36px); several are fine, keep them few. The toggle stays left and is not configurable. It is rendered by the phone bar only; desktop shows nothing (the sidebar is the navigation). |
284
284
 
285
285
  Row metrics (`geometry.ts`): desktop rows 36px, mobile rows 40px (with a 44px hit area from an invisible `::after`), both `text-sm` with 16px (desktop) or 20px (mobile) icons and group labels in `text-xs`. Safe-area insets only exist when the host app sets `viewportFit: "cover"` in its Next.js `viewport` export; without it the offsets fall back to the fixed minimums. For an installed iOS PWA also set `appleWebApp.statusBarStyle` (`black-translucent` draws the page under the status bar and relies on the insets; `default` keeps it below). The drawer height is pinned with `inset-y-0` rather than `100dvh`, which can disagree with the visible area in standalone mode.
286
286
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The one sidebar button: same box, icon and position rules on mobile and desktop.
3
3
  * In the top bar it opens the sidebar; inside the sidebar header it closes or collapses it. Both are
4
- * `toggleSidebar`. No tooltip (the Cmd/Ctrl+B binding lives in ui-core's sidebar provider). The labels are plain
4
+ * `toggleSidebar`. `Button`'s `tooltip` names the action and shows the Cmd/Ctrl+B binding (it lives in ui-core's sidebar provider) for the viewer's system; none where the device cannot hover. The labels are plain
5
5
  * English: the layouts have no message catalogue (only a locale hook).
6
6
  */
7
7
 
@@ -31,6 +31,7 @@ export const PrivateSidebarTrigger = React.forwardRef<
31
31
  variant="ghost"
32
32
  size="icon"
33
33
  aria-label={label}
34
+ tooltip={{ content: label, hotkey: 'mod+b', side: 'bottom', sideOffset: 8 }}
34
35
  className={cn(TRIGGER_CLASS, className)}
35
36
  onClick={(event) => {
36
37
  onClick?.(event);
@@ -15,13 +15,36 @@ import { PrivateSidebarAccount } from './PrivateSidebarAccount';
15
15
  import { SidebarBrand } from './SidebarBrand';
16
16
  import { SidebarNavGroup } from './SidebarNavGroup';
17
17
  import { SidebarSlots } from './SidebarSlots';
18
+ import { SidebarViews } from './SidebarViews';
18
19
 
19
20
  export function SidebarBody() {
20
21
  const { sidebar, header, isMobile, accountInBar } = usePrivateLayoutContext();
21
22
 
23
+ const views = sidebar?.views;
24
+ // The last pick survives a reload (a viewer's own habit, not app state).
25
+ const [picked, setPicked] = React.useState<string | undefined>(() => {
26
+ try {
27
+ return typeof window === 'undefined' ? undefined : (window.localStorage.getItem('sidebar-view') ?? undefined);
28
+ } catch {
29
+ return undefined;
30
+ }
31
+ });
32
+ const activeId = sidebar?.activeView ?? picked ?? views?.[0]?.id;
33
+ const activeView = views?.find((v) => v.id === activeId) ?? views?.[0];
34
+ const pick = (id: string) => {
35
+ setPicked(id);
36
+ try {
37
+ window.localStorage.setItem('sidebar-view', id);
38
+ } catch {
39
+ // Private mode: the pick lasts for the session.
40
+ }
41
+ sidebar?.onViewChange?.(id);
42
+ };
43
+ const shown = useMemo(() => [...(sidebar?.groups ?? []), ...(activeView?.groups ?? [])], [sidebar?.groups, activeView]);
44
+
22
45
  const groups = useMemo(
23
46
  () =>
24
- (sidebar?.groups ?? []).map((group) =>
47
+ shown.map((group) =>
25
48
  // A group of launchers for sections nobody registered renders nothing itself (see SidebarNavGroup).
26
49
  group.dynamic && group.items.length === 0 ? null : (
27
50
  <SidebarNavGroup
@@ -30,7 +53,7 @@ export function SidebarBody() {
30
53
  />
31
54
  ),
32
55
  ),
33
- [sidebar?.groups],
56
+ [shown],
34
57
  );
35
58
 
36
59
  // Three zones: pinned header, the ONLY scroller (nav), pinned footer. The header gets a border once the nav scrolls.
@@ -51,6 +74,8 @@ export function SidebarBody() {
51
74
  SIDEBAR_SPACING[isMobile ? 'mobile' : 'desktop'].body,
52
75
  )}
53
76
  >
77
+ {views && views.length > 0 && activeView ? <SidebarViews views={views} active={activeView.id} onChange={pick} /> : null}
78
+ {activeView?.menuStart}
54
79
  <SidebarSlots />
55
80
  {groups}
56
81
  </div>
@@ -20,7 +20,7 @@ const BRAND_LINK =
20
20
  'flex min-w-0 items-center gap-2.5 rounded-lg py-1 text-sidebar-foreground no-underline outline-none ring-sidebar-ring transition-opacity hover:no-underline hover:opacity-80 focus-visible:ring-2';
21
21
 
22
22
  /** Brand name: semibold, one step larger on desktop (18px), 16px on a phone; one line, truncated. */
23
- const BRAND_NAME = 'truncate text-base font-semibold tracking-tight md:text-lg';
23
+ const BRAND_NAME = 'truncate text-base font-semibold tracking-tight md:text-sm md:font-medium';
24
24
 
25
25
  function SidebarBrandRaw({ bordered = false }: { bordered?: boolean }) {
26
26
  const { header, homeHref, brandTitle, brandMonogram, isMobile } = usePrivateLayoutContext();
@@ -47,13 +47,13 @@ function SidebarBrandRaw({ bordered = false }: { bordered?: boolean }) {
47
47
  <span
48
48
  className={cn(
49
49
  'flex shrink-0 items-center justify-center rounded-lg bg-sidebar-primary',
50
- isMobile ? 'size-7' : 'size-8',
50
+ isMobile ? 'size-7' : 'size-6',
51
51
  )}
52
52
  >
53
53
  {header?.brandIcon ? (
54
- <LucideIcon icon={header.brandIcon} className="size-4 text-sidebar-primary-foreground md:size-[18px]" />
54
+ <LucideIcon icon={header.brandIcon} className="size-4 text-sidebar-primary-foreground md:size-4" />
55
55
  ) : (
56
- <span className="text-xs font-bold leading-none text-sidebar-primary-foreground">
56
+ <span className="text-xs font-bold leading-none md:text-[11px] text-sidebar-primary-foreground">
57
57
  {brandMonogram}
58
58
  </span>
59
59
  )}
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Sidebar Nav Group — a labelled list, or an accordion when `collapsible`.
3
- * Groups are separated by a hairline, not by louder labels.
3
+ * Groups are separated by air; only a `separated` group draws a rule.
4
4
  */
5
5
 
6
6
  'use client';
@@ -27,16 +27,13 @@ import { isSettingsItem, isSidebarGroupVisible, sidebarItemKey, visibleSidebarIt
27
27
  import type { SidebarGroupConfig } from '../types';
28
28
  import { SidebarNavItem } from './SidebarNavItem';
29
29
 
30
+ /**
31
+ * Groups are told apart by air, not by rules: one gap between neighbours (8px, 6px in the phone drawer) and the same small padding inside, so every
32
+ * block starts on the same rhythm. A hairline between plain groups doubled the gap and made the spacing look uneven; a group that wants a rule asks
33
+ * for it with `separated`.
34
+ */
30
35
  const groupClassFor = (inset: string, insetRule: boolean) =>
31
- cn(
32
- // Phone drawer (insetRule): half the air between groups.
33
- `gap-0 ${inset} ${insetRule ? 'py-1' : 'py-1.5'}`,
34
- insetRule ? '[&:not(:first-child)]:mt-0.5 [&:not(:first-child)]:pt-1.5' : '[&:not(:first-child)]:mt-1.5 [&:not(:first-child)]:pt-3',
35
- // Phone drawer: the hairline is inset to the row gutter (8px). Desktop keeps its full-width border.
36
- insetRule
37
- ? '[&:not(:first-child)]:before:absolute [&:not(:first-child)]:before:inset-x-2 [&:not(:first-child)]:before:top-0 [&:not(:first-child)]:before:h-px [&:not(:first-child)]:before:bg-sidebar-border/60'
38
- : '[&:not(:first-child)]:border-t [&:not(:first-child)]:border-sidebar-border/60',
39
- );
36
+ cn(`gap-0 ${inset} py-0.5`, insetRule ? '[&:not(:first-child)]:mt-1.5' : '[&:not(:first-child)]:mt-2');
40
37
 
41
38
  /** A `separated` group draws its own, stronger divider (below), so it drops the hairline and takes more air. */
42
39
  const separatedGroupClassFor = (inset: string) => `gap-0 ${inset} pb-1 pt-0`;
@@ -48,7 +45,7 @@ function GroupDivider({ inset }: { inset: string }) {
48
45
  role="separator"
49
46
  aria-orientation="horizontal"
50
47
  data-sidebar="group-divider"
51
- className={cn(inset, 'mb-3 mt-3 h-px shrink-0 bg-sidebar-border')}
48
+ className={cn(inset, 'mb-3 mt-3 h-(--sidebar-divider-h) shrink-0 bg-sidebar-border')}
52
49
  />
53
50
  );
54
51
  }
@@ -122,7 +119,7 @@ function SidebarNavGroupRaw({ group }: { group: SidebarGroupConfig }) {
122
119
  </CollapsibleTrigger>
123
120
  <CollapsibleContent className="overflow-hidden data-[state=closed]:animate-accordion-up data-[state=open]:animate-accordion-down">
124
121
  <SidebarGroupContent>
125
- <SidebarMenu className="mt-1 gap-0.5">{rows}</SidebarMenu>
122
+ <SidebarMenu className="mt-0.5 gap-(--sidebar-item-gap)">{rows}</SidebarMenu>
126
123
  </SidebarGroupContent>
127
124
  </CollapsibleContent>
128
125
  </Collapsible>
@@ -143,7 +140,7 @@ function SidebarNavGroupRaw({ group }: { group: SidebarGroupConfig }) {
143
140
  </SidebarGroupLabel>
144
141
  ) : null}
145
142
  <SidebarGroupContent>
146
- <SidebarMenu className="gap-0.5">{rows}</SidebarMenu>
143
+ <SidebarMenu className="gap-(--sidebar-item-gap)">{rows}</SidebarMenu>
147
144
  </SidebarGroupContent>
148
145
  </SidebarGroup>
149
146
  </>
@@ -27,7 +27,7 @@ interface SidebarNavItemProps {
27
27
  }
28
28
 
29
29
  const ITEM_CLASS = cn(
30
- 'rounded-lg border-0 font-normal shadow-none transition-colors duration-150',
30
+ 'rounded-(--sidebar-item-radius) border-0 font-normal shadow-none transition-colors duration-150',
31
31
  'text-sidebar-foreground/90 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground',
32
32
  'data-[active=true]:bg-sidebar-accent data-[active=true]:font-normal data-[active=true]:text-sidebar-foreground',
33
33
  '[&>svg]:text-sidebar-foreground/80 [&>svg]:opacity-100 hover:[&>svg]:text-sidebar-foreground',
@@ -67,9 +67,9 @@ export function SidebarResizeHandle() {
67
67
  className={[
68
68
  'absolute inset-y-0 right-0 z-20 hidden w-2 cursor-col-resize touch-none outline-none md:block',
69
69
  // 2px primary line on the border; fades in after a short hover delay.
70
- 'after:absolute after:inset-y-0 after:right-0 after:w-0.5 after:bg-transparent',
70
+ 'after:absolute after:inset-y-0 after:-right-px after:w-[2px] after:bg-transparent',
71
71
  'after:transition-colors after:duration-150',
72
- 'hover:after:bg-primary/70 hover:after:delay-100 focus-visible:after:bg-primary data-[dragging]:after:bg-primary',
72
+ 'hover:after:bg-primary hover:after:delay-100 focus-visible:after:bg-primary data-[dragging]:after:bg-primary',
73
73
  ].join(' ')}
74
74
  />
75
75
  );
@@ -0,0 +1,33 @@
1
+ // @vitest-environment jsdom
2
+ import React, { act } from 'react';
3
+ import { createRoot } from 'react-dom/client';
4
+ import { Home, MessageCircle } from 'lucide-react';
5
+ import { describe, expect, it, vi } from 'vitest';
6
+
7
+ import { SidebarViews } from './SidebarViews';
8
+
9
+ // react-dom + jsdom only: the package declares no testing-library.
10
+ (globalThis as { IS_REACT_ACT_ENVIRONMENT?: boolean }).IS_REACT_ACT_ENVIRONMENT = true;
11
+
12
+ const views = [
13
+ { id: 'home', label: 'Home', icon: Home, groups: [] },
14
+ { id: 'chat', label: 'Chat', icon: MessageCircle, groups: [] },
15
+ ];
16
+
17
+ describe('SidebarViews', () => {
18
+ it('shows the label of the active view only, and reports a pick', () => {
19
+ const onChange = vi.fn();
20
+ const host = document.createElement('div');
21
+ document.body.appendChild(host);
22
+ const root = createRoot(host);
23
+ act(() => root.render(<SidebarViews views={views} active="home" onChange={onChange} />));
24
+ const [home, chat] = Array.from(host.querySelectorAll<HTMLElement>('[role=tab]'));
25
+ expect(home.getAttribute('aria-selected')).toBe('true');
26
+ expect(home.textContent).toBe('Home');
27
+ expect(chat.textContent).toBe('');
28
+ act(() => chat.click());
29
+ expect(onChange).toHaveBeenCalledWith('chat');
30
+ act(() => root.unmount());
31
+ host.remove();
32
+ });
33
+ });
@@ -0,0 +1,48 @@
1
+ /**
2
+ * The view switcher: a row of icon buttons at the top of the menu. The active view also shows its label, so the row
3
+ * names where you are without spending width on the others (Notion's Home / Chat / Calendar strip).
4
+ */
5
+
6
+ 'use client';
7
+
8
+ import React from 'react';
9
+
10
+ import { cn } from '@djangocfg/ui-core/lib';
11
+
12
+ import { LucideIcon } from '../../../components';
13
+ import type { SidebarViewConfig } from '../types';
14
+
15
+ interface SidebarViewsProps {
16
+ views: SidebarViewConfig[];
17
+ active: string;
18
+ onChange: (id: string) => void;
19
+ }
20
+
21
+ export function SidebarViews({ views, active, onChange }: SidebarViewsProps) {
22
+ return (
23
+ <div role="tablist" aria-label="Sidebar views" className="mb-1 flex items-center gap-1 px-2">
24
+ {views.map((view) => {
25
+ const on = view.id === active;
26
+ return (
27
+ <button
28
+ key={view.id}
29
+ type="button"
30
+ role="tab"
31
+ aria-selected={on}
32
+ aria-label={view.label}
33
+ title={view.label}
34
+ onClick={() => onChange(view.id)}
35
+ className={cn(
36
+ 'flex h-(--sidebar-item-h) items-center gap-2 rounded-(--sidebar-item-radius) px-2 text-(length:--sidebar-item-font) transition-colors',
37
+ '[&>svg]:size-4 [&>svg]:shrink-0',
38
+ on ? 'bg-sidebar-accent font-medium text-sidebar-foreground' : 'text-sidebar-foreground/70 hover:bg-sidebar-accent/70 hover:text-sidebar-foreground',
39
+ )}
40
+ >
41
+ <LucideIcon icon={view.icon} />
42
+ {on ? <span>{view.label}</span> : null}
43
+ </button>
44
+ );
45
+ })}
46
+ </div>
47
+ );
48
+ }
@@ -73,8 +73,8 @@ export function PrivateLayoutProvider({
73
73
  ).toUpperCase();
74
74
 
75
75
  const allItems = useMemo(
76
- () => sidebar?.groups.flatMap((g) => g.items).filter(isLinkItem) ?? [],
77
- [sidebar?.groups],
76
+ () => [...(sidebar?.groups ?? []), ...(sidebar?.views?.flatMap((v) => v.groups) ?? [])].flatMap((g) => g.items).filter(isLinkItem),
77
+ [sidebar?.groups, sidebar?.views],
78
78
  );
79
79
 
80
80
  // The most specific item wins: `/a` is not active on `/a/b` when `/a/b` is its own item.
@@ -7,7 +7,7 @@ const SIZES = /\btext-(base|lg|xl|2xl)\b/;
7
7
  describe('sidebar geometry', () => {
8
8
  for (const form of ['desktop', 'mobile'] as const) {
9
9
  it(`${form}: rows use 14px text and a 16-20px icon, not a large font`, () => {
10
- expect(NAV_GEOMETRY[form].item).toMatch(/\btext-sm\b/);
10
+ expect(NAV_GEOMETRY[form].item).toMatch(/\btext-(sm|\(length:--sidebar-item-font\))/);
11
11
  expect(NAV_GEOMETRY[form].item).not.toMatch(SIZES);
12
12
  expect(NAV_GEOMETRY[form].item).toMatch(/\[&>svg\]:size-(4|5)/);
13
13
  expect(NAV_GEOMETRY[form].label).toMatch(/\btext-xs\b/);
@@ -22,7 +22,7 @@ describe('sidebar geometry', () => {
22
22
 
23
23
  it('mobile rows are 40px with a 44px hit area (see touch-safe.css); desktop rows are 36px', () => {
24
24
  expect(NAV_GEOMETRY.mobile.item).toMatch(/\bh-10\b/);
25
- expect(NAV_GEOMETRY.desktop.item).toMatch(/\bh-9\b/);
25
+ expect(NAV_GEOMETRY.desktop.item).toContain('h-(--sidebar-item-h)');
26
26
  });
27
27
 
28
28
  it('mobile header and footer never go under the status bar or home indicator', () => {
@@ -5,7 +5,8 @@
5
5
 
6
6
  export const NAV_GEOMETRY = {
7
7
  desktop: {
8
- item: 'h-9 gap-2.5 px-2 text-sm [&>svg]:size-4',
8
+ /** Row height, type size and corner come from ui-core tokens (`--sidebar-item-*`), so a preset sets them (Notion: 30px, 14px, 6px). */
9
+ item: 'h-(--sidebar-item-h) gap-2.5 px-2 text-(length:--sidebar-item-font) [&>svg]:size-4',
9
10
  label: 'h-7 px-2 text-xs',
10
11
  /** Horizontal inset of groups, slots and the divider; equals the header and footer inset. */
11
12
  inset: 'px-2',
@@ -15,6 +15,7 @@ export type {
15
15
  SidebarLinkItem,
16
16
  SidebarSettingsItem,
17
17
  SidebarGroupConfig,
18
+ SidebarViewConfig,
18
19
  SidebarConfig,
19
20
  HeaderConfig,
20
21
  SidebarActiveIndicator,
@@ -96,9 +96,27 @@ export interface SidebarFeaturedConfig {
96
96
  // Sidebar Config
97
97
  // ============================================================================
98
98
 
99
+ /**
100
+ * One view of the sidebar: a row in the view switcher (icon; the active one also shows its label) and the groups that
101
+ * replace the menu while it is active, as in Notion's Home / Chat / Calendar strip.
102
+ */
103
+ export interface SidebarViewConfig<Id extends string = string> {
104
+ id: string;
105
+ label: string;
106
+ icon: LucideIcon;
107
+ groups: SidebarGroupConfig<Id>[];
108
+ /** Block above this view's groups (a "New chat" button, say). */
109
+ menuStart?: ReactNode;
110
+ }
111
+
99
112
  export interface SidebarConfig<Id extends string = string> {
100
- /** Grouped items with labels */
113
+ /** Grouped items with labels. With `views`, these are shown in every view, above the active view's own groups. */
101
114
  groups: SidebarGroupConfig<Id>[];
115
+ /** A switcher row at the top of the menu; each view brings its own groups. Absent: the plain menu. */
116
+ views?: SidebarViewConfig<Id>[];
117
+ /** The active view's `id` (controlled). Absent: the sidebar remembers the last pick itself. */
118
+ activeView?: string;
119
+ onViewChange?: (id: string) => void;
102
120
  /** Home link href */
103
121
  homeHref?: string;
104
122
  /**