import { useState } from "react";
import {
Avatar,
AvatarFallback,
Card,
CardContent,
CardDescription,
CardHeader,
CardTitle,
} from "@godxjp/ui/data-display";
import { Button, Icon, Text } from "@godxjp/ui/general";
import { AppShell, Flex, PageContainer, Sidebar, Topbar, TopbarItem } from "@godxjp/ui/layout";
import type { SidebarSectionProp } from "@godxjp/ui/layout";
import {
DropdownMenu,
DropdownMenuContent,
DropdownMenuItem,
DropdownMenuLabel,
DropdownMenuSeparator,
DropdownMenuTrigger,
} from "@godxjp/ui/navigation";
import {
Bell,
Building2,
FileText,
LayoutDashboard,
LogOut,
PanelLeftClose,
PanelLeftOpen,
Settings,
Target,
Users,
} from "lucide-react";
/**
* TopbarItem — one interactive cell of a Topbar slot, shaped like part of the bar: full bar
* height, the bar's own hover surface, and the focus mark hosted INSIDE the cell. The second bar
* below shows the same triggers built from `Button` instead, which is the floating-pill read this
* component exists to replace.
*/
const SECTIONS: SidebarSectionProp[] = [
{
label: "会計",
items: [
{ id: "dashboard", label: "ダッシュボード", icon: LayoutDashboard },
{ id: "journal", label: "仕訳", icon: FileText },
],
},
{ label: "管理", items: [{ id: "users", label: "ユーザー", icon: Users }] },
];
export default function Demo() {
const [collapsed, setCollapsed] = useState(false);
return (
}
topbar={
setCollapsed((open) => !open)}
>
{collapsed ? (
) : (
)}
}
end={
<>
SD
佐藤 大輔
設定
ログアウト
>
}
/>
}
>
上のバーがこのコンポーネントです
セルの高さは自分では決めません。AppShell のグリッド行、単体で使うときは
--topbar-height、粗いポインタのときはその上書き。どれであっても、セルはバーの
高さまで伸びます。ホバー面もバー自身の面です。
DropdownMenuTrigger には `asChild` で渡します。メニューが開いている間は
[data-state="open"] でセルが点いたままになります。
Button を入れた場合(比較)
同じスロットに Button を置くと、背の高いバーの中に --control-height
の丸いピルが浮きます。バーの一部ではなく、バーに落ちてきた部品に見えます。
}
end={
<>
>
}
/>
包んだグリフ(icon スロットと Icon)
`.ui-topbar-item > svg` は直接の子だけを見ます。ブレークポイントで隠すために
グリフを包むと、その規則は届かず lucide 既定の 24px で描かれます(390px
のセルで実測)。 セル自身が持つ `icon` スロットに渡すか、包むなら `Icon`
を使えば、どちらもバーの段 (--topbar-icon-size)に載ります。
}>経理部
東京本社
>
}
/>
リンクのセルと、幅で畳むセル
`asChild` でもセルは `icon`
スロットを子要素の中に差し込み、リンクそのものがセルです。 `labelHideBelow`
はその幅未満でラベルを視覚的にだけ隠すので、アイコンだけになっても
ラベルがアクセシブルネームとして残ります。`iconHideFrom`
はその幅以上でアイコンを外します。 ビューポートを 640px
の前後に動かして確認してください。
}>
目標
}
labelHideBelow="sm"
iconHideFrom="sm"
>
今期の目標
} labelHideBelow="md">
東京本社
>
}
/>
);
}