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

79 lines
2.2 KiB
TypeScript

/**
* A usage breakdown as a labelled bar list: each row shows a key (layout /
* language / variant count / hook), its job count, and a horizontal bar sized
* relative to the largest row. Rows are sorted descending by count.
*/
import { StyleSheet, Text, View } from "react-native";
import { colors } from "@/components/me/theme";
import type { AnalyticsBreakdownItem } from "@/lib/types";
import { Bar } from "./Bar";
import { formatCount, toPercent } from "./format";
interface BreakdownListProps {
items: AnalyticsBreakdownItem[];
/** Bar colour (defaults to accent). */
color?: string;
/** Cap the number of rows shown (top-N by count). */
limit?: number;
emptyLabel?: string;
}
export function BreakdownList({
items,
color,
limit,
emptyLabel = "No data in this window yet.",
}: BreakdownListProps) {
const sorted = [...items].sort((a, b) => b.count - a.count);
const rows = typeof limit === "number" ? sorted.slice(0, limit) : sorted;
const max = rows.reduce((acc, r) => Math.max(acc, r.count), 0);
if (rows.length === 0) {
return (
<View style={styles.card}>
<Text style={styles.empty}>{emptyLabel}</Text>
</View>
);
}
return (
<View style={styles.card}>
{rows.map((row, index) => (
<View key={`${row.key}-${index}`} style={styles.row}>
<View style={styles.rowHeader}>
<Text style={styles.rowLabel} numberOfLines={1}>
{row.label ?? row.key}
</Text>
<Text style={styles.rowCount}>{formatCount(row.count)}</Text>
</View>
<Bar percent={toPercent(row.count, max)} color={color} height={8} />
</View>
))}
</View>
);
}
const styles = StyleSheet.create({
card: {
backgroundColor: colors.card,
borderColor: colors.border,
borderWidth: 1,
borderRadius: 12,
padding: 14,
gap: 14,
},
row: { gap: 6 },
rowHeader: {
flexDirection: "row",
justifyContent: "space-between",
alignItems: "center",
gap: 12,
},
rowLabel: { color: colors.textSecondary, fontSize: 14, flex: 1 },
rowCount: { color: colors.textPrimary, fontSize: 14, fontWeight: "700" },
empty: { color: colors.muted, fontSize: 13, paddingVertical: 6 },
});