The VS Code of video editing, built for agents.
TypeScript
Add arrow-left icon and refactor DashboardSidebar components
konstantin-paulus8fbec32a5735
diff --git a/apps/web/src/assets/icons/arrow-left.svg b/apps/web/src/assets/icons/arrow-left.svgnew file mode 100644index 00000000..d6e9a85a--- /dev/null+++ b/apps/web/src/assets/icons/arrow-left.svg@@ -0,0 +1,3 @@+<svg viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">+<path fill-rule="evenodd" clip-rule="evenodd" d="M11.3535 7.64645C11.1583 7.45118 10.8417 7.45118 10.6464 7.64645L6.6464 11.6465C6.4512 11.8417 6.4512 12.1583 6.6464 12.3536L10.6464 16.3536C10.8417 16.5488 11.1583 16.5488 11.3535 16.3536C11.5488 16.1583 11.5488 15.8417 11.3535 15.6464L8.2071 12.5H17C17.2761 12.5 17.5 12.2761 17.5 12C17.5 11.7239 17.2761 11.5 17 11.5H8.2071L11.3535 8.35355C11.5488 8.15829 11.5488 7.84171 11.3535 7.64645Z" fill="currentColor" />+</svg>diff --git a/apps/web/src/components/dashboard/sidebar.tsx b/apps/web/src/components/dashboard/sidebar.tsxindex f4184cd3..72097d89 100644--- a/apps/web/src/components/dashboard/sidebar.tsx+++ b/apps/web/src/components/dashboard/sidebar.tsx@@ -65,32 +65,48 @@ export function DashboardSidebarHeader() {);}+/**+ * Stands in for the header when the sidebar has none. On the macOS desktop+ * build it clears the traffic lights (hiddenInset title bar), except in+ * fullscreen where they are gone.+ */+export function DashboardSidebarTopSpacer() {+ return <div class="h-4 shrink-0 [[data-platform=darwin]:not([data-fullscreen=true])_&]:h-12" />;+}+type DashboardSidebarNavProps = {children: JSX.Element;- footer: JSX.Element;};+/** The scrolling middle of the sidebar: stacked sections, then empty space. */export function DashboardSidebarNav(props: DashboardSidebarNavProps) {return (<div class="flex min-h-0 flex-1 flex-col gap-2 px-3">- <div class="flex shrink-0 flex-col">+ {props.children}+ <div class="min-h-0 flex-1" />+ </div>+ );+}++type DashboardSidebarSectionProps = {+ title?: string;+ children: JSX.Element;+};++export function DashboardSidebarSection(props: DashboardSidebarSectionProps) {+ return (+ <div class="flex shrink-0 flex-col">+ <Show when={props.title}><div class="flex h-8 shrink-0 items-center px-1">- <p class="text-xs text-muted-foreground">- Get Started- </p>+ <p class="text-xs text-muted-foreground">{props.title}</p></div>- {props.children}- </div>- <div class="min-h-0 flex-1" />- <div class="flex shrink-0 flex-col">- {props.footer}- </div>+ </Show>+ {props.children}</div>);}type DashboardSidebarUserProps = {- active: boolean;onClick: () => void;};@@ -113,12 +129,11 @@ export function DashboardSidebarUser(props: DashboardSidebarUserProps) {type="button"onClick={props.onClick}class="flex w-full items-center gap-2 rounded-md p-2 text-left hover:bg-accent focus-ring"- classList={{ "bg-accent": props.active }}><Showwhen={avatarUrl()}fallback={- <div class="grid size-8 shrink-0 place-items-center rounded-full bg-input text-xs text-foreground">+ <div class="grid size-8 shrink-0 place-items-center rounded-full bg-accent text-xs text-foreground">{initial()}</div>}@@ -139,6 +154,7 @@ export function DashboardSidebarUser(props: DashboardSidebarUserProps) {{planLabel()}</span></div>+ <Icon name="settings" class="size-6 shrink-0 text-muted-foreground" /></button></div>);diff --git a/apps/web/src/pages/dashboard.tsx b/apps/web/src/pages/dashboard.tsxindex 03353b51..892b9f98 100644--- a/apps/web/src/pages/dashboard.tsx+++ b/apps/web/src/pages/dashboard.tsx@@ -3,7 +3,7 @@* file, You can obtain one at http://mozilla.org/MPL/2.0/. */import { useSearchParams } from "@solidjs/router";-import { Match, Show, Switch } from "solid-js";+import { Match, Show, Switch, createEffect, createSignal } from "solid-js";import { DashboardAccountView } from "@/components/dashboard/account-view";import { DashboardAiCreditsView } from "@/components/dashboard/ai-credits-view";@@ -13,7 +13,14 @@ import { DashboardHelpView } from "@/components/dashboard/help-view";import { DashboardHomeView } from "@/components/dashboard/home-view";import { DashboardProjectsView } from "@/components/dashboard/projects-view";import { DashboardSettingsView } from "@/components/dashboard/settings-view";-import { DashboardSidebarHeader, DashboardSidebarNav, DashboardSidebarUser, DashboardSidebarItem } from "@/components/dashboard/sidebar";+import {+ DashboardSidebarHeader,+ DashboardSidebarItem,+ DashboardSidebarNav,+ DashboardSidebarSection,+ DashboardSidebarTopSpacer,+ DashboardSidebarUser,+} from "@/components/dashboard/sidebar";import { Separator } from "@/components/ui/separator";import { useFullscreenState } from "@/hooks/use-fullscreen-state";@@ -31,11 +38,24 @@ const DASHBOARD_VIEWS: readonly DashboardView[] = ["help",];+/** The views reached through the settings navigation, not the dashboard one. */+const SETTINGS_VIEWS: readonly DashboardView[] = [+ "account",+ "settings",+ "ai-credits",+ "billing",+ "help",+];+function parseView(value: string | string[] | undefined): DashboardView {const raw = Array.isArray(value) ? value[0] : value;return DASHBOARD_VIEWS.find((v) => v === raw) ?? "home";}+function isSettingsView(view: DashboardView): boolean {+ return SETTINGS_VIEWS.includes(view);+}+export function DashboardPage() {const [params, setParams] = useSearchParams();const isFullscreen = useFullscreenState();@@ -43,27 +63,54 @@ export function DashboardPage() {const view = (): DashboardView => parseView(params.dashboard);const setView = (next: DashboardView) => setParams({ dashboard: next }, { replace: true });+ // Which navigation the sidebar shows. Landing on a settings view (deep link,+ // reload) opens the settings navigation; the user row opens it by itself.+ const [settingsNavOpen, setSettingsNavOpen] = createSignal(isSettingsView(view()));+ createEffect(() => {+ if (isSettingsView(view())) setSettingsNavOpen(true);+ });++ const openProfile = () => {+ setSettingsNavOpen(true);+ setView("account");+ };+ const backToDashboard = () => {+ setSettingsNavOpen(false);+ if (isSettingsView(view())) setView("home");+ };+return (<div class="flex h-screen w-full min-h-0 flex-row overflow-hidden bg-sidebar"><aside class="relative flex min-h-0 w-69 shrink-0 flex-col"><Show when={!!window.desktop && !isFullscreen()}><div class="absolute inset-x-0 top-0 h-10 z-20" style="-webkit-app-region: drag;" /></Show>- <DashboardSidebarHeader />- <DashboardSidebarNav- footer={- <>+ <Show when={!settingsNavOpen()} fallback={<DashboardSidebarTopSpacer />}>+ <DashboardSidebarHeader />+ </Show>+ <DashboardSidebarNav>+ <Show+ when={settingsNavOpen()}+ fallback={+ <DashboardSidebarSection title="Get Started">+ <DashboardSidebarItem active={view() === "home"} onClick={() => setView("home")} icon="home" label="Home" />+ <DashboardSidebarItem active={view() === "projects"} onClick={() => setView("projects")} icon="diffusion-project-file" label="Projects" />+ </DashboardSidebarSection>+ }+ >+ <DashboardSidebarSection>+ <DashboardSidebarItem onClick={backToDashboard} icon="arrow-left" label="Back to dashboard" />+ </DashboardSidebarSection>+ <DashboardSidebarSection title="Settings">+ <DashboardSidebarItem active={view() === "account"} onClick={() => setView("account")} icon="user" label="Account" />+ <DashboardSidebarItem active={view() === "settings"} onClick={() => setView("settings")} icon="settings" label="General" /><DashboardSidebarItem active={view() === "ai-credits"} onClick={() => setView("ai-credits")} icon="ai-generate" label="AI credits" /><DashboardSidebarItem active={view() === "billing"} onClick={() => setView("billing")} icon="billing" label="Billing" />- <DashboardSidebarItem active={view() === "settings"} onClick={() => setView("settings")} icon="settings" label="Settings" /><DashboardSidebarItem active={view() === "help"} onClick={() => setView("help")} icon="help" label="Help" />- </>- }- >- <DashboardSidebarItem active={view() === "home"} onClick={() => setView("home")} icon="home" label="Home" />- <DashboardSidebarItem active={view() === "projects"} onClick={() => setView("projects")} icon="diffusion-project-file" label="Projects" />+ </DashboardSidebarSection>+ </Show></DashboardSidebarNav>- <DashboardSidebarUser active={view() === "account"} onClick={() => setView("account")} />+ <DashboardSidebarUser onClick={openProfile} /></aside><Separator orientation="vertical" class="bg-border-strong" />