diff --git a/apps/web/index.html b/apps/web/index.html index b72a9d3d7d106..74515533e8d85 100644 --- a/apps/web/index.html +++ b/apps/web/index.html @@ -714,7 +714,96 @@ background-repeat: repeat; background-size: var(--surface-grain-size); } + /* A narrow window, where T3's left panel is a modal sheet (sidebar.tsx, SIDEBAR_MOBILE_QUERY): + the conversation takes the whole width without the rail, the open left panel carries the + rail at its left edge, and the open right panel takes the whole width. The script below moves the rail into the panel while it is open, so + the rail is part of the dialog for the keyboard and screen readers and slides with it. */ + @media (max-width: 767px) { + #root { + padding-left: 0; + } + body > lazurio-rail:defined:not([data-lazurio-dialog-open]) { + display: none; + } + /* The rail is no longer #root's sibling while it is in the panel; T3's fixed controls stay + contained all the same, below the panel. */ + :root:has(lazurio-rail:defined) #root [data-slot="sidebar-wrapper"] { + contain: layout paint; + } + [data-mobile="true"][data-sidebar="sidebar"]:has(> lazurio-rail:defined) { + padding-left: var(--lazurio-rail-width, 0px); + } + /* The right panel (RightPanelSheet.tsx, the one other sheet) takes the whole screen: no + sliver of the conversation beside it. Its own toggle closes it, back to the conversation. */ + :root:has(lazurio-rail:defined) [data-slot="sheet-popup"]:not([data-mobile]) { + width: 100vw; + min-width: 0; + max-width: none; + border-inline-start: 0; + padding-inline-start: env(safe-area-inset-left); + } + } + diff --git a/apps/web/src/lazurio/narrowRail.browser.test.tsx b/apps/web/src/lazurio/narrowRail.browser.test.tsx new file mode 100644 index 0000000000000..47addc88bce4d --- /dev/null +++ b/apps/web/src/lazurio/narrowRail.browser.test.tsx @@ -0,0 +1,214 @@ +import { page, userEvent } from "vite-plus/test/browser"; +import { describe, expect, it } from "vite-plus/test"; + +import "~/index.css"; + +import indexHtml from "../../index.html?raw"; +import { render } from "../../test/render"; +import { RightPanelSheet } from "../components/RightPanelSheet"; +import { Sidebar, SidebarProvider, SidebarTrigger } from "../components/ui/sidebar"; + +// The rail in a narrow window (index.html, the Lazurio shell slot): hidden beside the +// conversation, inside T3's open left panel, and shown wherever it stands while a dialog of its +// own is open. The style and the script are index.html's own; the rail is a stand-in with the +// shape the shell's `` has: an open shadow root, a control and a dialog. + +const narrowStyle = (() => { + const match = indexHtml.match(/\n(\s*\/\* A narrow window[\s\S]*?)\n\s*<\/style>/); + if (!match?.[1]) throw new Error("Could not find the narrow rail style in index.html"); + return match[1]; +})(); +const moverScript = (() => { + const match = indexHtml.match(/