feat(dashboard): Revamp UI components for improved layout and styling

This commit is contained in:
Abhimanyu Saharan
2026-02-04 21:23:11 +05:30
parent 8a41ba3f77
commit bf2a9452dc
6 changed files with 374 additions and 306 deletions

View File

@@ -16,6 +16,7 @@ import {
XAxis,
YAxis,
} from "recharts";
import { Activity, Clock, PenSquare, Timer, Users } from "lucide-react";
import { DashboardSidebar } from "@/components/organisms/DashboardSidebar";
import { DashboardShell } from "@/components/templates/DashboardShell";
@@ -97,6 +98,13 @@ const formatNumber = (value: number) => value.toLocaleString("en-US");
const formatPercent = (value: number) => `${value.toFixed(1)}%`;
const formatHours = (value: number | null) =>
value === null || !Number.isFinite(value) ? "--" : `${value.toFixed(1)}h`;
const calcProgress = (values?: number[]) => {
if (!values || values.length === 0) return 0;
const max = Math.max(...values);
if (!Number.isFinite(max) || max <= 0) return 0;
const latest = values[values.length - 1] ?? 0;
return Math.max(0, Math.min(100, Math.round((latest / max) * 100)));
};
function buildSeries(series: RangeSeries) {
return series.points.map((point) => ({
@@ -138,8 +146,8 @@ type TooltipProps = {
function TooltipCard({ active, payload, label, formatter }: TooltipProps) {
if (!active || !payload?.length) return null;
return (
<div className="rounded-lg border border-slate-200 bg-white px-3 py-2 text-xs text-slate-700 shadow-lg">
<div className="text-slate-500">{label}</div>
<div className="rounded-lg bg-slate-900/95 px-3 py-2 text-xs text-slate-200 shadow-lg">
<div className="text-slate-400">{label}</div>
<div className="mt-1 space-y-1">
{payload.map((entry) => (
<div key={entry.name} className="flex items-center justify-between gap-3">
@@ -164,31 +172,37 @@ function KpiCard({
label,
value,
sublabel,
sparkline,
icon,
progress = 0,
}: {
label: string;
value: string;
sublabel?: string;
sparkline?: { values: number[]; labels: string[] };
icon: React.ReactNode;
progress?: number;
}) {
return (
<div className="rounded-xl border border-slate-200 bg-white p-5 shadow-sm">
<div className="text-xs font-semibold uppercase tracking-[0.24em] text-slate-500">
{label}
</div>
<div className="mt-2 text-3xl font-semibold text-slate-900">{value}</div>
{sublabel ? (
<div className="mt-2 text-xs text-slate-500">{sublabel}</div>
) : null}
{sparkline ? (
<div className="mt-4">
<MetricSparkline
values={sparkline.values}
labels={sparkline.labels}
bucket="week"
/>
<div className="stat-card rounded-xl border border-slate-200 bg-white p-6 shadow-sm transition">
<div className="mb-4 flex items-center justify-between">
<p className="text-xs font-semibold uppercase tracking-wider text-slate-500">
{label}
</p>
<div className="rounded-lg bg-blue-50 p-2 text-blue-600">
{icon}
</div>
</div>
<div className="flex items-end gap-2">
<h3 className="font-heading text-4xl font-bold text-slate-900">{value}</h3>
</div>
{sublabel ? (
<p className="mt-2 text-xs text-slate-500">{sublabel}</p>
) : null}
<div className="mt-3 h-1 overflow-hidden rounded-full bg-slate-100">
<div
className="h-full rounded-full bg-gradient-to-r from-blue-500 to-blue-600"
style={{ width: `${progress}%` }}
/>
</div>
</div>
);
}
@@ -205,24 +219,30 @@ function ChartCard({
sparkline?: { values: number[]; labels: string[] };
}) {
return (
<div className="rounded-xl border border-slate-200 bg-white p-5 shadow-sm">
<div className="flex items-start justify-between">
<div className="rounded-xl border border-slate-200 bg-white p-6 shadow-sm">
<div className="mb-6 flex items-center justify-between">
<div>
<div className="text-xs font-semibold uppercase tracking-[0.22em] text-slate-500">
{subtitle}
</div>
<div className="mt-1 text-lg font-semibold text-slate-900">{title}</div>
<h3 className="font-heading text-base font-semibold text-slate-900">
{title}
</h3>
<p className="mt-1 text-sm text-slate-500">{subtitle}</p>
</div>
<div className="text-xs text-slate-500">24h</div>
<span className="rounded-full bg-slate-100 px-3 py-1.5 text-xs font-medium text-slate-500">
24h
</span>
</div>
<div className="mt-4 h-56">{children}</div>
<div className="h-56">{children}</div>
{sparkline ? (
<div className="mt-4">
<div className="text-xs text-slate-500">7d trend</div>
<div className="mt-4 border-t border-slate-100 pt-4">
<div className="flex items-center gap-2 text-xs text-slate-500">
<span className="h-2 w-2 rounded-full bg-blue-500" />
7d trend
</div>
<MetricSparkline
values={sparkline.values}
labels={sparkline.labels}
bucket="week"
className="mt-2"
/>
</div>
) : null}
@@ -301,6 +321,23 @@ export default function DashboardPage() {
[metrics],
);
const activeProgress = useMemo(
() => (metrics ? Math.min(100, metrics.kpis.active_agents * 12.5) : 0),
[metrics],
);
const wipProgress = useMemo(
() => calcProgress(wipSpark?.values),
[wipSpark],
);
const errorProgress = useMemo(
() => calcProgress(errorSpark?.values),
[errorSpark],
);
const cycleProgress = useMemo(
() => calcProgress(cycleSpark?.values),
[cycleSpark],
);
const updatedAtLabel = useMemo(() => {
if (!metrics?.generated_at) return null;
const date = new Date(metrics.generated_at);
@@ -311,221 +348,242 @@ export default function DashboardPage() {
return (
<DashboardShell>
<SignedOut>
<div className="flex h-full flex-col items-center justify-center gap-4 rounded-2xl surface-panel p-10 text-center lg:col-span-2">
<p className="text-sm text-muted">
Sign in to access the dashboard.
</p>
<SignInButton
mode="modal"
forceRedirectUrl="/onboarding"
signUpForceRedirectUrl="/onboarding"
>
<Button>Sign in</Button>
</SignInButton>
<div className="col-span-2 flex min-h-[calc(100vh-64px)] items-center justify-center bg-slate-50 p-10 text-center">
<div className="rounded-xl border border-slate-200 bg-white px-8 py-6 shadow-sm">
<p className="text-sm text-slate-600">
Sign in to access the dashboard.
</p>
<SignInButton
mode="modal"
forceRedirectUrl="/onboarding"
signUpForceRedirectUrl="/onboarding"
>
<Button className="mt-4">Sign in</Button>
</SignInButton>
</div>
</div>
</SignedOut>
<SignedIn>
<DashboardSidebar />
<div className="flex h-full flex-col gap-6">
<div className="flex items-center justify-between">
<h2 className="text-lg font-semibold text-strong">Dashboard</h2>
{updatedAtLabel ? (
<div className="text-xs text-muted">Updated {updatedAtLabel}</div>
<main className="flex-1 overflow-y-auto bg-slate-50">
<div className="border-b border-slate-200 bg-white px-8 py-6">
<div className="flex items-center justify-between">
<div>
<h2 className="font-heading text-2xl font-semibold text-slate-900 tracking-tight">
Dashboard
</h2>
<p className="mt-1 text-sm text-slate-500">
Monitor your mission control operations
</p>
</div>
{updatedAtLabel ? (
<div className="flex items-center gap-2 text-sm text-slate-500">
<Clock className="h-4 w-4" />
Updated {updatedAtLabel}
</div>
) : null}
</div>
</div>
<div className="p-8">
{error ? (
<div className="rounded-lg border border-slate-200 bg-white p-4 text-sm text-slate-600 shadow-sm">
{error}
</div>
) : null}
{isLoading && !metrics ? (
<div className="rounded-xl border border-slate-200 bg-white p-6 text-sm text-slate-500 shadow-sm">
Loading dashboard metrics
</div>
) : null}
{metrics ? (
<>
<div className="grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-4">
<KpiCard
label="Active agents"
value={formatNumber(metrics.kpis.active_agents)}
sublabel="Last 10 minutes"
icon={<Users className="h-4 w-4" />}
progress={activeProgress}
/>
<KpiCard
label="Tasks in progress"
value={formatNumber(metrics.kpis.tasks_in_progress)}
sublabel="Current WIP"
icon={<PenSquare className="h-4 w-4" />}
progress={wipProgress}
/>
<KpiCard
label="Error rate"
value={formatPercent(metrics.kpis.error_rate_pct)}
sublabel="24h average"
icon={<Activity className="h-4 w-4" />}
progress={errorProgress}
/>
<KpiCard
label="Median cycle time"
value={formatHours(metrics.kpis.median_cycle_time_hours_7d)}
sublabel="7d median"
icon={<Timer className="h-4 w-4" />}
progress={cycleProgress}
/>
</div>
<div className="mt-8 grid grid-cols-1 gap-6 lg:grid-cols-2">
<ChartCard
title="Completed Tasks"
subtitle="Throughput"
sparkline={throughputSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<BarChart data={throughputSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e2e8f0" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
width={40}
/>
<Tooltip content={<TooltipCard formatter={(v) => formatNumber(v)} />} />
<Bar dataKey="value" name="Completed" fill="#2563eb" radius={[6, 6, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</ChartCard>
<ChartCard
title="Avg Hours to Review"
subtitle="Cycle time"
sparkline={cycleSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<LineChart data={cycleSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e2e8f0" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
width={40}
/>
<Tooltip
content={<TooltipCard formatter={(v) => `${v.toFixed(1)}h`} />}
/>
<Line
type="monotone"
dataKey="value"
name="Hours"
stroke="#1d4ed8"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</ChartCard>
<ChartCard
title="Failed Events"
subtitle="Error rate"
sparkline={errorSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<LineChart data={errorSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e2e8f0" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
width={40}
/>
<Tooltip
content={<TooltipCard formatter={(v) => formatPercent(v)} />}
/>
<Line
type="monotone"
dataKey="value"
name="Error rate"
stroke="#1e40af"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</ChartCard>
<ChartCard
title="Status Distribution"
subtitle="Work in progress"
sparkline={wipSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={wipSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e2e8f0" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#94a3b8", fontSize: 11 }}
width={40}
/>
<Tooltip content={<TooltipCard formatter={(v) => formatNumber(v)} />} />
<Area
type="monotone"
dataKey="inbox"
name="Inbox"
stackId="wip"
fill="#dbeafe"
stroke="#93c5fd"
fillOpacity={0.8}
/>
<Area
type="monotone"
dataKey="in_progress"
name="In progress"
stackId="wip"
fill="#93c5fd"
stroke="#2563eb"
fillOpacity={0.8}
/>
<Area
type="monotone"
dataKey="review"
name="Review"
stackId="wip"
fill="#60a5fa"
stroke="#1d4ed8"
fillOpacity={0.85}
/>
</AreaChart>
</ResponsiveContainer>
</ChartCard>
</div>
</>
) : null}
</div>
{error ? (
<div className="rounded-lg border border-slate-200 bg-slate-50 p-3 text-xs text-slate-600">
{error}
</div>
) : null}
{isLoading && !metrics ? (
<div className="rounded-xl border border-slate-200 bg-white p-6 text-sm text-slate-500 shadow-sm">
Loading dashboard metrics
</div>
) : null}
{metrics ? (
<>
<div className="grid gap-4 lg:grid-cols-4">
<KpiCard
label="Active agents"
value={formatNumber(metrics.kpis.active_agents)}
sublabel="Last 10 minutes"
/>
<KpiCard
label="Tasks in progress"
value={formatNumber(metrics.kpis.tasks_in_progress)}
sublabel="Current WIP"
sparkline={wipSpark ?? undefined}
/>
<KpiCard
label="Error rate"
value={formatPercent(metrics.kpis.error_rate_pct)}
sublabel="24h average"
sparkline={errorSpark ?? undefined}
/>
<KpiCard
label="Median cycle time"
value={formatHours(metrics.kpis.median_cycle_time_hours_7d)}
sublabel="7d median"
sparkline={cycleSpark ?? undefined}
/>
</div>
<div className="grid gap-6 lg:grid-cols-2">
<ChartCard
title="Throughput"
subtitle="Completed tasks"
sparkline={throughputSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<BarChart data={throughputSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e5e7eb" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
width={40}
/>
<Tooltip content={<TooltipCard formatter={(v) => formatNumber(v)} />} />
<Bar dataKey="value" name="Completed" fill="#2563eb" radius={[6, 6, 0, 0]} />
</BarChart>
</ResponsiveContainer>
</ChartCard>
<ChartCard
title="Cycle time"
subtitle="Avg hours to review"
sparkline={cycleSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<LineChart data={cycleSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e5e7eb" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
width={40}
/>
<Tooltip
content={<TooltipCard formatter={(v) => `${v.toFixed(1)}h`} />}
/>
<Line
type="monotone"
dataKey="value"
name="Hours"
stroke="#16a34a"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</ChartCard>
<ChartCard
title="Error rate"
subtitle="Failed events"
sparkline={errorSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<LineChart data={errorSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e5e7eb" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
width={40}
/>
<Tooltip
content={<TooltipCard formatter={(v) => formatPercent(v)} />}
/>
<Line
type="monotone"
dataKey="value"
name="Error rate"
stroke="#dc2626"
strokeWidth={2}
dot={false}
/>
</LineChart>
</ResponsiveContainer>
</ChartCard>
<ChartCard
title="Work in progress"
subtitle="Status distribution"
sparkline={wipSpark ?? undefined}
>
<ResponsiveContainer width="100%" height="100%">
<AreaChart data={wipSeries} margin={{ left: 4, right: 12 }}>
<CartesianGrid vertical={false} stroke="#e5e7eb" />
<XAxis
dataKey="period"
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
/>
<YAxis
tickLine={false}
axisLine={false}
tick={{ fill: "#6b7280", fontSize: 12 }}
width={40}
/>
<Tooltip content={<TooltipCard formatter={(v) => formatNumber(v)} />} />
<Area
type="monotone"
dataKey="inbox"
name="Inbox"
stackId="wip"
fill="#cbd5f5"
stroke="#94a3b8"
fillOpacity={0.7}
/>
<Area
type="monotone"
dataKey="in_progress"
name="In progress"
stackId="wip"
fill="#93c5fd"
stroke="#2563eb"
fillOpacity={0.7}
/>
<Area
type="monotone"
dataKey="review"
name="Review"
stackId="wip"
fill="#86efac"
stroke="#16a34a"
fillOpacity={0.7}
/>
</AreaChart>
</ResponsiveContainer>
</ChartCard>
</div>
</>
) : null}
</div>
</main>
</SignedIn>
</DashboardShell>
);

View File

@@ -4,23 +4,27 @@
:root {
color-scheme: light;
--bg: #f4f6fa;
--bg: #f8fafc;
--surface: #ffffff;
--surface-muted: #eef2f7;
--surface-strong: #e6ecf6;
--border: #d6dce6;
--border-strong: #c2cad9;
--text: #0b1220;
--text-muted: #4b5a73;
--text-quiet: #7c8aa0;
--accent: #1d4ed8;
--accent-strong: #1e40af;
--accent-soft: rgba(29, 78, 216, 0.12);
--success: #0f766e;
--warning: #b45309;
--danger: #b42318;
--shadow-panel: 0 18px 40px rgba(12, 17, 29, 0.08);
--shadow-card: 0 12px 24px rgba(12, 17, 29, 0.06);
--surface-muted: #f1f5f9;
--surface-strong: #e2e8f0;
--border: #e2e8f0;
--border-strong: #cbd5e1;
--text: #0f172a;
--text-muted: #64748b;
--text-quiet: #94a3b8;
--accent: #2563eb;
--accent-strong: #1d4ed8;
--accent-soft: rgba(37, 99, 235, 0.12);
--success: #16a34a;
--warning: #d97706;
--danger: #dc2626;
--shadow-panel:
0 1px 3px rgba(15, 23, 42, 0.12),
0 1px 2px rgba(15, 23, 42, 0.08);
--shadow-card:
0 1px 2px rgba(15, 23, 42, 0.08),
0 2px 6px rgba(15, 23, 42, 0.06);
}
body {

View File

@@ -1,13 +1,12 @@
export function BrandMark() {
return (
<div className="flex items-center gap-3">
<div className="relative grid h-11 w-11 place-items-center rounded-2xl bg-[color:var(--accent)] text-sm font-semibold text-white shadow-lush">
<span className="font-heading tracking-[0.18em]">OC</span>
<span className="absolute -bottom-1 h-1 w-6 rounded-full bg-[color:var(--accent-strong)]" />
<div className="grid h-10 w-10 place-items-center rounded-lg bg-gradient-to-br from-blue-600 to-blue-700 text-xs font-semibold text-white shadow-sm">
<span className="font-heading tracking-[0.2em]">OC</span>
</div>
<div className="leading-tight">
<div className="font-heading text-sm uppercase tracking-[0.28em] text-strong">
OpenClaw
<div className="font-heading text-sm uppercase tracking-[0.26em] text-strong">
OPENCLAW
</div>
<div className="text-[11px] font-medium text-quiet">
Mission Control

View File

@@ -10,18 +10,19 @@ export function DashboardSidebar() {
const pathname = usePathname();
return (
<aside className="flex h-full flex-col gap-6 rounded-2xl surface-panel p-5">
<div className="space-y-3">
<p className="text-xs font-semibold uppercase tracking-[0.32em] text-quiet">
<aside className="flex h-full w-64 flex-col border-r border-slate-200 bg-white">
<div className="flex-1 px-3 py-4">
<p className="px-3 text-xs font-semibold uppercase tracking-wider text-slate-500">
Navigation
</p>
<nav className="space-y-2 text-sm">
<nav className="mt-3 space-y-1 text-sm">
<Link
href="/dashboard"
className={cn(
"flex items-center gap-3 rounded-xl border border-transparent px-3 py-2 font-semibold text-muted transition hover:border-[color:var(--border)] hover:bg-[color:var(--surface-muted)]",
pathname === "/dashboard" &&
"border-[color:var(--accent-soft)] bg-[color:var(--accent-soft)] text-[color:var(--accent-strong)]"
"flex items-center gap-3 rounded-lg px-3 py-2.5 text-slate-700 transition",
pathname === "/dashboard"
? "bg-blue-100 text-blue-800 font-medium"
: "hover:bg-slate-100"
)}
>
<BarChart3 className="h-4 w-4" />
@@ -30,9 +31,10 @@ export function DashboardSidebar() {
<Link
href="/boards"
className={cn(
"flex items-center gap-3 rounded-xl border border-transparent px-3 py-2 font-semibold text-muted transition hover:border-[color:var(--border)] hover:bg-[color:var(--surface-muted)]",
pathname.startsWith("/boards") &&
"border-[color:var(--accent-soft)] bg-[color:var(--accent-soft)] text-[color:var(--accent-strong)]"
"flex items-center gap-3 rounded-lg px-3 py-2.5 text-slate-700 transition",
pathname.startsWith("/boards")
? "bg-blue-100 text-blue-800 font-medium"
: "hover:bg-slate-100"
)}
>
<LayoutGrid className="h-4 w-4" />
@@ -41,9 +43,10 @@ export function DashboardSidebar() {
<Link
href="/agents"
className={cn(
"flex items-center gap-3 rounded-xl border border-transparent px-3 py-2 font-semibold text-muted transition hover:border-[color:var(--border)] hover:bg-[color:var(--surface-muted)]",
pathname.startsWith("/agents") &&
"border-[color:var(--accent-soft)] bg-[color:var(--accent-soft)] text-[color:var(--accent-strong)]"
"flex items-center gap-3 rounded-lg px-3 py-2.5 text-slate-700 transition",
pathname.startsWith("/agents")
? "bg-blue-100 text-blue-800 font-medium"
: "hover:bg-slate-100"
)}
>
<Bot className="h-4 w-4" />
@@ -51,13 +54,11 @@ export function DashboardSidebar() {
</Link>
</nav>
</div>
<div className="rounded-2xl border border-[color:var(--border)] bg-[color:var(--surface-muted)] p-4 text-xs text-quiet">
<p className="font-semibold uppercase tracking-[0.2em] text-strong">
Ops health
</p>
<p className="mt-2">
Live boards and agents appear here once data streams in.
</p>
<div className="border-t border-slate-200 p-4">
<div className="flex items-center gap-2 text-xs text-slate-500">
<span className="h-2 w-2 rounded-full bg-blue-500" />
All systems operational
</div>
</div>
</aside>
);

View File

@@ -24,19 +24,19 @@ export function UserMenu({ className }: { className?: string }) {
<button
type="button"
className={cn(
"flex h-12 items-center gap-2 rounded-lg px-2.5 text-gray-900 transition hover:bg-gray-100",
"flex h-11 items-center rounded-lg border border-transparent px-1 text-slate-900 transition hover:border-slate-200 hover:bg-slate-50",
className,
)}
aria-label="Open user menu"
>
<span className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-gray-100 text-sm font-semibold text-gray-900">
<span className="flex h-11 w-11 items-center justify-center overflow-hidden rounded-lg bg-slate-100 text-sm font-semibold text-slate-900 shadow-sm">
{avatarUrl ? (
<Image
src={avatarUrl}
alt="User avatar"
width={40}
height={40}
className="h-10 w-10 object-cover"
width={44}
height={44}
className="h-11 w-11 object-cover"
/>
) : (
avatarLabel
@@ -46,12 +46,12 @@ export function UserMenu({ className }: { className?: string }) {
</PopoverTrigger>
<PopoverContent
align="end"
sideOffset={8}
className="w-64 rounded-2xl border border-[color:var(--border)] bg-[color:var(--surface)] p-0 shadow-lg"
sideOffset={10}
className="w-64 rounded-2xl border border-slate-200 bg-white p-0 shadow-lg"
>
<div className="border-b border-[color:var(--border)] px-4 py-3">
<div className="border-b border-slate-200 px-4 py-3">
<div className="flex items-center gap-3">
<span className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-full bg-[color:var(--surface-muted)] text-sm font-semibold text-strong">
<span className="flex h-10 w-10 items-center justify-center overflow-hidden rounded-lg bg-slate-100 text-sm font-semibold text-slate-900">
{avatarUrl ? (
<Image
src={avatarUrl}
@@ -65,11 +65,11 @@ export function UserMenu({ className }: { className?: string }) {
)}
</span>
<div className="min-w-0">
<div className="truncate text-sm font-semibold text-strong">
<div className="truncate text-sm font-semibold text-slate-900">
{displayName}
</div>
{displayEmail ? (
<div className="truncate text-xs text-muted">{displayEmail}</div>
<div className="truncate text-xs text-slate-500">{displayEmail}</div>
) : null}
</div>
</div>
@@ -78,9 +78,9 @@ export function UserMenu({ className }: { className?: string }) {
<SignOutButton>
<button
type="button"
className="flex w-full items-center gap-2 rounded-xl px-3 py-2 text-sm font-semibold text-strong transition hover:bg-[color:var(--surface-strong)]"
className="flex w-full items-center gap-2 rounded-xl px-3 py-2 text-sm font-semibold text-slate-900 transition hover:bg-slate-100"
>
<LogOut className="h-4 w-4 text-[color:var(--text-quiet)]" />
<LogOut className="h-4 w-4 text-slate-500" />
Sign out
</button>
</SignOutButton>

View File

@@ -2,30 +2,36 @@
import type { ReactNode } from "react";
import { SignedIn } from "@clerk/nextjs";
import { SignedIn, useUser } from "@clerk/nextjs";
import { BrandMark } from "@/components/atoms/BrandMark";
import { UserMenu } from "@/components/organisms/UserMenu";
export function DashboardShell({ children }: { children: ReactNode }) {
const { user } = useUser();
const displayName =
user?.fullName ?? user?.firstName ?? user?.username ?? "Operator";
return (
<div className="relative min-h-screen bg-app text-strong">
<div
className="absolute inset-0 bg-landing-grid opacity-[0.18] pointer-events-none"
aria-hidden="true"
/>
<div className="relative flex min-h-screen w-full flex-col">
<header className="flex flex-wrap items-center justify-between gap-4 border-b border-[color:var(--border)] bg-[color:rgba(244,246,250,0.8)] px-6 py-3 backdrop-blur">
<div className="min-h-screen bg-app text-strong">
<header className="sticky top-0 z-40 border-b border-slate-200 bg-white shadow-sm">
<div className="flex items-center justify-between px-6 py-3">
<BrandMark />
<SignedIn>
<UserMenu />
<div className="flex items-center gap-3">
<div className="hidden text-right lg:block">
<p className="text-sm font-semibold text-slate-900">
{displayName}
</p>
<p className="text-xs text-slate-500">Operator</p>
</div>
<UserMenu />
</div>
</SignedIn>
</header>
<div className="flex-1 px-6 py-6">
<div className="grid gap-6 lg:grid-cols-[260px_1fr]">
{children}
</div>
</div>
</header>
<div className="grid min-h-[calc(100vh-64px)] grid-cols-[260px_1fr] bg-slate-50">
{children}
</div>
</div>
);