@better-forge/ui 0.1.0 → 0.1.1

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.
Files changed (51) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +13 -13
  3. package/icons.json +170 -170
  4. package/package.json +71 -71
  5. package/src/api/client.ts +139 -139
  6. package/src/components/ConfirmIdentityModal.tsx +82 -82
  7. package/src/components/ConfirmModal.tsx +83 -83
  8. package/src/components/CopyButton.tsx +71 -71
  9. package/src/components/CredentialSection.tsx +270 -270
  10. package/src/components/ErrorBoundary.tsx +47 -47
  11. package/src/components/ModalShell.tsx +160 -160
  12. package/src/components/ResetTwoFactorModal.tsx +74 -74
  13. package/src/components/SidePanel.tsx +96 -96
  14. package/src/components/SingleSignOnModal.tsx +161 -161
  15. package/src/components/SsoConfirmation.tsx +96 -96
  16. package/src/components/VaultTypePicker.tsx +131 -131
  17. package/src/components/WhatsNew.tsx +84 -84
  18. package/src/components/formParts.tsx +59 -59
  19. package/src/components/ui/Alert.tsx +45 -45
  20. package/src/components/ui/DataTable.tsx +225 -225
  21. package/src/components/ui/Field.tsx +63 -63
  22. package/src/components/ui/PageHeader.tsx +36 -36
  23. package/src/components/ui/Pagination.tsx +37 -37
  24. package/src/components/ui/QuickStartPanel.tsx +57 -57
  25. package/src/components/ui/StateViews.tsx +135 -135
  26. package/src/components/ui/Switch.tsx +65 -65
  27. package/src/components/ui/Toast.tsx +104 -104
  28. package/src/components/ui/index.ts +9 -9
  29. package/src/config.ts +46 -46
  30. package/src/hooks/useDarkMode.ts +38 -38
  31. package/src/hooks/useDebouncedValue.ts +22 -22
  32. package/src/index.ts +42 -42
  33. package/src/lib/changelog.ts +93 -93
  34. package/src/lib/dateFormat.ts +90 -90
  35. package/src/navigation.ts +6 -6
  36. package/src/pages/ApiTokens.tsx +361 -361
  37. package/src/pages/AuditLog.tsx +388 -388
  38. package/src/pages/Backups.tsx +170 -170
  39. package/src/pages/ChangePassword.tsx +84 -84
  40. package/src/pages/Login.tsx +275 -275
  41. package/src/pages/Settings.tsx +264 -264
  42. package/src/pages/Setup.tsx +438 -438
  43. package/src/pages/SsoConfirm.tsx +26 -26
  44. package/src/pages/SsoTestResult.tsx +104 -104
  45. package/src/pages/Users.tsx +426 -426
  46. package/src/pages/Vault.tsx +1036 -1036
  47. package/src/shell/AdminShell.tsx +256 -256
  48. package/src/shell/guards.tsx +88 -88
  49. package/styles/base.css +521 -521
  50. package/styles/icons.css +4 -4
  51. package/tailwind-preset.js +79 -79
