refactor(ui): add page layout system under src/layouts

This commit is contained in:
sam committed 2026-11-27 16:34:05 +11:00
1 parent ccb36a1ca9
commit 0d267170c6
7 files changed
+64 -10

No files matched your search

+6 -10
View File
@@ -22,7 +22,7 @@ import { Alert, AlertDescription } from "@/components/ui/alert";
import { Card } from "@/components/ui/card";
import { SidebarInset, SidebarProvider } from "@/components/ui/sidebar";
import NewTaskDialog from "@/tasks/NewTaskDialog.vue";
import SettingsShell from "@/settings/SettingsShell.vue";
import { layoutComponent, resolveLayout } from "@/layouts";
import { TooltipProvider } from "@/components/ui/tooltip";
import { hiddenPaths, navTree } from "@/lib/nav";
import { loadTaskMeta } from "@/lib/task-meta";
@@ -35,7 +35,7 @@ const accounts=useAccountsStore();
const session = useSessionStore();
const route = useRoute();
const router = useRouter();
const workflowsPage = computed(() => route.name === "workflow");
const canvasLayout = computed(() => resolveLayout(route.meta) === "canvas");
const hidden = computed(() => hiddenPaths(session.sections));
const sectionLink = computed(() =>
route.meta.nav === false && typeof route.meta.navPath === "string"
@@ -122,7 +122,7 @@ watch(() => accounts.status?.user, (user) => {
<SidebarProvider class="bg-[var(--workspace)]">
<a href="#main-content" class="sr-only focus:not-sr-only focus:fixed focus:top-2 focus:left-4 focus:z-[60] focus:rounded-md focus:bg-card focus:px-3 focus:py-2">Skip to main content</a>
<AppSidebar :hidden="hidden" />
<SidebarInset class="min-w-0 bg-[var(--workspace)] md:ml-[var(--chat-pin-l,0px)] md:mr-[var(--chat-pin-r,0px)]" :class="workflowsPage && 'max-md:h-dvh'">
<SidebarInset class="min-w-0 bg-[var(--workspace)] md:ml-[var(--chat-pin-l,0px)] md:mr-[var(--chat-pin-r,0px)]" :class="canvasLayout && 'max-md:h-dvh'">
<header class="bg-card border-border-strong sticky top-0 z-30 flex h-14 shrink-0 items-center gap-2 border-b px-3 shadow-[var(--shadow-sm)] sm:px-4">
<Brand />
<Breadcrumb class="max-md:min-w-0">
@@ -147,7 +147,7 @@ watch(() => accounts.status?.user, (user) => {
</div>
</header>
<div id="main-content" ref="main" tabindex="-1" class="@container scroll-mt-16 w-full flex-1 px-6 py-5 pb-[calc(var(--chat-dock-clear,6rem)+1rem)] outline-none max-lg:p-4 max-lg:pb-[calc(var(--chat-dock-clear,6rem)+1rem)]"
:class="workflowsPage && 'max-md:flex max-md:min-h-0 max-md:flex-col'">
:class="canvasLayout && 'max-md:flex max-md:min-h-0 max-md:flex-col'">
<!--
Keyed on the path and its parameters but not the query: a query-only
change is an entry state, so the page keeps the operator's filters,
@@ -156,13 +156,9 @@ watch(() => accounts.status?.user, (user) => {
open tab stays open on the next.
-->
<RouterView v-slot="{ Component, route }">
<SettingsShell v-if="route.meta.settings" scope="instance">
<component :is="layoutComponent(route.meta)">
<component :is="Component" :key="route.path" />
</SettingsShell>
<SettingsShell v-else-if="route.meta.org" scope="org">
<component :is="Component" :key="route.path" />
</SettingsShell>
<component :is="Component" v-else :key="route.path" />
</component>
</RouterView>
</div>
</SidebarInset>
+5
View File
@@ -0,0 +1,5 @@
<template>
<div class="contents max-md:flex max-md:min-h-0 max-md:flex-1 max-md:flex-col">
<slot />
</div>
</template>
+3
View File
@@ -0,0 +1,3 @@
<template>
<slot />
</template>
+9
View File
@@ -0,0 +1,9 @@
<script setup lang="ts">
import SettingsShell from "@/settings/SettingsShell.vue";
</script>
<template>
<SettingsShell scope="org">
<slot />
</SettingsShell>
</template>
+9
View File
@@ -0,0 +1,9 @@
<script setup lang="ts">
import SettingsShell from "@/settings/SettingsShell.vue";
</script>
<template>
<SettingsShell scope="instance">
<slot />
</SettingsShell>
</template>
+31
View File
@@ -0,0 +1,31 @@
import type { Component } from "vue";
import CanvasLayout from "./CanvasLayout.vue";
import DefaultLayout from "./DefaultLayout.vue";
import OrgLayout from "./OrgLayout.vue";
import SettingsLayout from "./SettingsLayout.vue";
export type LayoutName = "default" | "settings" | "org" | "canvas";
const layouts: Record<LayoutName, Component> = {
default: DefaultLayout,
settings: SettingsLayout,
org: OrgLayout,
canvas: CanvasLayout,
};
/** Resolves a route's layout from meta.layout, falling back to scope flags and default. */
export function resolveLayout(meta: Record<string, unknown>): LayoutName {
const explicit = meta.layout;
if (typeof explicit === "string" && explicit in layouts) {
return explicit as LayoutName;
}
if (meta.settings) return "settings";
if (meta.org) return "org";
return "default";
}
/** Returns the layout component wrapping the current page. */
export function layoutComponent(meta: Record<string, unknown>): Component {
return layouts[resolveLayout(meta)];
}
+1
View File
@@ -6,6 +6,7 @@ definePage({
nav: false,
navPath: "/workflows",
section: "workflow_editor",
layout: "canvas",
},
});