caelum0x d56639a594
Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Menivor — open source release (MIT), free to use and fork
Paid, hosted product at menivor.com, now retired as a company project.
Fresh squashed history of the cleaned working tree (secret-scanned,
no .env, no customer data, no outreach logs). Built on
MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
2026-12-04 02:10:26 +03:00

106 lines
3.4 KiB
TypeScript

import * as React from "react";
import { Filter } from "lucide-react";
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
import type { AnalyticsFunnel } from "@/lib/types";
import { cn } from "@/lib/utils";
import { formatCount, formatPct } from "./format";
interface FunnelStep {
readonly label: string;
readonly value: number;
readonly barClassName: string;
readonly hint: string;
}
export interface FunnelChartProps {
funnel: Readonly<AnalyticsFunnel>;
}
/**
* A simple stepped-bar funnel: created -> completed -> published. Each step's
* width is proportional to the top of the funnel (`created`), with its absolute
* count and conversion share of `created`. Pure CSS bars — no chart library.
*/
export function FunnelChart({ funnel }: Readonly<FunnelChartProps>) {
const top = Math.max(funnel.created, 0);
const steps: FunnelStep[] = [
{
label: "Created",
value: funnel.created,
barClassName: "bg-primary",
hint: "Jobs started",
},
{
label: "Completed",
value: funnel.completed,
barClassName: "bg-success",
hint: "Successfully rendered",
},
{
label: "Published",
value: funnel.published,
barClassName: "bg-accent",
hint: "Uploaded to a platform",
},
];
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2 text-base">
<Filter className="size-4 text-muted-foreground" aria-hidden />
Funnel
</CardTitle>
</CardHeader>
<CardContent>
{top === 0 ? (
<p className="text-sm text-muted-foreground">
No jobs created in this window.
</p>
) : (
<ul className="space-y-4">
{steps.map((step) => {
const pct = top > 0 ? step.value / top : 0;
return (
<li key={step.label}>
<div className="mb-1 flex items-baseline justify-between gap-3">
<span className="text-sm font-medium">{step.label}</span>
<span className="tabular-nums text-sm text-muted-foreground">
{formatCount(step.value)}
<span className="ml-1.5 text-xs">{formatPct(pct)}</span>
</span>
</div>
<div
className="h-6 w-full overflow-hidden rounded-md bg-muted"
role="img"
aria-label={`${step.label}: ${formatCount(step.value)} (${formatPct(
pct,
)} of created)`}
>
<div
className={cn(
"flex h-full items-center rounded-md px-2 transition-all",
step.barClassName,
)}
style={{ width: `${Math.max(pct * 100, 3)}%` }}
/>
</div>
<p className="mt-1 text-xs text-muted-foreground">{step.hint}</p>
</li>
);
})}
</ul>
)}
{funnel.failed > 0 ? (
<p className="mt-4 text-xs text-muted-foreground">
<span className="font-medium text-destructive">
{formatCount(funnel.failed)}
</span>{" "}
job{funnel.failed === 1 ? "" : "s"} failed in this window.
</p>
) : null}
</CardContent>
</Card>
);
}