Reorganize repo structure and standards references
This commit is contained in:
1 parent
3cb93a81be
commit
be2054274d
5885 files changed
+2588
-195
No files matched your search
@@ -0,0 +1,103 @@
|
||||
import type { Meta, StoryObj } from "@storybook/react";
|
||||
import { useState } from "react";
|
||||
import { DemoBadge } from "./_demo-primitives.js";
|
||||
|
||||
const meta: Meta = {
|
||||
title: "UI / Navigation / Sidebar",
|
||||
};
|
||||
|
||||
export default meta;
|
||||
|
||||
type Story = StoryObj;
|
||||
|
||||
type NavItem = {
|
||||
id: string;
|
||||
label: string;
|
||||
href: string;
|
||||
badge?: { tone: "default" | "warning" | "success"; text: string };
|
||||
};
|
||||
|
||||
const items: ReadonlyArray<NavItem> = [
|
||||
{ id: "dashboard", label: "Dashboard", href: "#dashboard" },
|
||||
{ id: "projects", label: "Projects", href: "#projects", badge: { tone: "default", text: "12" } },
|
||||
{ id: "members", label: "Members", href: "#members" },
|
||||
{ id: "billing", label: "Billing", href: "#billing", badge: { tone: "warning", text: "due" } },
|
||||
{ id: "settings", label: "Settings", href: "#settings" },
|
||||
];
|
||||
|
||||
function Sidebar({ collapsed }: { collapsed: boolean }) {
|
||||
const [active, setActive] = useState("projects");
|
||||
return (
|
||||
<nav
|
||||
aria-label="Primary"
|
||||
style={{
|
||||
width: collapsed ? 56 : 220,
|
||||
background: "var(--color-card)",
|
||||
borderRight: "1px solid var(--color-border)",
|
||||
padding: collapsed ? "12px 6px" : "16px 12px",
|
||||
display: "flex",
|
||||
flexDirection: "column",
|
||||
gap: 2,
|
||||
transition: "width 160ms",
|
||||
minHeight: 320,
|
||||
}}
|
||||
>
|
||||
<div
|
||||
style={{
|
||||
padding: collapsed ? 4 : "4px 8px 12px",
|
||||
fontSize: 12,
|
||||
letterSpacing: 1,
|
||||
textTransform: "uppercase",
|
||||
color: "var(--color-muted)",
|
||||
}}
|
||||
>
|
||||
{collapsed ? "T" : "Toolctrl"}
|
||||
</div>
|
||||
{items.map((item) => (
|
||||
<a
|
||||
key={item.id}
|
||||
href={item.href}
|
||||
onClick={(event) => {
|
||||
event.preventDefault();
|
||||
setActive(item.id);
|
||||
}}
|
||||
style={{
|
||||
display: "flex",
|
||||
alignItems: "center",
|
||||
justifyContent: collapsed ? "center" : "space-between",
|
||||
padding: collapsed ? 8 : "8px 10px",
|
||||
borderRadius: 6,
|
||||
background: active === item.id ? "var(--color-accent)" : "transparent",
|
||||
color: active === item.id ? "var(--color-fg)" : "var(--color-muted)",
|
||||
textDecoration: "none",
|
||||
fontSize: 14,
|
||||
fontWeight: active === item.id ? 600 : 500,
|
||||
}}
|
||||
>
|
||||
<span>{collapsed ? item.label.charAt(0) : item.label}</span>
|
||||
{!collapsed && item.badge ? (
|
||||
<DemoBadge tone={item.badge.tone}>{item.badge.text}</DemoBadge>
|
||||
) : null}
|
||||
</a>
|
||||
))}
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
|
||||
export const Expanded: Story = {
|
||||
render: () => <Sidebar collapsed={false} />,
|
||||
};
|
||||
|
||||
export const Collapsed: Story = {
|
||||
render: () => <Sidebar collapsed={true} />,
|
||||
};
|
||||
|
||||
export const SideBySide: Story = {
|
||||
name: "Side by side",
|
||||
render: () => (
|
||||
<div style={{ display: "flex", gap: 24 }}>
|
||||
<Sidebar collapsed={true} />
|
||||
<Sidebar collapsed={false} />
|
||||
</div>
|
||||
),
|
||||
};
|
||||
Reference in new issue
Block a user