@djangocfg/layouts 2.1.635 → 2.1.637
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 +12 -12
- package/src/components/account/useAccountMenuItems.tsx +1 -5
- package/src/layouts/PrivateLayout/README.md +2 -2
- package/src/layouts/PrivateLayout/components/PrivateSidebarTrigger.tsx +2 -1
- package/src/layouts/PrivateLayout/components/SidebarNavGroup.tsx +9 -12
- package/src/layouts/PrivateLayout/components/SidebarResizeHandle.tsx +2 -2
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/layouts",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.637",
|
|
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.
|
|
95
|
-
"@djangocfg/api": "^2.1.
|
|
96
|
-
"@djangocfg/devtools": "^2.1.
|
|
97
|
-
"@djangocfg/i18n": "^2.1.
|
|
98
|
-
"@djangocfg/ui-core": "^2.1.
|
|
94
|
+
"@djangocfg/analytics": "^2.1.637",
|
|
95
|
+
"@djangocfg/api": "^2.1.637",
|
|
96
|
+
"@djangocfg/devtools": "^2.1.637",
|
|
97
|
+
"@djangocfg/i18n": "^2.1.637",
|
|
98
|
+
"@djangocfg/ui-core": "^2.1.637",
|
|
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.
|
|
127
|
-
"@djangocfg/api": "^2.1.
|
|
128
|
-
"@djangocfg/devtools": "^2.1.
|
|
129
|
-
"@djangocfg/i18n": "^2.1.
|
|
130
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
131
|
-
"@djangocfg/ui-core": "^2.1.
|
|
126
|
+
"@djangocfg/analytics": "^2.1.637",
|
|
127
|
+
"@djangocfg/api": "^2.1.637",
|
|
128
|
+
"@djangocfg/devtools": "^2.1.637",
|
|
129
|
+
"@djangocfg/i18n": "^2.1.637",
|
|
130
|
+
"@djangocfg/typescript-config": "^2.1.637",
|
|
131
|
+
"@djangocfg/ui-core": "^2.1.637",
|
|
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
|
|
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
|
|
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;
|
|
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`.
|
|
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);
|
|
@@ -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
|
|
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`;
|
|
@@ -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-
|
|
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-
|
|
143
|
+
<SidebarMenu className="gap-(--sidebar-item-gap)">{rows}</SidebarMenu>
|
|
147
144
|
</SidebarGroupContent>
|
|
148
145
|
</SidebarGroup>
|
|
149
146
|
</>
|
|
@@ -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
|
|
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
|
|
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
|
);
|