From bb047f1fe974e6846227bb0069d4c6c321e28ed3 Mon Sep 17 00:00:00 2001 From: Jean Gerard Bousiquot Date: Sat, 5 Dec 2026 18:06:47 -0500 Subject: [PATCH 01/10] admin-next: the frame's nav model and layout rules, with tests Pure logic for the Shopify-style admin frame (admin-patterns draft 3, pattern 1): nav as data, the deepest match current, its section open, the drawer below 1040 px (to measure). Not exported yet: the frame UI comes on the shared design system's components. Co-Authored-By: Claude Opus 5.5 --- src/admin-next/frame/frame.test.ts | 93 +++++++++++++++++++++++ src/admin-next/frame/index.ts | 2 + src/admin-next/frame/layout.ts | 37 +++++++++ src/admin-next/frame/nav.ts | 117 +++++++++++++++++++++++++++++ 4 files changed, 249 insertions(+) create mode 100644 src/admin-next/frame/frame.test.ts create mode 100644 src/admin-next/frame/index.ts create mode 100644 src/admin-next/frame/layout.ts create mode 100644 src/admin-next/frame/nav.ts diff --git a/src/admin-next/frame/frame.test.ts b/src/admin-next/frame/frame.test.ts new file mode 100644 index 0000000..30b70d2 --- /dev/null +++ b/src/admin-next/frame/frame.test.ts @@ -0,0 +1,93 @@ +import { describe, expect, test } from 'bun:test' +import { drawerOpen, frameMode, NAV_DRAWER_BELOW } from './layout' +import { assertUniqueKeys, formatBadge, normalizePath, resolveNav, type AdminNav } from './nav' + +const nav: AdminNav = { + main: [ + { key: 'home', label: 'Home', to: '/admin', exact: true, icon: 'house' }, + { + key: 'users', + label: 'Users', + to: '/admin/users', + badge: 3, + children: [ + { key: 'roles', label: 'Roles', to: '/admin/users/roles' }, + { key: 'banned', label: 'Suspended', to: '/admin/users/suspended' }, + ], + }, + { key: 'pages', label: 'Pages', to: '/admin/pages' }, + ], + groups: [{ key: 'content', label: 'Content', items: [{ key: 'faq', label: 'FAQ', to: '/admin/content/faq' }] }], + settings: { key: 'settings', label: 'Settings', to: '/admin/settings' }, +} + +const currentKey = (path: string) => resolveNav(nav, path).current?.key + +describe('admin frame nav', () => { + test('marks the deepest match as current, and only one link', () => { + expect(currentKey('/admin')).toBe('home') + expect(currentKey('/admin/users')).toBe('users') + expect(currentKey('/admin/users/42')).toBe('users') + expect(currentKey('/admin/users/roles')).toBe('roles') + expect(currentKey('/admin/users/roles/editor')).toBe('roles') + expect(currentKey('/admin/settings/general')).toBe('settings') + expect(currentKey('/admin/content/faq/3')).toBe('faq') + const resolved = resolveNav(nav, '/admin/users/roles') + const marked = [...resolved.main, ...resolved.groups.flatMap((g) => g.items), resolved.settings!] + .flatMap((item) => [item, ...item.children]) + .filter((link) => link.current) + expect(marked.map((link) => link.key)).toEqual(['roles']) + }) + + test('the home link is current only on its own path', () => { + expect(currentKey('/admin/unknown')).toBeUndefined() + expect(currentKey('/elsewhere')).toBeUndefined() + }) + + test('a section is open while it or one of its sub-pages is shown', () => { + const users = (path: string) => resolveNav(nav, path).main.find((item) => item.key === 'users')! + expect(users('/admin').open).toBe(false) + expect(users('/admin/users').open).toBe(true) + expect(users('/admin/users/suspended').open).toBe(true) + expect(users('/admin/users/suspended').current).toBe(false) + }) + + test('a link must match on a path boundary, and query, hash and trailing slashes are ignored', () => { + expect(currentKey('/admin/usersettings')).toBeUndefined() + expect(currentKey('/admin/users/?q=ada#top')).toBe('users') + expect(normalizePath('/admin/users//')).toBe('/admin/users') + expect(normalizePath('/')).toBe('/') + expect(normalizePath('?x')).toBe('/') + }) + + test('keeps icons and badges, and words badges', () => { + const resolved = resolveNav(nav, '/admin') + expect(resolved.main[0]!.icon).toBe('house') + expect(resolved.main[1]!.badge).toBe(3) + expect(formatBadge(2481)).toBe('2,481') + expect(formatBadge(120, { compact: true })).toBe('99+') + expect(formatBadge('New')).toBe('New') + }) + + test('refuses a key used twice', () => { + expect(() => assertUniqueKeys(nav)).not.toThrow() + expect(() => + assertUniqueKeys({ main: [{ key: 'a', label: 'A', to: '/a', children: [{ key: 'a', label: 'B', to: '/a/b' }] }] }), + ).toThrow('"a"') + }) +}) + +describe('admin frame layout', () => { + test('the nav is a column from the breakpoint up, a drawer below it', () => { + expect(frameMode(1440)).toBe('sidebar') + expect(frameMode(NAV_DRAWER_BELOW)).toBe('sidebar') + expect(frameMode(NAV_DRAWER_BELOW - 1)).toBe('drawer') + expect(frameMode(390)).toBe('drawer') + }) + + test('the drawer opens from the menu button and closes on every way out', () => { + expect(drawerOpen(false, 'menu')).toBe(true) + expect(drawerOpen(true, 'menu')).toBe(false) + for (const event of ['close', 'navigated', 'wide'] as const) expect(drawerOpen(true, event)).toBe(false) + }) +}) diff --git a/src/admin-next/frame/index.ts b/src/admin-next/frame/index.ts new file mode 100644 index 0000000..318395c --- /dev/null +++ b/src/admin-next/frame/index.ts @@ -0,0 +1,2 @@ +export * from './layout' +export * from './nav' diff --git a/src/admin-next/frame/layout.ts b/src/admin-next/frame/layout.ts new file mode 100644 index 0000000..7736828 --- /dev/null +++ b/src/admin-next/frame/layout.ts @@ -0,0 +1,37 @@ +/** + * Where the nav lives at each width (admin-patterns, patterns 1 and 10): a fixed left column on wide + * screens, a drawer behind the menu button below the breakpoint. + */ + +/** Below this width (CSS px) the nav is a drawer. Draft 3's best guess, to measure in the reference admin. */ +export const NAV_DRAWER_BELOW = 1040 + +/** The left column's width (CSS px). To measure. */ +export const NAV_WIDTH = 240 + +export type FrameMode = 'sidebar' | 'drawer' + +export function frameMode(width: number): FrameMode { + return width < NAV_DRAWER_BELOW ? 'drawer' : 'sidebar' +} + +/** The media query for `frameMode(width) === 'sidebar'`, for CSS and `matchMedia`. */ +export const SIDEBAR_QUERY = `(min-width: ${NAV_DRAWER_BELOW}px)` + +export type DrawerEvent = + | 'menu' // the menu button + | 'close' // the close button, the scrim, Esc + | 'navigated' // a nav item was chosen, or the page changed + | 'wide' // the window grew past the breakpoint: the nav is a column again + +/** Whether the phone and tablet drawer is open after `event`. */ +export function drawerOpen(open: boolean, event: DrawerEvent): boolean { + switch (event) { + case 'menu': + return !open + case 'close': + case 'navigated': + case 'wide': + return false + } +} diff --git a/src/admin-next/frame/nav.ts b/src/admin-next/frame/nav.ts new file mode 100644 index 0000000..28b4027 --- /dev/null +++ b/src/admin-next/frame/nav.ts @@ -0,0 +1,117 @@ +/** + * The admin frame's left nav as data (admin-patterns, pattern 1): each app declares its sections, + * and `resolveNav` marks the page being shown and opens its section. Sub-items show only while their + * section is open; Settings sits at the bottom, apart from daily work. + */ + +/** A place in the admin. `to` is a path inside the app ("/admin/users"). */ +export type AdminNavLink = { + /** Stable and unique across the whole nav. */ + key: string + label: string + to: string + /** Something needs attention there: a count ("12") or a short word. */ + badge?: number | string | undefined + /** Current only on this exact path, never on the pages below it (the admin's home). */ + exact?: boolean | undefined +} + +/** A section: a link that may hold sub-pages, shown under it while the section is open. */ +export type AdminNavItem = AdminNavLink & { + icon?: Icon | undefined + children?: readonly AdminNavLink[] | undefined +} + +/** A titled group under the core sections ("Content", "Channels"). */ +export type AdminNavGroup = { + key: string + label: string + items: readonly AdminNavItem[] +} + +export type AdminNav = { + /** The core sections, first in the nav. */ + main: readonly AdminNavItem[] + groups?: readonly AdminNavGroup[] | undefined + /** Pinned to the bottom of the nav. */ + settings?: AdminNavItem | undefined +} + +export type ResolvedLink = AdminNavLink & { current: boolean } +export type ResolvedItem = ResolvedLink & { + icon?: Icon | undefined + /** This section or one of its sub-pages is shown: its sub-items are visible. */ + open: boolean + children: ResolvedLink[] +} +export type ResolvedNav = { + main: ResolvedItem[] + groups: { key: string; label: string; items: ResolvedItem[] }[] + settings: ResolvedItem | undefined + /** The link of the page being shown, if the nav has one. */ + current: ResolvedLink | undefined +} + +/** "/admin/users/?q=a#x" → "/admin/users". */ +export function normalizePath(path: string): string { + const bare = path.replace(/[?#].*$/, '') + const trimmed = bare.length > 1 ? bare.replace(/\/+$/, '') : bare + return trimmed || '/' +} + +/** How well `link` matches `path`: the length of its `to`, or -1. Deeper links win. */ +function matchLength(link: AdminNavLink, path: string): number { + const to = normalizePath(link.to) + if (path === to) return to.length + if (link.exact) return -1 + const prefix = to === '/' ? '/' : `${to}/` + return path.startsWith(prefix) ? to.length : -1 +} + +function allLinks(nav: AdminNav): AdminNavLink[] { + const sections = [...nav.main, ...(nav.groups ?? []).flatMap((group) => group.items), ...(nav.settings ? [nav.settings] : [])] + return sections.flatMap((item) => [item, ...(item.children ?? [])]) +} + +/** Throws on a key used twice: React keys and the current mark would both go wrong. */ +export function assertUniqueKeys(nav: AdminNav): void { + const seen = new Set() + for (const link of allLinks(nav)) { + if (seen.has(link.key)) throw new Error(`admin nav: the key "${link.key}" is used twice`) + seen.add(link.key) + } +} + +/** + * The nav for the page at `pathname`: exactly one link is current (the deepest match), and the + * section holding it is open. + */ +export function resolveNav(nav: AdminNav, pathname: string): ResolvedNav { + const path = normalizePath(pathname) + let best: AdminNavLink | undefined + let bestLength = -1 + for (const link of allLinks(nav)) { + const length = matchLength(link, path) + if (length > bestLength) { + best = link + bestLength = length + } + } + const mark = (link: AdminNavLink): ResolvedLink => ({ ...link, current: link === best }) + const resolve = (item: AdminNavItem): ResolvedItem => { + const children = (item.children ?? []).map(mark) + const current = item === best + return { ...item, current, open: current || children.some((child) => child.current), children } + } + const main = nav.main.map(resolve) + const groups = (nav.groups ?? []).map((group) => ({ key: group.key, label: group.label, items: group.items.map(resolve) })) + const settings = nav.settings ? resolve(nav.settings) : undefined + return { main, groups, settings, current: best ? mark(best) : undefined } +} + +/** A badge as the nav shows it: "2,481", "99+" past 99 when `compact`; words as given. */ +export function formatBadge(badge: number | string, { compact = false }: { compact?: boolean } = {}): string { + if (typeof badge !== 'number') return badge + if (compact && badge > 99) return '99+' + return badge.toLocaleString('en-US') +} From 39c64b1ec873013bc1e836537ec5fb8ec3b75a9a Mon Sep 17 00:00:00 2001 From: Jean Gerard Bousiquot Date: Sat, 5 Dec 2026 19:23:03 -0500 Subject: [PATCH 02/10] admin-next: the frame (top bar, nav column and drawer, search shortcuts, page header) on kit/ui and the admin theme Co-Authored-By: Claude Opus 5.5 --- e2e/admin-frame-screenshots.spec.ts | 26 ++ e2e/admin-frame.spec.ts | 109 ++++++++ playground/admin-next.html | 24 ++ playground/admin-next.tsx | 144 ++++++++++ playground/serve.ts | 4 +- src/admin-next/frame/AdminFrame.tsx | 325 ++++++++++++++++++++++ src/admin-next/frame/PageHeader.tsx | 91 +++++++ src/admin-next/frame/icons.tsx | 51 ++++ src/admin-next/frame/index.ts | 3 + src/admin-next/frame/render.test.tsx | 103 +++++++ src/admin-next/frame/text.ts | 69 +++++ src/admin-next/styles/10-frame.css | 391 +++++++++++++++++++++++++++ 12 files changed, 1339 insertions(+), 1 deletion(-) create mode 100644 e2e/admin-frame-screenshots.spec.ts create mode 100644 e2e/admin-frame.spec.ts create mode 100644 playground/admin-next.html create mode 100644 playground/admin-next.tsx create mode 100644 src/admin-next/frame/AdminFrame.tsx create mode 100644 src/admin-next/frame/PageHeader.tsx create mode 100644 src/admin-next/frame/icons.tsx create mode 100644 src/admin-next/frame/render.test.tsx create mode 100644 src/admin-next/frame/text.ts create mode 100644 src/admin-next/styles/10-frame.css diff --git a/e2e/admin-frame-screenshots.spec.ts b/e2e/admin-frame-screenshots.spec.ts new file mode 100644 index 0000000..721c7fc --- /dev/null +++ b/e2e/admin-frame-screenshots.spec.ts @@ -0,0 +1,26 @@ +import { test } from '@playwright/test' + +/** + * Review screenshots of the new admin's frame for the owner: light and dark, desktop (1280) and + * phone (390), with the drawer open on the phone. Saved to SCREENSHOTS_DIR (default + * .screenshots/admin). `bun --bun playwright test e2e/admin-frame-screenshots.spec.ts`. + */ +const DIR = process.env.SCREENSHOTS_DIR ?? '.screenshots/admin' +const sizes = { desktop: { width: 1280, height: 800 }, phone: { width: 390, height: 844 } } + +for (const scheme of ['light', 'dark'] as const) + for (const [label, viewport] of Object.entries(sizes)) + test(`@screenshots admin frame ${label} ${scheme}`, async ({ browser }) => { + const context = await browser.newContext({ viewport, hasTouch: label === 'phone', isMobile: label === 'phone' }) + const page = await context.newPage() + await page.goto(`/admin-next?scheme=${scheme}&path=/admin/users/roles`) + await page.evaluate(() => document.fonts.ready) + await page.screenshot({ path: `${DIR}/frame-${label}-${scheme}.png` }) + if (label === 'phone') { + await page.getByRole('button', { name: 'Menu' }).click() + await page.getByRole('dialog').waitFor() + await page.waitForTimeout(400) + await page.screenshot({ path: `${DIR}/frame-${label}-${scheme}-drawer.png` }) + } + await context.close() + }) diff --git a/e2e/admin-frame.spec.ts b/e2e/admin-frame.spec.ts new file mode 100644 index 0000000..934a73b --- /dev/null +++ b/e2e/admin-frame.spec.ts @@ -0,0 +1,109 @@ +import { expect, test, type Page } from '@playwright/test' +import { expectAccessible, expectFitsScreen } from './helpers' + +/** The new admin's frame (kit 0.9.0, playground /admin-next). */ +async function openFrame(page: Page, query = '') { + await page.goto(`/admin-next?${query}`) + await expect(page.getByRole('heading', { level: 1 })).toBeVisible() +} + +for (const scheme of ['light', 'dark'] as const) + test(`the frame is accessible and fits the screen (${scheme})`, async ({ page }) => { + await openFrame(page, `scheme=${scheme}`) + await expectAccessible(page) + await expectFitsScreen(page) + }) + +test('long names wrap or cut, never widen the page', async ({ page }) => { + await openFrame(page, 'long=1') + await expectFitsScreen(page) +}) + +test('the skip link is first and moves focus to the page', async ({ page }) => { + await openFrame(page) + await page.keyboard.press('Tab') + const skip = page.getByRole('link', { name: 'Skip to content' }) + await expect(skip).toBeFocused() + await expect(skip).toBeInViewport() + await page.keyboard.press('Enter') + await expect(page.locator('#admin-main')).toBeFocused() +}) + +test('⌘K, Ctrl+K and / open the search; / types normally inside a field', async ({ page }) => { + await openFrame(page) + await page.keyboard.press('Control+k') + await expect(page.getByText('Search opened 1 time.')).toBeVisible() + await page.keyboard.press('Meta+k') + await page.keyboard.press('/') + await expect(page.getByText('Search opened 3 times.')).toBeVisible() +}) + +test.describe('wide screens', () => { + test.skip(({ viewport }) => (viewport?.width ?? 0) < 1040, 'desktop only') + + test('the nav is a column that stays put while the page scrolls', async ({ page }) => { + await openFrame(page) + await expect(page.getByRole('button', { name: 'Menu', exact: true })).toBeHidden() + const nav = page.getByRole('navigation', { name: 'Admin' }) + await expect(nav).toBeVisible() + const before = await nav.boundingBox() + await page.evaluate(() => scrollTo(0, document.body.scrollHeight)) + await expect.poll(() => page.evaluate(() => scrollY)).toBeGreaterThan(100) + expect((await nav.boundingBox())!.y).toBe(before!.y) + }) + + test('one current item; its section opens; choosing another moves the mark', async ({ page }) => { + await openFrame(page, 'path=/admin/users/roles') + const nav = page.getByRole('navigation', { name: 'Admin' }) + await expect(nav.locator('[aria-current="page"]')).toHaveCount(1) + await expect(nav.getByRole('link', { name: 'Roles' })).toHaveAttribute('aria-current', 'page') + await nav.getByRole('link', { name: 'Analytics' }).click() + await expect(nav.getByRole('link', { name: 'Analytics' })).toHaveAttribute('aria-current', 'page') + await expect(nav.getByRole('link', { name: 'Roles' })).toHaveCount(0) + await expect(page.getByRole('heading', { level: 1 })).toHaveText('Analytics') + }) + + test('a number badge reads in full to screen readers', async ({ page }) => { + await openFrame(page) + await expect(page.getByRole('link', { name: 'Reports 12 pending' })).toBeVisible() + }) +}) + +test.describe('phones and tablets', () => { + test.skip(({ viewport }) => (viewport?.width ?? 0) >= 1040, 'narrow screens only') + + test('the nav is a drawer: focus goes in, Esc closes it, focus comes back', async ({ page }) => { + await openFrame(page) + await expect(page.getByRole('navigation', { name: 'Admin' })).toHaveCount(0) + const menu = page.getByRole('button', { name: 'Menu', exact: true }) + await expect(menu).toHaveAttribute('aria-expanded', 'false') + await menu.click() + const drawer = page.getByRole('dialog', { name: 'Admin' }) + await expect(drawer).toBeVisible() + await expect(menu).toHaveAttribute('aria-expanded', 'true') + await expect(drawer.getByRole('button', { name: 'Close menu' })).toBeFocused() + await expectAccessible(page) + await page.keyboard.press('Escape') + await expect(drawer).toBeHidden() + await expect(menu).toBeFocused() + await expect(menu).toHaveAttribute('aria-expanded', 'false') + }) + + test('choosing a page closes the drawer; so does the scrim', async ({ page }) => { + await openFrame(page) + await page.getByRole('button', { name: 'Menu', exact: true }).click() + await page.getByRole('dialog', { name: 'Admin' }).getByRole('link', { name: 'Reports 12 pending' }).click() + await expect(page.getByRole('dialog', { name: 'Admin' })).toBeHidden() + await expect(page.getByRole('heading', { level: 1 })).toHaveText('Reports') + await page.getByRole('button', { name: 'Menu', exact: true }).click() + await expect(page.getByRole('dialog', { name: 'Admin' })).toBeVisible() + await page.mouse.click(380, 400) // right of the panel: the scrim + await expect(page.getByRole('dialog', { name: 'Admin' })).toBeHidden() + }) + + test('touch targets are at least 44 px', async ({ page }) => { + await openFrame(page) + for (const name of ['Menu', 'Search']) + expect((await page.getByRole('button', { name, exact: true }).boundingBox())!.height).toBeGreaterThanOrEqual(44) + }) +}) diff --git a/playground/admin-next.html b/playground/admin-next.html new file mode 100644 index 0000000..17f973f --- /dev/null +++ b/playground/admin-next.html @@ -0,0 +1,24 @@ + + + + + + kit admin (next) playground + + + + + + + + + +
+ + + diff --git a/playground/admin-next.tsx b/playground/admin-next.tsx new file mode 100644 index 0000000..7c676bd --- /dev/null +++ b/playground/admin-next.tsx @@ -0,0 +1,144 @@ +/** + * The new admin (kit 0.9.0, in progress): the frame with sample data. `?path=/admin/users` picks the + * page, `?scheme=dark|light` forces a scheme, `?long=1` tries long names. Links stay in the playground. + */ +import { useState, type ReactNode } from 'react' +import { createRoot } from 'react-dom/client' +import { AdminFrame, AdminSearch, PageHeader, type AdminLink, type AdminNav } from '../src/admin-next/frame' +import { scaleCss, themeCss } from '../src/tokens' +import { adminTheme, ADMIN_THEME_SCOPE } from '../src/tokens/themes' +import { Badge, Button, VisuallyHidden, Card, CardContent, CardDescription, CardHeader, CardTitle } from '../src/ui' + +const params = new URLSearchParams(location.search) +const scheme = params.get('scheme') === 'dark' ? 'dark' : params.get('scheme') === 'light' ? 'light' : undefined +const long = params.has('long') + +// Lucide's icons (ISC licence): house, users, flag, file-text, chart-column, settings. +const icon = (...paths: string[]) => ( + + {paths.map((d) => ( + + ))} + +) +const icons = { + home: icon( + 'M15 21v-8a1 1 0 0 0-1-1h-4a1 1 0 0 0-1 1v8', + 'M3 10a2 2 0 0 1 .709-1.528l7-5.999a2 2 0 0 1 2.582 0l7 5.999A2 2 0 0 1 21 10v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z', + ), + users: icon( + 'M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2', + 'M22 21v-2a4 4 0 0 0-3-3.87', + 'M16 3.13a4 4 0 0 1 0 7.75', + 'M9 3a4 4 0 1 0 0 8 4 4 0 0 0 0-8', + ), + flag: icon( + 'M4 22V4a1 1 0 0 1 .4-.8A6 6 0 0 1 8 2c3 0 5 2 7.333 2q2 0 3.067-.8A1 1 0 0 1 20 4v10a1 1 0 0 1-.4.8A6 6 0 0 1 16 16c-3 0-5-2-8-2a6 6 0 0 0-4 1.528', + ), + file: icon('M15 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V7Z', 'M14 2v4a2 2 0 0 0 2 2h4', 'M10 9H8', 'M16 13H8', 'M16 17H8'), + chart: icon('M3 3v16a2 2 0 0 0 2 2h16', 'M18 17V9', 'M13 17V5', 'M8 17v-3'), + settings: icon( + 'M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z', + 'M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0', + ), +} + +const nav: AdminNav = { + main: [ + { key: 'home', label: 'Home', to: '/admin', exact: true, icon: icons.home }, + { + key: 'users', + label: long ? 'People who signed up for an account' : 'Users', + to: '/admin/users', + icon: icons.users, + children: [ + { key: 'roles', label: 'Roles', to: '/admin/users/roles' }, + { key: 'suspended', label: 'Suspended', to: '/admin/users/suspended' }, + ], + }, + { key: 'reports', label: 'Reports', to: '/admin/reports', icon: icons.flag, badge: 12 }, + { key: 'stats', label: 'Analytics', to: '/admin/stats', icon: icons.chart }, + ], + groups: [ + { + key: 'content', + label: 'Content', + items: [ + { key: 'pages', label: 'Pages', to: '/admin/pages', icon: icons.file }, + { key: 'faq', label: 'FAQ', to: '/admin/faq', icon: icons.file, badge: 'New' }, + ], + }, + ], + settings: { key: 'settings', label: 'Settings', to: '/admin/settings', icon: icons.settings }, +} + +const style = document.createElement('style') +style.textContent = [scaleCss(), themeCss(adminTheme, { scope: ADMIN_THEME_SCOPE })].join('\n') +document.head.append(style) + +function App() { + const [path, setPath] = useState(params.get('path') ?? '/admin/users') + const [searched, setSearched] = useState(0) + // Links stay in the playground: the path goes in the URL, the page doesn't reload. + const link: AdminLink = ({ href, onClick, ...props }) => ( + { + onClick?.(event) + event.preventDefault() + history.pushState(null, '', event.currentTarget.href) + setPath(href) + }} + /> + ) + const title = + nav.main + .concat(nav.groups![0]!.items, [nav.settings!]) + .flatMap((item) => [item, ...(item.children ?? [])]) + .find((item) => item.to === path)?.label ?? 'Page' + return ( + , + }} + search={ setSearched((n) => n + 1)} />} + account={ + + } + renderLink={link} + > + 2,481 : undefined} + backTo={path.split('/').length > 3 ? { href: '/admin/users', label: 'Users' } : undefined} + secondaryActions={} + primaryAction={} + renderLink={link} + /> + + + The page goes here + + Lists, details and settings come in the next pull requests. Search opened {searched} time{searched === 1 ? '' : 's'}. + + + + {Array.from({ length: 24 }, (_, i) => ( +