@@ -1,256 +1,256 @@
1
- import { Fragment, Suspense, useCallback, useEffect, useRef, useState, type RefObject } from 'react'
2
- import { Outlet, NavLink, useNavigate, useLocation, Link } from 'react-router-dom'
3
- import { api, clearSession, getCurrentUser } from '../api/client'
4
- import { LoadingState } from '../components/ui/StateViews'
5
- import { WhatsNew, markWhatsNewSeen, pendingWhatsNew } from '../components/WhatsNew'
6
- import { useDarkMode } from '../hooks/useDarkMode'
7
- import { useDatePrefs } from '../lib/dateFormat'
8
-
9
- export interface NavItem {
10
- to: string
11
- label: string
12
- icon: string
13
- /** The lowest role that sees the item (see `roleRank`). */
14
- minRole: string
15
- }
16
-
17
- export interface NavSection { label: string; items: NavItem[] }
18
-
19
- /** A link below the sections that leaves the interface (the public page, the documentation). */
20
- export interface ExternalLink { label: string; icon: string; href: () => string }
21
-
22
- export interface AdminShellConfig {
23
- sections: NavSection[]
24
- /** Roles from the lowest to the highest rank: a user sees an item when their rank reaches the item's `minRole`. */
25
- roleRank: Readonly<Record<string, number>>
26
- brand: { iconUrl: string; name: string; title: string; subtitle: string }
27
- /** The page the first item leads to: it is highlighted only when it is exactly the current one. */
28
- homePath: string
29
- settingsPath: string
30
- loginPath: string
31
- externalLinks: readonly ExternalLink[]
32
- /** The release notes shown once to a user who last saw an older version. */
33
- whatsNew: { changelog: string; version: string; docsUrl: string }
34
- }
35
-
36
- const ICON_STYLE = { fontSize: '20px' }
37
-
38
- function Brand({ brand }: { brand: AdminShellConfig['brand'] }) {
39
- return (
40
- <div className="flex items-center gap-3 min-w-0">
41
- <img src={brand.iconUrl} alt={brand.name} style={{ width: '40px', height: '40px', objectFit: 'contain', flexShrink: 0 }} />
42
- <div className="min-w-0">
43
- <p className="font-headline font-bold text-base leading-none" style={{ color: 'var(--m3-on-surface)' }}>
44
- {brand.title}
45
- </p>
46
- <p className="text-xs leading-none mt-1" style={{ color: 'var(--m3-secondary)' }}>
47
- {brand.subtitle}
48
- </p>
49
- </div>
50
- </div>
51
- )
52
- }
53
-
54
- interface NavContentProps {
55
- config: AdminShellConfig
56
- sections: NavSection[]
57
- isDark: boolean
58
- onToggleDark: () => void
59
- onLogout: () => void
60
- }
61
-
62
- /** Section links plus the Settings / theme / logout footer, shared by the desktop sidebar and the mobile drawer. */
63
- function NavContent({ config, sections, isDark, onToggleDark, onLogout }: NavContentProps) {
64
- return (
65
- <>
66
- <nav aria-label="Main" className="flex-1 px-3 overflow-y-auto pb-2">
67
- {sections.map((section, si) => (
68
- <div key={section.label} className={si > 0 ? 'mt-4' : ''}>
69
- <p
70
- className="px-4 pb-1 font-mono uppercase tracking-widest"
71
- style={{ fontSize: '10px', color: 'var(--m3-outline)', letterSpacing: '0.1em' }}
72
- >
73
- {section.label}
74
- </p>
75
- <div className="space-y-0.5">
76
- {section.items.map((item) => (
77
- <NavLink key={item.to} to={item.to} end={item.to === config.homePath} className="admin-nav-item">
78
- {({ isActive }) => (
79
- <>
80
- <span
81
- aria-hidden="true" className="material-symbols-outlined flex-shrink-0"
82
- style={{ ...ICON_STYLE, fontVariationSettings: isActive ? "'FILL' 1" : "'FILL' 0" }}
83
- >
84
- {item.icon}
85
- </span>
86
- <span className="font-sans">{item.label}</span>
87
- </>
88
- )}
89
- </NavLink>
90
- ))}
91
- </div>
92
- </div>
93
- ))}
94
- </nav>
95
-
96
- <div className="px-3 pb-4 pt-4 space-y-0.5" style={{ borderTop: '1px solid var(--m3-outline-variant)' }}>
97
- {config.externalLinks.map((link) => (
98
- <a key={link.label} href={link.href()} target="_blank" rel="noopener" className="admin-nav-item">
99
- <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>{link.icon}</span>
100
- <span className="font-sans">{link.label}</span>
101
- </a>
102
- ))}
103
-
104
- <Link to={config.settingsPath} className="admin-nav-item">
105
- <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>manage_accounts</span>
106
- <span className="font-sans">Settings</span>
107
- </Link>
108
-
109
- <button type="button" onClick={onToggleDark} className="admin-nav-item">
110
- <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>
111
- {isDark ? 'light_mode' : 'dark_mode'}
112
- </span>
113
- <span className="font-sans">{isDark ? 'Light Mode' : 'Dark Mode'}</span>
114
- </button>
115
-
116
- <button type="button" onClick={onLogout} className="admin-nav-item admin-nav-danger">
117
- <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>logout</span>
118
- <span className="font-sans">Logout</span>
119
- </button>
120
- </div>
121
- </>
122
- )
123
- }
124
-
125
- interface MobileDrawerProps extends NavContentProps {
126
- onClose: () => void
127
- returnFocusRef: RefObject<HTMLButtonElement | null>
128
- }
129
-
130
- function MobileDrawer({ onClose, returnFocusRef, ...nav }: MobileDrawerProps) {
131
- const closeRef = useRef<HTMLButtonElement>(null)
132
-
133
- useEffect(() => {
134
- closeRef.current?.focus()
135
- const returnTo = returnFocusRef.current
136
- const onKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape') onClose() }
137
- document.addEventListener('keydown', onKeyDown)
138
- return () => {
139
- document.removeEventListener('keydown', onKeyDown)
140
- returnTo?.focus()
141
- }
142
- }, [onClose, returnFocusRef])
143
-
144
- return (
145
- <div className="md:hidden fixed inset-0 z-50">
146
- <div data-testid="nav-drawer-overlay" className="admin-drawer-overlay absolute inset-0" style={{ background: 'rgba(0,0,0,0.55)' }} onClick={onClose} />
147
- <div
148
- id="admin-nav-drawer"
149
- role="dialog"
150
- aria-modal="true"
151
- aria-label="Navigation"
152
- className="admin-drawer-panel absolute inset-y-0 left-0 flex flex-col w-72 max-w-[85vw]"
153
- style={{ background: 'var(--m3-surface-container-low)', boxShadow: '0 8px 32px rgba(0,0,0,0.18)' }}
154
- >
155
- <div className="flex items-center justify-between gap-2 px-4 pt-4 mb-4">
156
- <Brand brand={nav.config.brand} />
157
- <button ref={closeRef} type="button" onClick={onClose} aria-label="Close navigation" className="btn-icon">
158
- <span aria-hidden="true" className="material-symbols-outlined">close</span>
159
- </button>
160
- </div>
161
- <NavContent {...nav} />
162
- </div>
163
- </div>
164
- )
165
- }
166
-
167
- /**
168
- * The signed-in shell of an admin interface: a sidebar (a drawer on a phone) with the sections the user's role may see,
169
- * the footer links, the theme switch and logout, and the page below it. The sections, roles, brand and links are the
170
- * application's; the page is whatever the router renders in the `Outlet`.
171
- */
172
- export function createAdminShell(config: AdminShellConfig) {
173
- return function AdminShell() {
174
- const navigate = useNavigate()
175
- const location = useLocation()
176
- const [isDark, toggleDark] = useDarkMode()
177
- const datePrefs = useDatePrefs()
178
- const currentUser = getCurrentUser()
179
- const userRank = config.roleRank[currentUser?.role ?? ''] ?? 0
180
- // The drawer remembers the path it was opened on, so navigating anywhere closes it without an effect.
181
- const [drawerPath, setDrawerPath] = useState<string | null>(null)
182
- const drawerOpen = drawerPath === location.pathname
183
- const menuButtonRef = useRef<HTMLButtonElement>(null)
184
- const closeDrawer = useCallback(() => setDrawerPath(null), [])
185
-
186
- const navSections = config.sections
187
- .map((section) => ({
188
- ...section,
189
- items: section.items.filter((item) => userRank >= (config.roleRank[item.minRole] ?? 99)),
190
- }))
191
- .filter((section) => section.items.length > 0)
192
-
193
- const { changelog, version, docsUrl } = config.whatsNew
194
- const userId = currentUser?.userId
195
- const [whatsNew, setWhatsNew] = useState(() => userId !== undefined ? pendingWhatsNew(userId, changelog, version) : [])
196
- const closeWhatsNew = useCallback(() => {
197
- setWhatsNew([])
198
- if (userId !== undefined) markWhatsNewSeen(userId, version)
199
- }, [userId, version])
200
-
201
- async function handleLogout() {
202
- try { await api.post('/auth/logout') } catch { /* local logout still proceeds */ }
203
- clearSession()
204
- navigate(config.loginPath)
205
- }
206
-
207
- const nav: NavContentProps = { config, sections: navSections, isDark, onToggleDark: toggleDark, onLogout: () => void handleLogout() }
208
-
209
- return (
210
- <div className="flex flex-col md:flex-row h-screen" style={{ background: 'var(--m3-surface-container-low)' }}>
211
- {/* Mobile top bar */}
212
- <header
213
- className="md:hidden flex items-center justify-between gap-3 px-4 py-3 flex-shrink-0"
214
- style={{ background: 'var(--m3-surface-container-low)', borderBottom: '1px solid var(--m3-outline-variant)' }}
215
- >
216
- <Brand brand={config.brand} />
217
- <button
218
- ref={menuButtonRef}
219
- type="button"
220
- onClick={() => setDrawerPath(location.pathname)}
221
- aria-label="Open navigation"
222
- aria-expanded={drawerOpen}
223
- aria-controls="admin-nav-drawer"
224
- className="btn-icon"
225
- >
226
- <span aria-hidden="true" className="material-symbols-outlined">menu</span>
227
- </button>
228
- </header>
229
-
230
- {whatsNew.length > 0 && <WhatsNew releases={whatsNew} docsUrl={docsUrl} onClose={closeWhatsNew} />}
231
-
232
- {drawerOpen && <MobileDrawer {...nav} onClose={closeDrawer} returnFocusRef={menuButtonRef} />}
233
-
234
- {/* Sidebar */}
235
- <aside
236
- className="hidden md:flex flex-col h-screen w-64 sticky top-0 flex-shrink-0"
237
- style={{ background: 'var(--m3-surface-container-low)' }}
238
- >
239
- <div className="mb-6 px-4 pt-5">
240
- <Brand brand={config.brand} />
241
- </div>
242
- <NavContent {...nav} />
243
- </aside>
244
-
245
- {/* Main */}
246
- <main className="flex-1 min-h-0 min-w-0 overflow-auto" style={{ background: 'var(--m3-surface-container-low)' }}>
247
- {/* Lazy pages suspend here, not above the shell, so the menu stays while a page's code is fetched. */}
248
- <Suspense fallback={<LoadingState />}>
249
- {/* Remount the page when the date format changes so every formatted date is recomputed. */}
250
- <Fragment key={`${datePrefs.date}-${datePrefs.time}`}><Outlet /></Fragment>
251
- </Suspense>
252
- </main>
253
- </div>
254
- )
255
- }
256
- }
1
+ import { Fragment, Suspense, useCallback, useEffect, useRef, useState, type RefObject } from 'react'
2
+ import { Outlet, NavLink, useNavigate, useLocation, Link } from 'react-router-dom'
3
+ import { api, clearSession, getCurrentUser } from '../api/client'
4
+ import { LoadingState } from '../components/ui/StateViews'
5
+ import { WhatsNew, markWhatsNewSeen, pendingWhatsNew } from '../components/WhatsNew'
6
+ import { useDarkMode } from '../hooks/useDarkMode'
7
+ import { useDatePrefs } from '../lib/dateFormat'
8
+
9
+ export interface NavItem {
10
+ to: string
11
+ label: string
12
+ icon: string
13
+ /** The lowest role that sees the item (see `roleRank`). */
14
+ minRole: string
15
+ }
16
+
17
+ export interface NavSection { label: string; items: NavItem[] }
18
+
19
+ /** A link below the sections that leaves the interface (the public page, the documentation). */
20
+ export interface ExternalLink { label: string; icon: string; href: () => string }
21
+
22
+ export interface AdminShellConfig {
23
+ sections: NavSection[]
24
+ /** Roles from the lowest to the highest rank: a user sees an item when their rank reaches the item's `minRole`. */
25
+ roleRank: Readonly<Record<string, number>>
26
+ brand: { iconUrl: string; name: string; title: string; subtitle: string }
27
+ /** The page the first item leads to: it is highlighted only when it is exactly the current one. */
28
+ homePath: string
29
+ settingsPath: string
30
+ loginPath: string
31
+ externalLinks: readonly ExternalLink[]
32
+ /** The release notes shown once to a user who last saw an older version. */
33
+ whatsNew: { changelog: string; version: string; docsUrl: string }
34
+ }
35
+
36
+ const ICON_STYLE = { fontSize: '20px' }
37
+
38
+ function Brand({ brand }: { brand: AdminShellConfig['brand'] }) {
39
+ return (
40
+ <div className="flex items-center gap-3 min-w-0">
41
+ <img src={brand.iconUrl} alt={brand.name} style={{ width: '40px', height: '40px', objectFit: 'contain', flexShrink: 0 }} />
42
+ <div className="min-w-0">
43
+ <p className="font-headline font-bold text-base leading-none" style={{ color: 'var(--m3-on-surface)' }}>
44
+ {brand.title}
45
+ </p>
46
+ <p className="text-xs leading-none mt-1" style={{ color: 'var(--m3-secondary)' }}>
47
+ {brand.subtitle}
48
+ </p>
49
+ </div>
50
+ </div>
51
+ )
52
+ }
53
+
54
+ interface NavContentProps {
55
+ config: AdminShellConfig
56
+ sections: NavSection[]
57
+ isDark: boolean
58
+ onToggleDark: () => void
59
+ onLogout: () => void
60
+ }
61
+
62
+ /** Section links plus the Settings / theme / logout footer, shared by the desktop sidebar and the mobile drawer. */
63
+ function NavContent({ config, sections, isDark, onToggleDark, onLogout }: NavContentProps) {
64
+ return (
65
+ <>
66
+ <nav aria-label="Main" className="flex-1 px-3 overflow-y-auto pb-2">
67
+ {sections.map((section, si) => (
68
+ <div key={section.label} className={si > 0 ? 'mt-4' : ''}>
69
+ <p
70
+ className="px-4 pb-1 font-mono uppercase tracking-widest"
71
+ style={{ fontSize: '10px', color: 'var(--m3-outline)', letterSpacing: '0.1em' }}
72
+ >
73
+ {section.label}
74
+ </p>
75
+ <div className="space-y-0.5">
76
+ {section.items.map((item) => (
77
+ <NavLink key={item.to} to={item.to} end={item.to === config.homePath} className="admin-nav-item">
78
+ {({ isActive }) => (
79
+ <>
80
+ <span
81
+ aria-hidden="true" className="material-symbols-outlined flex-shrink-0"
82
+ style={{ ...ICON_STYLE, fontVariationSettings: isActive ? "'FILL' 1" : "'FILL' 0" }}
83
+ >
84
+ {item.icon}
85
+ </span>
86
+ <span className="font-sans">{item.label}</span>
87
+ </>
88
+ )}
89
+ </NavLink>
90
+ ))}
91
+ </div>
92
+ </div>
93
+ ))}
94
+ </nav>
95
+
96
+ <div className="px-3 pb-4 pt-4 space-y-0.5" style={{ borderTop: '1px solid var(--m3-outline-variant)' }}>
97
+ {config.externalLinks.map((link) => (
98
+ <a key={link.label} href={link.href()} target="_blank" rel="noopener" className="admin-nav-item">
99
+ <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>{link.icon}</span>
100
+ <span className="font-sans">{link.label}</span>
101
+ </a>
102
+ ))}
103
+
104
+ <Link to={config.settingsPath} className="admin-nav-item">
105
+ <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>manage_accounts</span>
106
+ <span className="font-sans">Settings</span>
107
+ </Link>
108
+
109
+ <button type="button" onClick={onToggleDark} className="admin-nav-item">
110
+ <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>
111
+ {isDark ? 'light_mode' : 'dark_mode'}
112
+ </span>
113
+ <span className="font-sans">{isDark ? 'Light Mode' : 'Dark Mode'}</span>
114
+ </button>
115
+
116
+ <button type="button" onClick={onLogout} className="admin-nav-item admin-nav-danger">
117
+ <span aria-hidden="true" className="material-symbols-outlined flex-shrink-0" style={ICON_STYLE}>logout</span>
118
+ <span className="font-sans">Logout</span>
119
+ </button>
120
+ </div>
121
+ </>
122
+ )
123
+ }
124
+
125
+ interface MobileDrawerProps extends NavContentProps {
126
+ onClose: () => void
127
+ returnFocusRef: RefObject<HTMLButtonElement | null>
128
+ }
129
+
130
+ function MobileDrawer({ onClose, returnFocusRef, ...nav }: MobileDrawerProps) {
131
+ const closeRef = useRef<HTMLButtonElement>(null)
132
+
133
+ useEffect(() => {
134
+ closeRef.current?.focus()
135
+ const returnTo = returnFocusRef.current
136
+ const onKeyDown = (event: KeyboardEvent) => { if (event.key === 'Escape') onClose() }
137
+ document.addEventListener('keydown', onKeyDown)
138
+ return () => {
139
+ document.removeEventListener('keydown', onKeyDown)
140
+ returnTo?.focus()
141
+ }
142
+ }, [onClose, returnFocusRef])
143
+
144
+ return (
145
+ <div className="md:hidden fixed inset-0 z-50">
146
+ <div data-testid="nav-drawer-overlay" className="admin-drawer-overlay absolute inset-0" style={{ background: 'rgba(0,0,0,0.55)' }} onClick={onClose} />
147
+ <div
148
+ id="admin-nav-drawer"
149
+ role="dialog"
150
+ aria-modal="true"
151
+ aria-label="Navigation"
152
+ className="admin-drawer-panel absolute inset-y-0 left-0 flex flex-col w-72 max-w-[85vw]"
153
+ style={{ background: 'var(--m3-surface-container-low)', boxShadow: '0 8px 32px rgba(0,0,0,0.18)' }}
154
+ >
155
+ <div className="flex items-center justify-between gap-2 px-4 pt-4 mb-4">
156
+ <Brand brand={nav.config.brand} />
157
+ <button ref={closeRef} type="button" onClick={onClose} aria-label="Close navigation" className="btn-icon">
158
+ <span aria-hidden="true" className="material-symbols-outlined">close</span>
159
+ </button>
160
+ </div>
161
+ <NavContent {...nav} />
162
+ </div>
163
+ </div>
164
+ )
165
+ }
166
+
167
+ /**
168
+ * The signed-in shell of an admin interface: a sidebar (a drawer on a phone) with the sections the user's role may see,
169
+ * the footer links, the theme switch and logout, and the page below it. The sections, roles, brand and links are the
170
+ * application's; the page is whatever the router renders in the `Outlet`.
171
+ */
172
+ export function createAdminShell(config: AdminShellConfig) {
173
+ return function AdminShell() {
174
+ const navigate = useNavigate()
175
+ const location = useLocation()
176
+ const [isDark, toggleDark] = useDarkMode()
177
+ const datePrefs = useDatePrefs()
178
+ const currentUser = getCurrentUser()
179
+ const userRank = config.roleRank[currentUser?.role ?? ''] ?? 0
180
+ // The drawer remembers the path it was opened on, so navigating anywhere closes it without an effect.
181
+ const [drawerPath, setDrawerPath] = useState<string | null>(null)
182
+ const drawerOpen = drawerPath === location.pathname
183
+ const menuButtonRef = useRef<HTMLButtonElement>(null)
184
+ const closeDrawer = useCallback(() => setDrawerPath(null), [])
185
+
186
+ const navSections = config.sections
187
+ .map((section) => ({
188
+ ...section,
189
+ items: section.items.filter((item) => userRank >= (config.roleRank[item.minRole] ?? 99)),
190
+ }))
191
+ .filter((section) => section.items.length > 0)
192
+
193
+ const { changelog, version, docsUrl } = config.whatsNew
194
+ const userId = currentUser?.userId
195
+ const [whatsNew, setWhatsNew] = useState(() => userId !== undefined ? pendingWhatsNew(userId, changelog, version) : [])
196
+ const closeWhatsNew = useCallback(() => {
197
+ setWhatsNew([])
198
+ if (userId !== undefined) markWhatsNewSeen(userId, version)
199
+ }, [userId, version])
200
+
201
+ async function handleLogout() {
202
+ try { await api.post('/auth/logout') } catch { /* local logout still proceeds */ }
203
+ clearSession()
204
+ navigate(config.loginPath)
205
+ }
206
+
207
+ const nav: NavContentProps = { config, sections: navSections, isDark, onToggleDark: toggleDark, onLogout: () => void handleLogout() }
208
+
209
+ return (
210
+ <div className="flex flex-col md:flex-row h-screen" style={{ background: 'var(--m3-surface-container-low)' }}>
211
+ {/* Mobile top bar */}
212
+ <header
213
+ className="md:hidden flex items-center justify-between gap-3 px-4 py-3 flex-shrink-0"
214
+ style={{ background: 'var(--m3-surface-container-low)', borderBottom: '1px solid var(--m3-outline-variant)' }}
215
+ >
216
+ <Brand brand={config.brand} />
217
+ <button
218
+ ref={menuButtonRef}
219
+ type="button"
220
+ onClick={() => setDrawerPath(location.pathname)}
221
+ aria-label="Open navigation"
222
+ aria-expanded={drawerOpen}
223
+ aria-controls="admin-nav-drawer"
224
+ className="btn-icon"
225
+ >
226
+ <span aria-hidden="true" className="material-symbols-outlined">menu</span>
227
+ </button>
228
+ </header>
229
+
230
+ {whatsNew.length > 0 && <WhatsNew releases={whatsNew} docsUrl={docsUrl} onClose={closeWhatsNew} />}
231
+
232
+ {drawerOpen && <MobileDrawer {...nav} onClose={closeDrawer} returnFocusRef={menuButtonRef} />}
233
+
234
+ {/* Sidebar */}
235
+ <aside
236
+ className="hidden md:flex flex-col h-screen w-64 sticky top-0 flex-shrink-0"
237
+ style={{ background: 'var(--m3-surface-container-low)' }}
238
+ >
239
+ <div className="mb-6 px-4 pt-5">
240
+ <Brand brand={config.brand} />
241
+ </div>
242
+ <NavContent {...nav} />
243
+ </aside>
244
+
245
+ {/* Main */}
246
+ <main className="flex-1 min-h-0 min-w-0 overflow-auto" style={{ background: 'var(--m3-surface-container-low)' }}>
247
+ {/* Lazy pages suspend here, not above the shell, so the menu stays while a page's code is fetched. */}
248
+ <Suspense fallback={<LoadingState />}>
249
+ {/* Remount the page when the date format changes so every formatted date is recomputed. */}
250
+ <Fragment key={`${datePrefs.date}-${datePrefs.time}`}><Outlet /></Fragment>
251
+ </Suspense>
252
+ </main>
253
+ </div>
254
+ )
255
+ }
256
+ }