diff --git a/apps/app/e2e/shell/editor-shell.spec.ts b/apps/app/e2e/shell/editor-shell.spec.ts
index adfbda2f..e747bab9 100644
--- a/apps/app/e2e/shell/editor-shell.spec.ts
+++ b/apps/app/e2e/shell/editor-shell.spec.ts
@@ -11,6 +11,7 @@ import {
openEditor,
openReferences,
openSection,
+ pickAnnotation,
place,
pointOf,
seedDraft,
@@ -244,3 +245,85 @@ test.describe('editor shell, width crossing (B2b)', () => {
await expect(field).toHaveValue('Brouillon')
})
})
+
+// V1-2.6 U1 F (AC9): in the editor the sidebar shows from 1 280 px only; below, the top
+// bar's menu button opens the drawer, which stays open while the sidebar stays hidden.
+test.describe('editor shell, sidebar from 1 280 px (F)', () => {
+ test.use({ locale: 'fr-FR', actionTimeout: 15_000 })
+ test.beforeEach(async ({ context }, info) => {
+ test.skip(isPhone(info), 'the widths are set by the tests themselves') // floor-guard: allow C16 editing needs >= 1024 px; phone read-only covered in editor-access
+ await routeToSandbox(context)
+ })
+ test.afterEach(async ({ context }) => {
+ await dropLateReplays(context)
+ })
+
+ const nav = (page: Page) =>
+ page.getByRole('navigation', { name: dict['shell.nav_label'] })
+ const menu = (page: Page) =>
+ page.getByRole('button', { name: dict['shell.open_menu'] })
+ const drawer = (page: Page) =>
+ page.getByRole('dialog', { name: dict['shell.nav_label'] })
+
+ async function measure(page: Page, width: number) {
+ await page.setViewportSize({ width, height: 800 })
+ await selectTab(page, dict, 'annotations')
+ await pickAnnotation(page, dict, 'Point libre')
+ const canvas = await page.getByTestId('annotation-canvas').boundingBox()
+ const scroll = await page.evaluate(() => ({
+ scrollWidth: document.documentElement.scrollWidth,
+ clientWidth: document.documentElement.clientWidth,
+ }))
+ console.log(`F-measure ${width}px canvas=${canvas?.width} ${JSON.stringify(scroll)}`)
+ return scroll
+ }
+
+ test('the sidebar is hidden below 1 280 px and shown from 1 280 px', async ({
+ page,
+ }) => {
+ await open(page)
+ for (const width of [1024, 1180, 1279]) {
+ const scroll = await measure(page, width)
+ expect(scroll.scrollWidth, `${width} px`).toBeLessThanOrEqual(scroll.clientWidth)
+ await expect(nav(page), `${width} px`).toHaveCount(0)
+ await expect(menu(page), `${width} px`).toBeVisible()
+ }
+ const scroll = await measure(page, 1280)
+ expect(scroll.scrollWidth).toBeLessThanOrEqual(scroll.clientWidth)
+ await expect(nav(page)).toBeVisible()
+ await expect(menu(page)).toHaveCount(0)
+ })
+
+ test('the menu is one tap away and the drawer stays open at 1 180 px', async ({
+ page,
+ }) => {
+ await open(page)
+ await page.setViewportSize({ width: 1180, height: 800 })
+ await menu(page).click()
+ await expect(drawer(page)).toBeVisible()
+ await page.setViewportSize({ width: 1279, height: 800 })
+ await page.waitForTimeout(300)
+ await expect(drawer(page)).toBeVisible()
+ await page.setViewportSize({ width: 1280, height: 800 })
+ await expect(drawer(page)).toBeHidden()
+ await expect(nav(page)).toBeVisible()
+ })
+
+ test('a drawer link asks before leaving while the draft has unsaved changes', async ({
+ page,
+ }) => {
+ await open(page)
+ await page.setViewportSize({ width: 1180, height: 800 })
+ await selectTab(page, dict, 'general')
+ await page.locator('#general-name-fr').fill('Travail non enregistré')
+ await menu(page).click()
+ await drawer(page)
+ .getByRole('link', { name: new RegExp(dict['shell.nav.account']) })
+ .click()
+ const leave = page.getByRole('dialog', { name: dict['leave.title'] })
+ await expect(leave).toBeVisible()
+ await leave.getByRole('button', { name: dict['leave.stay'] }).click()
+ await expect(leave).toBeHidden()
+ await expect(page).toHaveURL(/\/draft/)
+ })
+})
diff --git a/apps/app/src/components/shell/AppLayout.tsx b/apps/app/src/components/shell/AppLayout.tsx
index c49330a3..ca92b61d 100644
--- a/apps/app/src/components/shell/AppLayout.tsx
+++ b/apps/app/src/components/shell/AppLayout.tsx
@@ -1,30 +1,16 @@
import { useState, type MouseEvent } from 'react'
-import { Link, Outlet, matchPath, useLocation, useNavigate } from 'react-router-dom'
-import Brand from '@/components/brand/Brand'
-import LanguageSwitcher from '@/components/brand/LanguageSwitcher'
+import { Outlet, matchPath, useLocation, useNavigate } from 'react-router-dom'
import Button from '@/components/ui/Button'
import Dialog from '@/components/ui/Dialog'
-import Icon from '@/components/ui/Icon'
import MobileDrawer from './MobileDrawer'
-import SidebarNav, { NAV_ITEMS } from './SidebarNav'
-import SignOutButton from './SignOutButton'
-import UserBadge, { AvatarCircle } from './UserBadge'
+import { DEFAULT_SHELL, EDITOR_SHELL, Sidebar, TopBar } from './ShellChrome'
import { usePurgeForeignCopies } from '@/app/usePurgeForeignCopies'
-import { useAuthStore } from '@/state/authStore'
import { useLeaveGuardStore } from '@/state/leaveGuardStore'
import { useT } from '@/i18n/useT'
/** The draft editor takes the whole width (board 04's three columns). */
const DRAFT_EDITOR_PATH = '/app/admin/sheets/:sheetId/draft'
-/** Title of the current /app page for the top bar, from the nav table. */
-function pageTitleKey(pathname: string): string {
- const match = NAV_ITEMS.find((item) =>
- item.end ? item.to === pathname : pathname.startsWith(item.to) && item.to !== '/',
- )
- return match?.labelKey ?? 'shell.nav.dashboard'
-}
-
/** An in-app link a plain click would follow: same origin, same tab, no modifier key. */
function followedLink(event: MouseEvent): HTMLAnchorElement | null {
if (event.defaultPrevented || event.button !== 0) return null
@@ -67,58 +53,15 @@ export default function AppLayout() {
setDrawerOpen(false)
navigate(to)
}
- const profile = useAuthStore((s) => s.profile)
- const user = useAuthStore((s) => s.user)
const fullWidth = matchPath(DRAFT_EDITOR_PATH, location.pathname) !== null
- const displayName = profile?.display_name ?? user?.email ?? ''
+ const shell = fullWidth ? EDITOR_SHELL : DEFAULT_SHELL
return (
-
+
-
-
-
-
-
-
- {t(pageTitleKey(location.pathname))}
-
-
-
-
-
-
{displayName}
-
-
-
+
setDrawerOpen(true)} />
@@ -126,7 +69,11 @@ export default function AppLayout() {
- setDrawerOpen(false)} />
+ setDrawerOpen(false)}
+ closesFrom={shell.closesFrom}
+ />