Row {i + 1}: long enough to scroll the page, so you can see the nav stay put.

+ ))} +
+
+
+ ) +} + +createRoot(document.getElementById('root')!).render() diff --git a/playground/serve.ts b/playground/serve.ts index 4220eb1..7079c8f 100644 --- a/playground/serve.ts +++ b/playground/serve.ts @@ -10,6 +10,7 @@ import { dirname, resolve } from 'node:path' import page from './index.html' import account from './account.html' import ui from './ui.html' +import adminNext from './admin-next.html' import overlays from './overlays.html' const reactNativeWeb: BunPlugin = { @@ -55,9 +56,10 @@ Bun.serve({ '/account': account, '/ui': ui, '/overlays': overlays, + '/admin-next': adminNext, '/account-native': () => new Response(nativeHtml, { headers: { 'content-type': 'text/html; charset=utf-8' } }), '/account-native.js': () => new Response(nativeJs, { headers: { 'content-type': 'text/javascript; charset=utf-8' } }), }, development: process.env.NODE_ENV !== 'production', }) -console.log(`Playground on http://127.0.0.1:${port}/ (kit/account: /account, /account-native; kit/ui: /ui, /overlays)`) +console.log(`Playground on http://127.0.0.1:${port}/ (kit/account: /account, /account-native; kit/ui: /ui, /overlays; new admin: /admin-next)`) diff --git a/src/admin-next/frame/AdminFrame.tsx b/src/admin-next/frame/AdminFrame.tsx new file mode 100644 index 0000000..4fb7b00 --- /dev/null +++ b/src/admin-next/frame/AdminFrame.tsx @@ -0,0 +1,325 @@ +import { useEffect, useId, useRef, useState, type AnchorHTMLAttributes, type ReactNode } from 'react' +import { Badge, Kbd, VisuallyHidden } from '../../ui' +import { CloseIcon, MenuIcon, SearchIcon } from './icons' +import { drawerOpen, SIDEBAR_QUERY, type DrawerEvent } from './layout' +import { formatBadge, resolveNav, type AdminNav, type ResolvedItem, type ResolvedLink } from './nav' +import { adminFrameTextEn, type AdminFrameText } from './text' + +/** + * How links are drawn, so any router works: TanStack's , or a plain
(the default). The + * props always hold `href` (a path the app gave the kit), `data-slot`, and `aria-current` on the page shown. + */ +export type AdminLinkProps = AnchorHTMLAttributes & { href: string; 'data-slot': string; children: ReactNode } +export type AdminLink = (props: AdminLinkProps) => ReactNode +export const plainAdminLink: AdminLink = (props) => + +export type AdminBrand = { + name: string + /** A small mark before the name (an or an SVG, 24 px). Decorative: the name is written. */ + logo?: ReactNode + /** The admin's home. */ + href: string +} + +export type AdminFrameProps = { + nav: AdminNav + /** The page being shown: marks the current nav item and closes the drawer when it changes. */ + pathname: string + brand: AdminBrand + /** The top bar's search (usually ``). */ + search?: ReactNode + /** The right side of the top bar: the account menu, a theme switch. */ + account?: ReactNode + /** Force a scheme; by default the frame follows the device. */ + scheme?: 'light' | 'dark' | undefined + text?: AdminFrameText + renderLink?: AdminLink + children: ReactNode +} + +/** + * The admin's frame (admin-patterns, pattern 1): a top bar, the nav in a column on wide screens and in + * a drawer behind the menu button below 1040 px, and the page. The nav never scrolls with the page. + * The admin theme applies inside it only, so the app's public pages keep their own. + */ +export function AdminFrame({ + nav, + pathname, + brand, + search, + account, + scheme, + text = adminFrameTextEn, + renderLink = plainAdminLink, + children, +}: AdminFrameProps) { + const resolved = resolveNav(nav, pathname) + const [open, setOpen] = useState(false) + const send = (event: DrawerEvent) => setOpen((now) => drawerOpen(now, event)) + const drawerId = useId() + const mainId = 'admin-main' + + // A new page closes the drawer. + const shown = useRef(pathname) + useEffect(() => { + if (shown.current !== pathname) send('navigated') + shown.current = pathname + }, [pathname]) + + // Growing past the breakpoint turns the drawer back into the column. + useEffect(() => { + const wide = window.matchMedia(SIDEBAR_QUERY) + const onChange = () => wide.matches && send('wide') + wide.addEventListener('change', onChange) + return () => wide.removeEventListener('change', onChange) + }, []) + + return ( +
+ + {text.skip} + +
+ + {renderLink({ + href: brand.href, + 'data-slot': 'admin-brand', + children: ( + <> + {brand.logo && {brand.logo}} + {brand.name} + + ), + })} +
{search}
+
{account}
+
+
+ + send('close')} label={text.navigation} closeLabel={text.closeMenu}> + send('navigated')} /> + +
+ {children} +
+
+
+ ) +} + +/** + * The nav drawer, on the native : modal, so focus stays inside, Esc closes it, and the + * browser puts focus back on the menu button. Its content renders only while open, so the nav isn't + * in the page twice. + */ +function AdminDrawer({ + id, + open, + onClose, + label, + closeLabel, + children, +}: { + id: string + open: boolean + onClose: () => void + label: string + closeLabel: string + children: ReactNode +}) { + const ref = useRef(null) + useEffect(() => { + const dialog = ref.current + if (!dialog) return + if (open && !dialog.open) dialog.showModal() + if (!open && dialog.open) dialog.close() + }, [open]) + return ( + event.target === event.currentTarget && onClose()} + > + {open && ( +
+ + +
+ )} +
+ ) +} + +type NavContentProps = { + nav: ReturnType> + text: AdminFrameText + renderLink: AdminLink + onNavigate?: (() => void) | undefined +} + +function NavContent({ nav, text, renderLink, onNavigate }: NavContentProps) { + const groupId = useId() + return ( + <> +
    + {nav.main.map((item) => ( + + ))} +
+ {nav.groups.map((group) => ( +
+

+ {group.label} +

+
    + {group.items.map((item) => ( + + ))} +
+
+ ))} + {nav.settings && ( +
    + +
+ )} + + ) +} + +function NavItem({ + item, + text, + renderLink, + onNavigate, +}: { + item: ResolvedItem + text: AdminFrameText + renderLink: AdminLink + onNavigate?: (() => void) | undefined +}) { + return ( +
  • + + {item.open && item.children.length > 0 && ( +
      + {item.children.map((child) => ( +
    • + +
    • + ))} +
    + )} +
  • + ) +} + +function NavLink({ + link, + icon, + text, + renderLink, + onNavigate, + sub = false, +}: { + link: ResolvedLink + icon?: ReactNode + text: AdminFrameText + renderLink: AdminLink + onNavigate?: (() => void) | undefined + sub?: boolean +}) { + const badge = link.badge === undefined ? undefined : formatBadge(link.badge, { compact: true }) + return renderLink({ + href: link.to, + 'data-slot': sub ? 'admin-nav-sublink' : 'admin-nav-link', + 'aria-current': link.current ? 'page' : undefined, + onClick: onNavigate, + children: ( + <> + {icon && ( + + )} + {link.label} + {badge !== undefined && ( + + + {typeof link.badge === 'number' ? ( + <> + + {text.pending(formatBadge(link.badge))} + + ) : ( + badge + )} + + + )} + + ), + }) +} + +export type AdminSearchProps = { + /** Opens the search (the ⌘K palette, once it ships; until then the app's own search page). */ + onOpen: () => void + text?: AdminFrameText +} + +function editable(target: EventTarget | null): boolean { + if (!(target instanceof HTMLElement)) return false + return target.isContentEditable || ['INPUT', 'TEXTAREA', 'SELECT'].includes(target.tagName) +} + +/** + * The top bar's search: a field-shaped button that opens the search, also with ⌘K (Ctrl+K) anywhere + * and with / outside a text field. On phones it is a search icon. + */ +export function AdminSearch({ onOpen, text = adminFrameTextEn }: AdminSearchProps) { + const latest = useRef(onOpen) + latest.current = onOpen + const [mac, setMac] = useState(false) + useEffect(() => { + setMac(/Mac|iPhone|iPad/.test(navigator.platform)) + const onKey = (event: KeyboardEvent) => { + const palette = event.key.toLowerCase() === 'k' && (event.metaKey || event.ctrlKey) && !event.altKey + const slash = event.key === '/' && !event.metaKey && !event.ctrlKey && !event.altKey && !editable(event.target) + if (!palette && !slash) return + event.preventDefault() + latest.current() + } + document.addEventListener('keydown', onKey) + return () => document.removeEventListener('keydown', onKey) + }, []) + return ( + + ) +} diff --git a/src/admin-next/frame/PageHeader.tsx b/src/admin-next/frame/PageHeader.tsx new file mode 100644 index 0000000..71c31ee --- /dev/null +++ b/src/admin-next/frame/PageHeader.tsx @@ -0,0 +1,91 @@ +import type { ReactNode } from 'react' +import { ChevronLeftIcon, ChevronRightIcon } from './icons' +import { plainAdminLink, type AdminLink } from './AdminFrame' +import { adminFrameTextEn, type AdminFrameText } from './text' + +export type PageHeaderProps = { + /** The page's one h1. */ + title: string + /** A status next to the title (a kit/ui ). */ + badge?: ReactNode + /** The list this page belongs to. Give the list's URL with its filters, so Back keeps them. */ + backTo?: { href: string; label?: string | undefined } | undefined + /** The page's main action (a primary } + primaryAction={} + pagination={{ next: '/admin/users/2' }} + />, + ) + expect(html.match(/

    { + test('every language has every word', () => { + const keys = Object.keys(adminFrameTextEn).sort() + for (const text of [adminFrameTextFr, adminFrameTextEs, adminFrameTextHt]) { + expect(Object.keys(text).sort()).toEqual(keys) + expect(text.pending('3')).toContain('3') + } + }) +}) diff --git a/src/admin-next/frame/text.ts b/src/admin-next/frame/text.ts new file mode 100644 index 0000000..e83bfc9 --- /dev/null +++ b/src/admin-next/frame/text.ts @@ -0,0 +1,69 @@ +/** + * Every word the admin frame shows, in one typed object, in the kit's four languages. An app passes + * its own, or one of these with a few lines changed: `{ ...adminFrameTextEn, search: 'Search orders' }`. + */ +export type AdminFrameText = { + /** The skip link, first on the page. */ + skip: string + /** The menu button that opens the nav on phones and tablets. */ + menu: string + closeMenu: string + /** The nav's name for screen readers. */ + navigation: string + /** The search field's placeholder and the search button's name. */ + search: string + /** Read after a number badge in the nav ("12" → "12 pending"). */ + pending: (count: string) => string + /** The page header's back link when the app gives no label. */ + back: string + previous: string + next: string +} + +export const adminFrameTextEn: AdminFrameText = { + skip: 'Skip to content', + menu: 'Menu', + closeMenu: 'Close menu', + navigation: 'Admin', + search: 'Search', + pending: (count) => `${count} pending`, + back: 'Back', + previous: 'Previous', + next: 'Next', +} + +export const adminFrameTextFr: AdminFrameText = { + skip: 'Aller au contenu', + menu: 'Menu', + closeMenu: 'Fermer le menu', + navigation: 'Administration', + search: 'Rechercher', + pending: (count) => `${count} en attente`, + back: 'Retour', + previous: 'Précédent', + next: 'Suivant', +} + +export const adminFrameTextEs: AdminFrameText = { + skip: 'Ir al contenido', + menu: 'Menú', + closeMenu: 'Cerrar el menú', + navigation: 'Administración', + search: 'Buscar', + pending: (count) => `${count} pendientes`, + back: 'Volver', + previous: 'Anterior', + next: 'Siguiente', +} + +export const adminFrameTextHt: AdminFrameText = { + skip: 'Ale nan kontni an', + menu: 'Meni', + closeMenu: 'Fèmen meni an', + navigation: 'Administrasyon', + search: 'Chèche', + pending: (count) => `${count} ap tann`, + back: 'Retounen', + previous: 'Anvan', + next: 'Pwochen', +} diff --git a/src/admin-next/styles/10-frame.css b/src/admin-next/styles/10-frame.css new file mode 100644 index 0000000..92e9dd3 --- /dev/null +++ b/src/admin-next/styles/10-frame.css @@ -0,0 +1,391 @@ +/* + * The admin frame: top bar, nav (a column from 1040 px, a drawer below), page header. Tokens only + * (tokens.css plus tokens/themes/admin.css, scoped to [data-kit-theme="admin"]), every selector + * inside :where() so any class of the app's wins. Component tokens: --admin-topbar-height, + * --admin-nav-width, --admin-page-width. + */ +:where([data-slot='admin-frame']) { + --admin-topbar-height: 3.5rem; + --admin-nav-width: 15rem; + --admin-page-width: 75rem; + --admin-item-height: var(--control-md); + min-height: 100dvh; + background: var(--background); + color: var(--foreground); + font-family: var(--font-body); + font-size: var(--font-size-sm); + line-height: var(--line-height-sm); +} +@media (pointer: coarse) { + :where([data-slot='admin-frame']) { + --admin-item-height: var(--hit-min); + } +} + +/* One focus ring, as kit/ui's. */ +:where( + [data-slot='admin-skip'], + [data-slot='admin-menu-button'], + [data-slot='admin-brand'], + [data-slot='admin-search'], + [data-slot='admin-nav-link'], + [data-slot='admin-nav-sublink'], + [data-slot='admin-drawer-close'], + [data-slot='admin-back'], + [data-slot='admin-pager'] +):focus-visible { + outline: 2px solid var(--ring); + outline-offset: 2px; +} + +/* The skip link: hidden until it takes focus. */ +:where([data-slot='admin-skip']) { + position: absolute; + z-index: 30; + top: var(--space-2); + left: var(--space-2); + padding: var(--space-2) var(--space-3); + border-radius: var(--radius-control); + background: var(--card); + color: var(--card-foreground); + font-weight: 600; + box-shadow: var(--elevation-2); + transform: translateY(-200%); +} +:where([data-slot='admin-skip']):focus { + transform: none; +} + +/* Top bar: menu button (narrow screens), brand, search in the middle, the account at the end. */ +:where([data-slot='admin-topbar']) { + position: sticky; + z-index: 20; + top: 0; + display: grid; + grid-template-columns: auto auto minmax(0, 1fr) auto; + align-items: center; + gap: var(--space-3); + height: var(--admin-topbar-height); + padding-inline: var(--space-3); + border-bottom: 1px solid var(--sidebar-border, var(--border)); + background: var(--sidebar); + color: var(--sidebar-foreground); +} +:where([data-slot='admin-menu-button'], [data-slot='admin-drawer-close'], [data-slot='admin-back'], [data-slot='admin-pager']) { + display: inline-grid; + flex: none; + place-items: center; + width: var(--admin-item-height); + height: var(--admin-item-height); + padding: 0; + border: 1px solid transparent; + border-radius: var(--radius-control); + background: transparent; + color: inherit; + cursor: pointer; + transition: background-color var(--duration-fast) var(--easing-out); +} +:where([data-slot='admin-menu-button'], [data-slot='admin-drawer-close'], [data-slot='admin-back'], a[data-slot='admin-pager']):hover { + background: var(--accent); +} +:where([data-slot='admin-pager'][aria-disabled='true']) { + color: var(--muted-foreground); + opacity: 0.5; + cursor: default; +} +:where([data-slot='admin-frame'] [data-icon]) { + width: 1rem; + height: 1rem; + flex: none; +} +:where([data-slot='admin-menu-button'] [data-icon], [data-slot='admin-drawer-close'] [data-icon]) { + width: 1.25rem; + height: 1.25rem; +} +:where([data-slot='admin-brand']) { + display: inline-flex; + align-items: center; + gap: var(--space-2); + min-height: var(--admin-item-height); + padding-inline: var(--space-1); + border-radius: var(--radius-control); + color: inherit; + font-weight: var(--heading-weight); + text-decoration: none; +} +:where([data-slot='admin-brand-logo']) { + display: inline-grid; + place-items: center; + width: 1.5rem; + height: 1.5rem; +} +:where([data-slot='admin-brand-logo'] > *) { + max-width: 100%; + max-height: 100%; +} +:where([data-slot='admin-topbar-search']) { + display: flex; + justify-content: center; + min-width: 0; +} +:where([data-slot='admin-topbar-end']) { + display: flex; + align-items: center; + gap: var(--space-2); +} + +/* The search: a field-shaped button; an icon on small screens. */ +:where([data-slot='admin-search']) { + display: flex; + align-items: center; + gap: var(--space-2); + width: 100%; + max-width: 30rem; + min-height: var(--admin-item-height); + padding-inline: var(--space-3); + border: 1px solid var(--border); + border-radius: var(--radius-control); + background: var(--card); + color: var(--muted-foreground); + font: inherit; + text-align: start; + cursor: pointer; +} +:where([data-slot='admin-search']):hover { + border-color: var(--input); +} +:where([data-slot='admin-search-label']) { + flex: 1; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +@media (max-width: 639.98px) { + :where([data-slot='admin-topbar-search']) { + justify-content: flex-end; + } + :where([data-slot='admin-search']) { + justify-content: center; + width: var(--admin-item-height); + padding: 0; + border-color: transparent; + background: transparent; + color: inherit; + } + :where([data-slot='admin-search'] [data-slot='kbd']) { + display: none; + } + /* Out of sight, still the button's name. */ + :where([data-slot='admin-search-label']) { + position: absolute; + width: 1px; + height: 1px; + overflow: hidden; + clip-path: inset(50%); + white-space: nowrap; + } +} + +/* Body: the nav column and the page. */ +:where([data-slot='admin-body']) { + display: grid; + grid-template-columns: minmax(0, 1fr); +} +:where([data-slot='admin-nav']) { + display: none; +} +@media (min-width: 1040px) { + :where([data-slot='admin-menu-button']) { + display: none; + } + :where([data-slot='admin-topbar']) { + grid-template-columns: calc(var(--admin-nav-width) - var(--space-3)) minmax(0, 1fr) auto; + } + :where([data-slot='admin-body']) { + grid-template-columns: var(--admin-nav-width) minmax(0, 1fr); + } + /* The nav stays put while the page scrolls; it scrolls on its own when it is taller than the screen. */ + :where([data-slot='admin-nav']) { + position: sticky; + top: var(--admin-topbar-height); + display: flex; + flex-direction: column; + height: calc(100dvh - var(--admin-topbar-height)); + overflow-y: auto; + padding: var(--space-3) var(--space-2); + background: var(--sidebar); + color: var(--sidebar-foreground); + } +} + +/* Nav lists and links (column and drawer alike). */ +:where([data-slot='admin-nav-list'], [data-slot='admin-nav-sublist']) { + display: grid; + gap: 1px; + margin: 0; + padding: 0; + list-style: none; +} +:where([data-slot='admin-nav-list'][data-pinned]) { + margin-top: auto; + padding-top: var(--space-3); +} +:where([data-slot='admin-nav-group']) { + margin-top: var(--space-4); +} +:where([data-slot='admin-nav-group-title']) { + margin: 0 0 var(--space-1); + padding-inline: var(--space-2); + color: var(--muted-foreground); + font-size: var(--font-size-xs); + font-weight: 600; + line-height: var(--line-height-xs); +} +:where([data-slot='admin-nav-link'], [data-slot='admin-nav-sublink']) { + display: flex; + align-items: center; + gap: var(--space-2); + min-height: var(--admin-item-height); + padding-inline: var(--space-2); + border-radius: var(--radius-control); + color: inherit; + font-weight: 500; + text-decoration: none; + transition: background-color var(--duration-fast) var(--easing-out); +} +:where([data-slot='admin-nav-sublink']) { + padding-inline-start: calc(var(--space-2) + 1rem + var(--space-2)); + color: var(--muted-foreground); +} +:where([data-slot='admin-nav-link'], [data-slot='admin-nav-sublink']):hover { + background: color-mix(in oklab, var(--sidebar-accent) 60%, transparent); + color: var(--sidebar-accent-foreground); +} +:where([data-slot='admin-nav-link'], [data-slot='admin-nav-sublink'])[aria-current='page'] { + background: var(--sidebar-accent); + color: var(--sidebar-accent-foreground); + font-weight: 600; + box-shadow: var(--elevation-1); +} +:where([data-slot='admin-nav-icon']) { + display: inline-grid; + flex: none; + place-items: center; + width: 1rem; + height: 1rem; +} +:where([data-slot='admin-nav-icon'] svg) { + width: 1rem; + height: 1rem; +} +:where([data-slot='admin-nav-label']) { + flex: 1; + min-width: 0; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +:where([data-slot='admin-nav-badge']) { + display: inline-flex; + flex: none; +} + +/* The drawer: a panel from the start edge over a scrim (the native , modal). */ +:where([data-slot='admin-drawer']) { + position: fixed; + inset: 0 auto 0 0; + width: min(20rem, 85vw); + max-width: none; + height: 100dvh; + max-height: none; + margin: 0; + padding: 0; + border: 0; + background: var(--sidebar); + color: var(--sidebar-foreground); + box-shadow: var(--elevation-3); +} +:where([data-slot='admin-drawer'])::backdrop { + background: var(--overlay); +} +:where([data-slot='admin-drawer'][open]) { + animation: admin-drawer-in var(--duration-sheet) var(--easing-out); +} +@keyframes admin-drawer-in { + from { + transform: translateX(-100%); + } +} +@media (prefers-reduced-motion: reduce) { + :where([data-slot='admin-drawer'][open]) { + animation: none; + } +} +:where([data-slot='admin-drawer-panel']) { + display: flex; + flex-direction: column; + height: 100%; + overflow-y: auto; + padding: var(--space-2); +} +:where([data-slot='admin-drawer-panel'] > nav) { + display: flex; + flex: 1; + flex-direction: column; + padding-top: var(--space-2); +} +:where([data-slot='admin-drawer-close']) { + align-self: flex-end; +} + +/* The page. */ +:where([data-slot='admin-main']) { + width: 100%; + max-width: var(--admin-page-width); + min-width: 0; + margin-inline: auto; + padding: var(--space-4) var(--space-3) var(--space-16); +} +:where([data-slot='admin-main']):focus { + outline: none; +} +@media (min-width: 640px) { + :where([data-slot='admin-main']) { + padding: var(--space-6) var(--space-6) var(--space-16); + } +} + +/* Page header: back, title and status, then the actions. */ +:where([data-slot='admin-page-header']) { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-2) var(--space-3); + margin-bottom: var(--space-4); +} +:where([data-slot='admin-page-title-row']) { + display: flex; + flex: 1 1 12rem; + flex-wrap: wrap; + align-items: center; + gap: var(--space-2); + min-width: 0; +} +:where([data-slot='admin-page-title']) { + margin: 0; + font-family: var(--font-display); + font-size: var(--font-size-xl); + font-weight: var(--heading-weight); + line-height: var(--line-height-xl); + overflow-wrap: anywhere; +} +:where([data-slot='admin-page-actions']) { + display: flex; + flex-wrap: wrap; + align-items: center; + gap: var(--space-2); +} +:where([data-slot='admin-record-pager']) { + display: inline-flex; + gap: 1px; +} From 0abac0d762a87cb4a464900bc3ec31027831c203 Mon Sep 17 00:00:00 2001 From: Jean Gerard Bousiquot Date: Sat, 5 Dec 2026 19:23:07 -0500 Subject: [PATCH 03/10] Format Co-Authored-By: Claude Opus 5.5 --- src/admin-next/frame/AdminFrame.tsx | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/admin-next/frame/AdminFrame.tsx b/src/admin-next/frame/AdminFrame.tsx index 4fb7b00..8477331 100644 --- a/src/admin-next/frame/AdminFrame.tsx +++ b/src/admin-next/frame/AdminFrame.tsx @@ -311,12 +311,7 @@ export function AdminSearch({ onOpen, text = adminFrameTextEn }: AdminSearchProp return () => document.removeEventListener('keydown', onKey) }, []) return ( -