Open source CapCut alternative.
TypeScript
feat(site): the su rail hides and shows on every width
David Le9c74a5707fa3
diff --git a/site/src/app/su/SuHeader.tsx b/site/src/app/su/SuHeader.tsxindex 29359da3..9936d5f1 100644--- a/site/src/app/su/SuHeader.tsx+++ b/site/src/app/su/SuHeader.tsx@@ -21,8 +21,8 @@ const PAGE_ACTIONS: Partial<Record<SuPage["href"], ComponentType>> = {};// The title is the surface's; the description and action belong to whichever-// page is showing, since a section's tabs each drive their own work. On a-// phone the rail is off screen, so the header carries the button that opens it.+// page is showing, since a section's tabs each drive their own work. The+// header carries the button that shows and hides the rail (also ⌘B).export function SuHeader() {const pathname = usePathname();const { surface, page } = suSurfaceAt(pathname);@@ -30,7 +30,7 @@ export function SuHeader() {return (<div className="sticky top-0 z-20 mx-auto flex w-full max-w-6xl shrink-0 items-start justify-between gap-4 bg-background px-4 pt-4 pb-4 md:px-10 md:pt-9"><div className="flex min-w-0 items-start gap-2">- <SidebarTrigger className="-ml-1.5 shrink-0 md:hidden" />+ <SidebarTrigger className="-ml-1.5 shrink-0" /><div className="min-w-0"><h1 className="text-lg font-semibold tracking-tight">{surface.title}diff --git a/site/src/app/su/SuShell.tsx b/site/src/app/su/SuShell.tsxindex eaf706c7..c4e8e812 100644--- a/site/src/app/su/SuShell.tsx+++ b/site/src/app/su/SuShell.tsx@@ -1,11 +1,11 @@"use client";-import type { ReactNode } from "react";+import { useEffect, type CSSProperties, type ReactNode } from "react";import { NoSessionReplay } from "@/app/_components/NoSessionReplay";import { SuHeader } from "@/app/su/SuHeader";import { SuSidebar } from "@/app/su/SuSidebar";-import { SidebarProvider } from "@/components/ui/sidebar";+import { SidebarProvider, useSidebar } from "@/components/ui/sidebar";import { useWarmAnalyticsRollup } from "@/queries/analytics";// The section's two-pane shell. It mounts only for a super user: the proxy@@ -29,9 +29,11 @@ export function SuShell({ children }: { children: ReactNode }) {return (<SidebarProvidertranslate="no"+ style={{ "--sidebar-width": "15rem" } as CSSProperties}className="app-surface h-screen min-h-0 bg-background font-system text-foreground antialiased"><NoSessionReplay />+ <RailState /><SuSidebar /><main className="flex min-w-0 flex-1 flex-col overflow-y-auto"><SuHeader />@@ -47,3 +49,14 @@ export function SuShell({ children }: { children: ReactNode }) {</SidebarProvider>);}++// The rail opens by default so the shell prerenders one way; a rail the+// super user hid stays hidden across loads through the cookie the provider+// writes on every toggle.+function RailState() {+ const { setOpen } = useSidebar();+ useEffect(() => {+ if (/(?:^|;\s*)sidebar_state=false(?:;|$)/.test(document.cookie)) setOpen(false);+ }, [setOpen]);+ return null;+}diff --git a/site/src/app/su/SuSidebar.tsx b/site/src/app/su/SuSidebar.tsxindex 8ce1d768..5b4f01ae 100644--- a/site/src/app/su/SuSidebar.tsx+++ b/site/src/app/su/SuSidebar.tsx@@ -89,7 +89,7 @@ export function SuSidebar() {const pathname = usePathname();const router = useRouter();const here = suSurfaceAt(pathname);- const { isMobile, setOpenMobile } = useSidebar();+ const { setOpenMobile } = useSidebar();useEffect(() => {for (const href of RAIL_PAGES) router.prefetch(href);@@ -100,10 +100,7 @@ export function SuSidebar() {}, [pathname, setOpenMobile]);return (- <Sidebar- collapsible={isMobile ? "offcanvas" : "none"}- className="hidden w-60 shrink-0 border-r border-sidebar-border md:flex"- >+ <Sidebar collapsible="offcanvas" className="border-sidebar-border"><SidebarHeader className="mb-3 flex-row items-center gap-2.5 px-4 pt-4"><span className="grid size-9 shrink-0 place-items-center p-0.5"><img