refactor: unify floating toolbar sizing and show graph title
This commit is contained in:
@@ -8,6 +8,8 @@ import { Check, ChevronsUpDown, FilePlus2, Home, Network, PanelLeftClose, PanelL
|
||||
import { IconButton } from "@/components/ui/icon-button";
|
||||
import { api, errorText, type Profile } from "@/lib/api";
|
||||
import { boardHref, createBoard, DEFAULT_BOARD_TITLE, loadWorkspaceHome, type Board, type Workspace } from "@/lib/workspace";
|
||||
import { useActiveBoard } from "@/components/workspace/active-board";
|
||||
import toolbar from "@/components/ui/toolbar.module.css";
|
||||
import { UserAvatar } from "@/components/workspace/user-avatar";
|
||||
import { AccountPanel } from "@/components/workspace/account-panel";
|
||||
import { readDemoBoards } from "@/lib/demo-workspace";
|
||||
@@ -15,6 +17,7 @@ import styles from "@/components/workspace/workspace.module.css";
|
||||
|
||||
export default function DashboardSidebar() {
|
||||
const router = useRouter();
|
||||
const { board: activeBoard } = useActiveBoard();
|
||||
const reduceMotion = useReducedMotion();
|
||||
const params = useParams<{ workspace?: string; board?: string }>();
|
||||
const searchParams = useSearchParams();
|
||||
@@ -128,6 +131,9 @@ export default function DashboardSidebar() {
|
||||
} catch (e) { setError(errorText(e)); }
|
||||
}
|
||||
|
||||
const currentTitle = activeBoard && activeBoard.id === params.board && activeBoard.workspace_id === workspace
|
||||
? activeBoard.title
|
||||
: boards.find((board) => board.id === params.board)?.title || (params.board ? "正在读取图谱…" : "工作空间");
|
||||
const name = profile?.display_name || profile?.username || "账户";
|
||||
const currentWorkspace = workspaces.find((w) => w.id === workspace);
|
||||
const filtered = boards.filter((b) => b.title.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()));
|
||||
@@ -142,7 +148,7 @@ export default function DashboardSidebar() {
|
||||
<>
|
||||
<AnimatePresence initial={false}>
|
||||
{collapsed && (
|
||||
<motion.div key="sidebar-controls" className={styles.floating} aria-label="侧边栏快捷操作"
|
||||
<motion.div key="sidebar-controls" className={`${toolbar.surface} ${styles.floating}`} aria-label="侧边栏快捷操作"
|
||||
initial={{ opacity: 0, y: reduceMotion ? 0 : -6 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
exit={{ opacity: 0, y: reduceMotion ? 0 : -6 }}
|
||||
@@ -153,6 +159,7 @@ export default function DashboardSidebar() {
|
||||
srcSet="/brand/png/logo-light/endoleap-16.png 1x, /brand/png/logo-light/endoleap-32.png 2x, /brand/png/logo-light/endoleap-48.png 3x"
|
||||
width={16} height={16} alt="" />
|
||||
</Link>
|
||||
<h1 className={styles.floatingTitle} title={currentTitle}>{currentTitle}</h1>
|
||||
<button type="button" className={styles.floatingAvatarButton} popoverTarget="workspace-account" aria-label="账户和工作空间">
|
||||
<UserAvatar name={name} url={profile?.avatar_url} />
|
||||
</button>
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import "@xyflow/react/dist/style.css";
|
||||
import { Suspense, type ReactNode } from "react";
|
||||
import { ActiveBoardProvider } from "@/components/workspace/active-board";
|
||||
import DashboardSidebar from "./dashboard";
|
||||
import styles from "@/components/workspace/workspace.module.css";
|
||||
|
||||
export default function DashboardLayout({ children }: { children: ReactNode }) {
|
||||
return (
|
||||
<div className={styles.shell}>
|
||||
<Suspense fallback={<aside className={styles.sidebar} aria-label="正在加载侧边栏" aria-busy="true" />}>
|
||||
<DashboardSidebar />
|
||||
</Suspense>
|
||||
{children}
|
||||
</div>
|
||||
<ActiveBoardProvider>
|
||||
<div className={styles.shell}>
|
||||
<Suspense fallback={<aside className={styles.sidebar} aria-label="正在加载侧边栏" aria-busy="true" />}>
|
||||
<DashboardSidebar />
|
||||
</Suspense>
|
||||
{children}
|
||||
</div>
|
||||
</ActiveBoardProvider>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user