Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
feat(web): add sidebar layout
Naiyuan Qing4036463d6cf4
diff --git a/apps/web/app/layout.tsx b/apps/web/app/layout.tsxindex 8c34579678..08c187da73 100644--- a/apps/web/app/layout.tsx+++ b/apps/web/app/layout.tsx@@ -1,6 +1,7 @@import type { Metadata } from "next";import { Geist, Geist_Mono, Inter } from "next/font/google";import "@multica/ui/globals.css";+import { SidebarProvider } from "@multica/ui/components/ui/sidebar";const inter = Inter({subsets:['latin'],variable:'--font-sans'});@@ -29,7 +30,9 @@ export default function RootLayout({<bodyclassName={`${geistSans.variable} ${geistMono.variable} antialiased`}>- {children}+ <SidebarProvider>+ {children}+ </SidebarProvider></body></html>);diff --git a/apps/web/app/page.tsx b/apps/web/app/page.tsxindex 356262c352..2771418906 100644--- a/apps/web/app/page.tsx+++ b/apps/web/app/page.tsx@@ -1,6 +1,19 @@"use client"import { Markdown } from "@multica/ui/components/markdown"+import {+ Sidebar,+ SidebarHeader,+ SidebarContent,+ SidebarGroup,+ SidebarGroupLabel,+ SidebarGroupContent,+ SidebarMenu,+ SidebarMenuItem,+ SidebarMenuButton,+ SidebarInset,+ SidebarTrigger,+} from "@multica/ui/components/ui/sidebar"const MOCK_MD = `# Markdown 渲染器示例@@ -45,12 +58,46 @@ async function fetchUser(id: string): Promise<User> {这是一个 [链接示例](https://github.com)。`+const NAV_ITEMS = [+ { title: "Home", url: "#" },+ { title: "Documents", url: "#" },+ { title: "Settings", url: "#" },+]+export default function Page() {return (- <div className="min-h-screen bg-background text-foreground flex items-center justify-center p-8">- <div className="max-w-2xl w-full">- <Markdown mode="full">{MOCK_MD}</Markdown>- </div>- </div>+ <>+ <Sidebar>+ <SidebarHeader>+ <span className="text-lg font-semibold px-2 py-1">Multica</span>+ </SidebarHeader>+ <SidebarContent>+ <SidebarGroup>+ <SidebarGroupLabel>Navigation</SidebarGroupLabel>+ <SidebarGroupContent>+ <SidebarMenu>+ {NAV_ITEMS.map((item) => (+ <SidebarMenuItem key={item.title}>+ <SidebarMenuButton>+ {item.title}+ </SidebarMenuButton>+ </SidebarMenuItem>+ ))}+ </SidebarMenu>+ </SidebarGroupContent>+ </SidebarGroup>+ </SidebarContent>+ </Sidebar>+ <SidebarInset>+ <header className="flex h-12 items-center border-b px-4">+ <SidebarTrigger />+ </header>+ <main className="flex-1 p-8">+ <div className="max-w-2xl mx-auto">+ <Markdown mode="full">{MOCK_MD}</Markdown>+ </div>+ </main>+ </SidebarInset>+ </>)}diff --git a/packages/ui/src/hooks/use-mobile.ts b/packages/ui/src/hooks/use-mobile.tsnew file mode 100644index 0000000000..2b0fe1dfef--- /dev/null+++ b/packages/ui/src/hooks/use-mobile.ts@@ -0,0 +1,19 @@+import * as React from "react"++const MOBILE_BREAKPOINT = 768++export function useIsMobile() {+ const [isMobile, setIsMobile] = React.useState<boolean | undefined>(undefined)++ React.useEffect(() => {+ const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`)+ const onChange = () => {+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)+ }+ mql.addEventListener("change", onChange)+ setIsMobile(window.innerWidth < MOBILE_BREAKPOINT)+ return () => mql.removeEventListener("change", onChange)+ }, [])++ return !!isMobile+}