Skip to content

Every analytics tool wants a subscription. And your data. I built Twiligent instead. YouTube stats. Instagram stats. One dashboard. Runs locally on your machine.

refactor(frontend): delete the shadcn components nothing imports

spacesdrivefd149cc638c5
diff --git a/docs/architecture/frontend/DESIGN_SYSTEM.md b/docs/architecture/frontend/DESIGN_SYSTEM.md
index 99050fb..e06c395 100644
--- a/docs/architecture/frontend/DESIGN_SYSTEM.md
+++ b/docs/architecture/frontend/DESIGN_SYSTEM.md
@@ -46,7 +46,7 @@ Shared components live in `frontend/src/components/`. Reach for these before wri
| `MediaCard`, `MediaChip` | Thumbnail cards for videos, Shorts and Instagram media |
| `ChartPanel` | The titled card around a chart, with an empty state and an optional `description`: the chart's takeaway in words, read by screen readers in place of the plot (`trendSummary`, `rankingSummary` and `pointsOf` in `lib/chart.ts` write it from the data) |
| `ChartFigure` | The figure inside `ChartPanel`, `MetricAreaChart` and `AudienceChart`: the chart's screen-reader name and its hidden description |
-| `AreaChart`, `BarChart`, `LineChart` (`components/ui`) | Intent UI's Recharts charts (ADR-048): pass `data`, the category `dataKey`, a `config` of series with labels and `SERIES` or `PLATFORM_META` colours, `containerHeight`, `valueFormatter={fmtNum}` for the axis, and `legend={false}` for a single series; the legend highlights one series when pressed |
+| `AreaChart`, `BarChart` (`components/ui`) | Intent UI's Recharts charts (ADR-048): pass `data`, the category `dataKey`, a `config` of series with labels and `SERIES` or `PLATFORM_META` colours, `containerHeight`, `valueFormatter={fmtNum}` for the axis, and `legend={false}` for a single series; the legend highlights one series when pressed |
| `ExactTooltip` | Intent's tooltip with every value in full (`tooltip={<ExactTooltip />}`); `format` for rates, `labelOf` when one series mixes kinds |
| `DonutChart` | Parts of a whole as a ring inside Intent's chart frame, with the exact tooltip and a legend |
| `MetricAreaChart` | A single-series Intent area chart with its own screen-reader name and description |
diff --git a/docs/architecture/frontend/FEATURES.md b/docs/architecture/frontend/FEATURES.md
index 636f983..de6c889 100644
--- a/docs/architecture/frontend/FEATURES.md
+++ b/docs/architecture/frontend/FEATURES.md
@@ -127,7 +127,7 @@ The computed indices `viralityScore` and `consistencyScore` (YouTube and Instagr
## Shared Chart Components
-Charts are drawn with Intent UI's components in `components/ui` (`AreaChart`, `BarChart`, `LineChart`; ADR-048)
+Charts are drawn with Intent UI's components in `components/ui` (`AreaChart`, `BarChart`; ADR-048)
inside the shared pieces below. Each chart is a figure with a screen-reader name and a hidden description of its
data; nothing extra is shown on screen.
diff --git a/docs/guidelines/SHADCN.md b/docs/guidelines/SHADCN.md
index 7361d9a..bf093ea 100644
--- a/docs/guidelines/SHADCN.md
+++ b/docs/guidelines/SHADCN.md
@@ -21,7 +21,7 @@ Always import from the local `@/components/ui/` path:
```tsx
import { Button } from '@/components/ui/button';
-import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
+import { Tooltip, TooltipContent, TooltipTrigger } from '@/components/ui/tooltip';
import { Badge } from '@/components/ui/badge';
```
@@ -43,27 +43,22 @@ This copies the component source into `frontend/src/components/ui/` as a `.tsx`
shadcn components are composed using their named export variants. Read the component file in `frontend/src/components/ui/` to understand the available props before using them.
```tsx
-// Card composition
-<Card>
- <CardHeader>
- <CardTitle>Title</CardTitle>
- <CardDescription>Subtitle</CardDescription>
- </CardHeader>
- <CardContent>
- {/* content */}
- </CardContent>
- <CardFooter>
- {/* actions */}
- </CardFooter>
-</Card>
+// Tooltip composition: the trigger renders the button, the content is the label
+<Tooltip>
+ <TooltipTrigger render={<Button variant="ghost" size="icon-xs" aria-label="Refresh" />}>
+ <RefreshCw />
+ </TooltipTrigger>
+ <TooltipContent>Refresh</TooltipContent>
+</Tooltip>
```
+Only the components the app uses are kept in `components/ui/`. Add one with the CLI when a feature needs it, and delete it when the last use goes. Grouped content uses `SurfaceBox` and labelled fields use `FieldRow` (`DESIGN_SYSTEM.md`), not `Card` or `Label`.
+
## Common Components in Use
| Component | Import | Use case |
|---|---|---|
| `Button` | `@/components/ui/button` | All action buttons; use `variant` prop: `default`, `outline`, `ghost`, `destructive` |
-| `Card`, `CardHeader`, `CardContent`, `CardFooter` | `@/components/ui/card` | Content containers |
| `Badge` | `@/components/ui/badge` | Status labels, platform tags |
| `Avatar` | `@/components/ui/avatar` | Channel/account avatars |
| `Table`, `TableHeader`, etc. | `@/components/ui/table` | Data tables |
@@ -74,7 +69,6 @@ shadcn components are composed using their named export variants. Read the compo
| `Skeleton` | `@/components/ui/skeleton` | Loading placeholders |
| `Alert`, `AlertTitle`, `AlertDescription` | `@/components/ui/alert` | Info/warning/error banners |
| `Input` | `@/components/ui/input` | Text inputs |
-| `Label` | `@/components/ui/label` | Form labels |
## `cn()` Utility
diff --git a/frontend/src/components/ui/breadcrumb.tsx b/frontend/src/components/ui/breadcrumb.tsx
deleted file mode 100644
index 3aa28cc..0000000
--- a/frontend/src/components/ui/breadcrumb.tsx
+++ /dev/null
@@ -1,124 +0,0 @@
-import * as React from "react"
-import { mergeProps } from "@base-ui/react/merge-props"
-import { useRender } from "@base-ui/react/use-render"
-
-import { cn } from "@/lib/utils"
-import { ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
-
-function Breadcrumb({
- className,
- ...props
-}: React.ComponentProps<"nav">) {
- return (
- <nav
- aria-label="breadcrumb"
- data-slot="breadcrumb"
- className={cn(className)}
- {...props} />
- );
-}
-
-function BreadcrumbList({
- className,
- ...props
-}: React.ComponentProps<"ol">) {
- return (
- <ol
- data-slot="breadcrumb-list"
- className={cn(
- "flex flex-wrap items-center gap-1.5 text-sm wrap-break-word text-muted-foreground",
- className
- )}
- {...props} />
- );
-}
-
-function BreadcrumbItem({
- className,
- ...props
-}: React.ComponentProps<"li">) {
- return (
- <li
- data-slot="breadcrumb-item"
- className={cn("inline-flex items-center gap-1", className)}
- {...props} />
- );
-}
-
-function BreadcrumbLink({
- className,
- render,
- ...props
-}: useRender.ComponentProps<"a">) {
- return useRender({
- defaultTagName: "a",
- props: mergeProps({
- className: cn("transition-colors hover:text-foreground", className),
- }, props),
- render,
- state: {
- slot: "breadcrumb-link",
- },
- });
-}
-
-function BreadcrumbPage({
- className,
- ...props
-}: React.ComponentProps<"span">) {
- return (
- <span
- data-slot="breadcrumb-page"
- role="link"
- aria-disabled="true"
- aria-current="page"
- className={cn("font-normal text-foreground", className)}
- {...props} />
- );
-}
-
-function BreadcrumbSeparator({
- children,
- className,
- ...props
-}: React.ComponentProps<"li">) {
- return (
- <li
- data-slot="breadcrumb-separator"
- role="presentation"
- aria-hidden="true"
- className={cn("[&>svg]:size-3.5", className)}
- {...props}>
- {children ?? (
- <ChevronRightIcon />
- )}
- </li>
- );
-}
-
-function BreadcrumbEllipsis({
- className,
- ...props
-}: React.ComponentProps<"span">) {
- return (
- <span
- data-slot="breadcrumb-ellipsis"
- role="presentation"
- aria-hidden="true"
- className={cn("flex size-5 items-center justify-center [&>svg]:size-4", className)}
- {...props}>
- <MoreHorizontalIcon />
- <span className="sr-only">More</span>
- </span>
- );
-}
-
-export {
- Breadcrumb,
- BreadcrumbList,
- BreadcrumbItem,
- BreadcrumbLink,
- BreadcrumbPage,
- BreadcrumbSeparator,
- BreadcrumbEllipsis,
-}
diff --git a/frontend/src/components/ui/card.tsx b/frontend/src/components/ui/card.tsx
deleted file mode 100644
index b1a8955..0000000
--- a/frontend/src/components/ui/card.tsx
+++ /dev/null
@@ -1,114 +0,0 @@
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-
-function Card({
- className,
- size = "default",
- ...props
-}: React.ComponentProps<"div"> & { size?: "default" | "sm" }) {
- return (
- <div
- data-slot="card"
- data-size={size}
- className={cn(
- "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-card border border-line bg-card py-(--card-spacing) text-sm text-card-foreground [--card-spacing:--spacing(5)] has-data-[slot=card-footer]:pb-0 has-[>img:first-child]:pt-0 data-[size=sm]:[--card-spacing:--spacing(3)] data-[size=sm]:has-data-[slot=card-footer]:pb-0 *:[img:first-child]:rounded-t-card *:[img:last-child]:rounded-b-card",
- className
- )}
- {...props} />
- );
-}
-
-function CardHeader({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-header"
- className={cn(
- "group/card-header @container/card-header grid auto-rows-min items-start gap-1 rounded-t-xl px-(--card-spacing) has-data-[slot=card-action]:grid-cols-[1fr_auto] has-data-[slot=card-description]:grid-rows-[auto_auto] [.border-b]:pb-(--card-spacing)",
- className
- )}
- {...props} />
- );
-}
-
-function CardTitle({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-title"
- className={cn(
- "font-heading text-section font-semibold group-data-[size=sm]/card:text-sm",
- className
- )}
- {...props} />
- );
-}
-
-function CardDescription({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-description"
- className={cn("text-sm text-muted-foreground", className)}
- {...props} />
- );
-}
-
-function CardAction({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-action"
- className={cn(
- "col-start-2 row-span-2 row-start-1 self-start justify-self-end",
- className
- )}
- {...props} />
- );
-}
-
-function CardContent({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-content"
- className={cn("px-(--card-spacing)", className)}
- {...props} />
- );
-}
-
-function CardFooter({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="card-footer"
- className={cn(
- "flex items-center rounded-b-card border-t border-line bg-surface-sunken/60 p-(--card-spacing)",
- className
- )}
- {...props} />
- );
-}
-
-export {
- Card,
- CardHeader,
- CardFooter,
- CardTitle,
- CardAction,
- CardDescription,
- CardContent,
-}
diff --git a/frontend/src/components/ui/collapsible.tsx b/frontend/src/components/ui/collapsible.tsx
deleted file mode 100644
index e5797c8..0000000
--- a/frontend/src/components/ui/collapsible.tsx
+++ /dev/null
@@ -1,21 +0,0 @@
-import { Collapsible as CollapsiblePrimitive } from "@base-ui/react/collapsible"
-
-function Collapsible({
- ...props
-}: CollapsiblePrimitive.Root.Props) {
- return <CollapsiblePrimitive.Root data-slot="collapsible" {...props} />;
-}
-
-function CollapsibleTrigger({
- ...props
-}: CollapsiblePrimitive.Trigger.Props) {
- return (<CollapsiblePrimitive.Trigger data-slot="collapsible-trigger" {...props} />);
-}
-
-function CollapsibleContent({
- ...props
-}: CollapsiblePrimitive.Panel.Props) {
- return (<CollapsiblePrimitive.Panel data-slot="collapsible-content" {...props} />);
-}
-
-export { Collapsible, CollapsibleTrigger, CollapsibleContent }
diff --git a/frontend/src/components/ui/empty.tsx b/frontend/src/components/ui/empty.tsx
deleted file mode 100644
index ab3f586..0000000
--- a/frontend/src/components/ui/empty.tsx
+++ /dev/null
@@ -1,111 +0,0 @@
-import type * as React from "react"
-import { cva, type VariantProps } from "class-variance-authority";
-
-import { cn } from "@/lib/utils"
-
-function Empty({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="empty"
- className={cn(
- "flex w-full min-w-0 flex-1 flex-col items-center justify-center gap-4 rounded-xl border-dashed p-6 text-center text-balance",
- className
- )}
- {...props} />
- );
-}
-
-function EmptyHeader({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="empty-header"
- className={cn("flex max-w-sm flex-col items-center gap-2", className)}
- {...props} />
- );
-}
-
-const emptyMediaVariants = cva(
- "mb-2 flex shrink-0 items-center justify-center [&_svg]:pointer-events-none [&_svg]:shrink-0",
- {
- variants: {
- variant: {
- default: "bg-transparent",
- icon: "flex size-8 shrink-0 items-center justify-center rounded-lg bg-muted text-foreground [&_svg:not([class*='size-'])]:size-4",
- },
- },
- defaultVariants: {
- variant: "default",
- },
- }
-)
-
-function EmptyMedia({
- className,
- variant = "default",
- ...props
-}: React.ComponentProps<"div"> & VariantProps<typeof emptyMediaVariants>) {
- return (
- <div
- data-slot="empty-icon"
- data-variant={variant}
- className={cn(emptyMediaVariants({ variant, className }))}
- {...props} />
- );
-}
-
-function EmptyTitle({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="empty-title"
- className={cn("font-heading text-sm font-medium tracking-tight", className)}
- {...props} />
- );
-}
-
-function EmptyDescription({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="empty-description"
- className={cn(
- "text-sm/relaxed text-muted-foreground [&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
- className
- )}
- {...props} />
- );
-}
-
-function EmptyContent({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="empty-content"
- className={cn(
- "flex w-full max-w-sm min-w-0 flex-col items-center gap-2.5 text-sm text-balance",
- className
- )}
- {...props} />
- );
-}
-
-export {
- Empty,
- EmptyHeader,
- EmptyTitle,
- EmptyDescription,
- EmptyContent,
- EmptyMedia,
-}
diff --git a/frontend/src/components/ui/field.tsx b/frontend/src/components/ui/field.tsx
deleted file mode 100644
index 0984732..0000000
--- a/frontend/src/components/ui/field.tsx
+++ /dev/null
@@ -1,233 +0,0 @@
-import type * as React from "react"
-import { useMemo } from "react"
-import { cva, type VariantProps } from "class-variance-authority";
-
-import { cn } from "@/lib/utils"
-import { Label } from "@/components/ui/label"
-import { Separator } from "@/components/ui/separator"
-
-function FieldSet({
- className,
- ...props
-}: React.ComponentProps<"fieldset">) {
- return (
- <fieldset
- data-slot="field-set"
- className={cn(
- "flex flex-col gap-4 has-[>[data-slot=checkbox-group]]:gap-3 has-[>[data-slot=radio-group]]:gap-3",
- className
- )}
- {...props} />
- );
-}
-
-function FieldLegend({
- className,
- variant = "legend",
- ...props
-}: React.ComponentProps<"legend"> & { variant?: "legend" | "label" }) {
- return (
- <legend
- data-slot="field-legend"
- data-variant={variant}
- className={cn(
- "mb-1.5 font-medium data-[variant=label]:text-sm data-[variant=legend]:text-base",
- className
- )}
- {...props} />
- );
-}
-
-function FieldGroup({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="field-group"
- className={cn(
- "group/field-group @container/field-group flex w-full flex-col gap-5 data-[slot=checkbox-group]:gap-3 *:data-[slot=field-group]:gap-4",
- className
- )}
- {...props} />
- );
-}
-
-const fieldVariants = cva("group/field flex w-full gap-2 data-[invalid=true]:text-destructive", {
- variants: {
- orientation: {
- vertical: "flex-col *:w-full [&>.sr-only]:w-auto",
- horizontal:
- "flex-row items-center has-[>[data-slot=field-content]]:items-start *:data-[slot=field-label]:flex-auto has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
- responsive:
- "flex-col *:w-full @md/field-group:flex-row @md/field-group:items-center @md/field-group:*:w-auto @md/field-group:has-[>[data-slot=field-content]]:items-start @md/field-group:*:data-[slot=field-label]:flex-auto [&>.sr-only]:w-auto @md/field-group:has-[>[data-slot=field-content]]:[&>[role=checkbox],[role=radio]]:mt-px",
- },
- },
- defaultVariants: {
- orientation: "vertical",
- },
-})
-
-function Field({
- className,
- orientation = "vertical",
- ...props
-}: React.ComponentProps<"div"> & VariantProps<typeof fieldVariants>) {
- return (
- <div
- role="group"
- data-slot="field"
- data-orientation={orientation}
- className={cn(fieldVariants({ orientation }), className)}
- {...props} />
- );
-}
-
-function FieldContent({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="field-content"
- className={cn("group/field-content flex flex-1 flex-col gap-0.5 leading-snug", className)}
- {...props} />
- );
-}
-
-function FieldLabel({
- className,
- ...props
-}: React.ComponentProps<typeof Label>) {
- return (
- <Label
- data-slot="field-label"
- className={cn(
- "group/field-label peer/field-label flex w-fit gap-2 leading-snug group-data-[disabled=true]/field:opacity-50 has-data-checked:border-primary/30 has-data-checked:bg-primary/5 has-[>[data-slot=field]]:rounded-lg has-[>[data-slot=field]]:border *:data-[slot=field]:p-2.5 dark:has-data-checked:border-primary/20 dark:has-data-checked:bg-primary/10",
- "has-[>[data-slot=field]]:w-full has-[>[data-slot=field]]:flex-col",
- className
- )}
- {...props} />
- );
-}
-
-function FieldTitle({
- className,
- ...props
-}: React.ComponentProps<"div">) {
- return (
- <div
- data-slot="field-label"
- className={cn(
- "flex w-fit items-center gap-2 text-sm font-medium group-data-[disabled=true]/field:opacity-50",
- className
- )}
- {...props} />
- );
-}
-
-function FieldDescription({
- className,
- ...props
-}: React.ComponentProps<"p">) {
- return (
- <p
- data-slot="field-description"
- className={cn(
- "text-left text-sm leading-normal font-normal text-muted-foreground group-has-data-horizontal/field:text-balance [[data-variant=legend]+&]:-mt-1.5",
- "last:mt-0 nth-last-2:-mt-1",
- "[&>a]:underline [&>a]:underline-offset-4 [&>a:hover]:text-primary",
- className
- )}
- {...props} />
- );
-}
-
-function FieldSeparator({
- children,
- className,
- ...props
-}: React.ComponentProps<"div"> & {
- children?: React.ReactNode
-}) {
- return (
- <div
- data-slot="field-separator"
- data-content={!!children}
- className={cn(
- "relative -my-2 h-5 text-sm group-data-[variant=outline]/field-group:-mb-2",
- className
- )}
- {...props}>
- <Separator className="absolute inset-0 top-1/2" />
- {children && (
- <span
- className="relative mx-auto block w-fit bg-background px-2 text-muted-foreground"
- data-slot="field-separator-content">
- {children}
- </span>
- )}
- </div>
- );
-}
-
-function FieldError({
- className,
- children,
- errors,
- ...props
-}: React.ComponentProps<"div"> & {
- errors?: Array<{ message?: string } | undefined>
-}) {
- const content = useMemo(() => {
- if (children) {
- return children
- }
-
- if (!errors?.length) {
- return null
- }
-
- const uniqueErrors = [
- ...new Map(errors.map((error) => [error?.message, error])).values(),
- ]
-
- if (uniqueErrors?.length == 1) {
- return uniqueErrors[0]?.message
- }
-
- return (
- <ul className="ml-4 flex list-disc flex-col gap-1">
- {uniqueErrors.map((error, index) =>
- error?.message && <li key={index}>{error.message}</li>)}
- </ul>
- );
- }, [children, errors])
-
- if (!content) {
- return null
- }
-
- return (
- <div
- role="alert"
- data-slot="field-error"
- className={cn("text-sm font-normal text-destructive", className)}
- {...props}>
- {content}
- </div>
- );
-}
-
-export {
- Field,
- FieldLabel,
- FieldDescription,
- FieldError,
- FieldGroup,
- FieldLegend,
- FieldSeparator,
- FieldSet,
- FieldContent,
- FieldTitle,
-}
diff --git a/frontend/src/components/ui/label.tsx b/frontend/src/components/ui/label.tsx
deleted file mode 100644
index 38c49f8..0000000
--- a/frontend/src/components/ui/label.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-"use client"
-
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-
-function Label({
- className,
- ...props
-}: React.ComponentProps<"label">) {
- return (
- <label
- data-slot="label"
- className={cn(
- "flex items-center gap-2 text-sm leading-none font-medium select-none group-data-[disabled=true]:pointer-events-none group-data-[disabled=true]:opacity-50 peer-disabled:cursor-not-allowed peer-disabled:opacity-50",
- className
- )}
- {...props} />
- );
-}
-
-export { Label }
diff --git a/frontend/src/components/ui/line-chart.tsx b/frontend/src/components/ui/line-chart.tsx
deleted file mode 100644
index e61ea92..0000000
--- a/frontend/src/components/ui/line-chart.tsx
+++ /dev/null
@@ -1,148 +0,0 @@
-"use client"
-// Intent UI (https://intentui.com, MIT), vendored; see THIRD_PARTY_NOTICES.md
-
-import { useMemo } from "react"
-import { Line, LineChart as LineChartPrimitive, type LineProps } from "recharts"
-import {
- type BaseChartProps,
- CartesianGrid,
- Chart,
- ChartLegend,
- ChartLegendContent,
- ChartTooltip,
- ChartTooltipContent,
- constructCategoryColors,
- DEFAULT_COLORS,
- getColorValue,
- valueToPercent,
- XAxis,
- YAxis,
-} from "./chart"
-
-export interface LineChartProps extends BaseChartProps {
- connectNulls?: boolean
- lineProps?: LineProps
- chartProps?: Omit<React.ComponentProps<typeof LineChartPrimitive>, "data" | "stackOffset">
-}
-
-export function LineChart({
- data = [],
- dataKey,
- colors = DEFAULT_COLORS,
- connectNulls = false,
- type = "default",
- config,
- children,
-
- // Components
- tooltip = true,
- tooltipProps,
-
- legend = true,
- legendProps,
-
- intervalType = "equidistantPreserveStart",
-
- valueFormatter = (value: number) => value.toString(),
-
- // XAxis
- displayEdgeLabelsOnly = false,
- xAxisProps,
- hideXAxis = false,
-
- // YAxis
- yAxisProps,
- hideYAxis = false,
-
- hideGridLines = false,
- chartProps,
- lineProps,
- ...props
-}: LineChartProps) {
- const configKeys = useMemo(() => Object.keys(config), [config])
- const categoryColors = useMemo(
- () => constructCategoryColors(configKeys, colors),
- [configKeys, colors]
- )
-
- const configEntries = useMemo(() => Object.entries(config), [config])
-
- return (
- <Chart config={config} data={data} dataKey={dataKey} {...props}>
- {({ onLegendSelect, selectedLegend }) => (
- <LineChartPrimitive
- onClick={() => {
- onLegendSelect(null)
- }}
- data={data}
- margin={{
- bottom: 0,
- left: 0,
- right: 0,
- top: 5,
- }}
- stackOffset={type === "percent" ? "expand" : undefined}
- {...chartProps}
- >
- {!hideGridLines && <CartesianGrid strokeDasharray="4 4" />}
- <XAxis
- hide={hideXAxis}
- displayEdgeLabelsOnly={displayEdgeLabelsOnly}
- intervalType={intervalType}
- {...xAxisProps}
- />
- <YAxis
- hide={hideYAxis}
- tickFormatter={type === "percent" ? valueToPercent : valueFormatter}
- {...yAxisProps}
- />
-
- {legend && (
- <ChartLegend
- content={typeof legend === "boolean" ? <ChartLegendContent /> : legend}
- {...legendProps}
- />
- )}
-
- {tooltip && (
- <ChartTooltip
- content={
- typeof tooltip === "boolean" ? <ChartTooltipContent accessibilityLayer /> : tooltip
- }
- {...tooltipProps}
- />
- )}
-
- {!children
- ? configEntries.map(([category, values]) => {
- const strokeOpacity = selectedLegend && selectedLegend !== category ? 0.1 : 1
- const color = getColorValue(values.color || categoryColors.get(category))
-
- return (
- <Line
- key={category}
- dot={false}
- name={category}
- type="linear"
- dataKey={category}
- stroke={color}
- style={
- {
- strokeOpacity,
- strokeWidth: 2,
- "--line-color": color,
- } as React.CSSProperties
- }
- strokeLinejoin="round"
- strokeLinecap="round"
- connectNulls={connectNulls}
- {...lineProps}
- />
- )
- })
- : children}
- </LineChartPrimitive>
- )}
- </Chart>
- )
-}
diff --git a/frontend/src/components/ui/pagination.tsx b/frontend/src/components/ui/pagination.tsx
deleted file mode 100644
index dd04a29..0000000
--- a/frontend/src/components/ui/pagination.tsx
+++ /dev/null
@@ -1,127 +0,0 @@
-import * as React from "react"
-
-import { cn } from "@/lib/utils"
-import { Button } from "@/components/ui/button"
-import { ChevronLeftIcon, ChevronRightIcon, MoreHorizontalIcon } from "lucide-react"
-
-function Pagination({
- className,
- ...props
-}: React.ComponentProps<"nav">) {
- return (
- <nav
- role="navigation"
- aria-label="pagination"
- data-slot="pagination"
- className={cn("mx-auto flex w-full justify-center", className)}
- {...props} />
- );
-}
-
-function PaginationContent({
- className,
- ...props
-}: React.ComponentProps<"ul">) {
- return (
- <ul
- data-slot="pagination-content"
- className={cn("flex items-center gap-0.5", className)}
- {...props} />
- );
-}
-
-function PaginationItem({
- ...props
-}: React.ComponentProps<"li">) {
- return <li data-slot="pagination-item" {...props} />;
-}
-
-type PaginationLinkProps = {
- isActive?: boolean
-} & Pick<React.ComponentProps<typeof Button>, "size"> &
- React.ComponentProps<"a">
-
-function PaginationLink({
- className,
- isActive,
- size = "icon",
- ...props
-}: PaginationLinkProps) {
- return (
- <Button
- variant={isActive ? "outline" : "ghost"}
- size={size}
- className={cn(className)}
- nativeButton={false}
- render={
- <a
- aria-current={isActive ? "page" : undefined}
- data-slot="pagination-link"
- data-active={isActive}
- {...props} />
- } />
- );
-}
-
-function PaginationPrevious({
- className,
- text = "Previous",
- ...props
-}: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
- return (
- <PaginationLink
- aria-label="Go to previous page"
- size="default"
- className={cn("pl-1.5!", className)}
- {...props}>
- <ChevronLeftIcon data-icon="inline-start" />
- <span className="hidden sm:block">{text}</span>
- </PaginationLink>
- );
-}
-
-function PaginationNext({
- className,
- text = "Next",
- ...props
-}: React.ComponentProps<typeof PaginationLink> & { text?: string }) {
- return (
- <PaginationLink
- aria-label="Go to next page"
- size="default"
- className={cn("pr-1.5!", className)}
- {...props}>
- <span className="hidden sm:block">{text}</span>
- <ChevronRightIcon data-icon="inline-end" />
- </PaginationLink>
- );
-}
-
-function PaginationEllipsis({
- className,
- ...props
-}: React.ComponentProps<"span">) {
- return (
- <span
- aria-hidden
- data-slot="pagination-ellipsis"
- className={cn(
- "flex size-8 items-center justify-center [&_svg:not([class*='size-'])]:size-4",
- className
- )}
- {...props}>
- <MoreHorizontalIcon />
- <span className="sr-only">More pages</span>
- </span>
- );
-}
-
-export {
- Pagination,
- PaginationContent,
- PaginationEllipsis,
- PaginationItem,
- PaginationLink,
- PaginationNext,
- PaginationPrevious,
-}
diff --git a/frontend/src/components/ui/scroll-area.tsx b/frontend/src/components/ui/scroll-area.tsx
deleted file mode 100644
index 3b5044e..0000000
--- a/frontend/src/components/ui/scroll-area.tsx
+++ /dev/null
@@ -1,46 +0,0 @@
-import * as React from "react"
-import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"
-
-import { cn } from "@/lib/utils"
-
-function ScrollArea({
- className,
- children,
- ...props
-}: ScrollAreaPrimitive.Root.Props) {
- return (
- <ScrollAreaPrimitive.Root data-slot="scroll-area" className={cn("relative", className)} {...props}>
- <ScrollAreaPrimitive.Viewport
- data-slot="scroll-area-viewport"
- className="size-full rounded-[inherit] transition-[color,box-shadow] outline-none focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1">
- {children}
- </ScrollAreaPrimitive.Viewport>
- <ScrollBar />
- <ScrollAreaPrimitive.Corner />
- </ScrollAreaPrimitive.Root>
- );
-}
-
-function ScrollBar({
- className,
- orientation = "vertical",
- ...props
-}: ScrollAreaPrimitive.Scrollbar.Props) {
- return (
- <ScrollAreaPrimitive.Scrollbar
- data-slot="scroll-area-scrollbar"
- data-orientation={orientation}
- orientation={orientation}
- className={cn(
- "flex touch-none p-px transition-colors select-none data-horizontal:h-2.5 data-horizontal:flex-col data-horizontal:border-t data-horizontal:border-t-transparent data-vertical:h-full data-vertical:w-2.5 data-vertical:border-l data-vertical:border-l-transparent",
- className
- )}
- {...props}>
- <ScrollAreaPrimitive.Thumb
- data-slot="scroll-area-thumb"
- className="relative flex-1 rounded-full bg-border" />
- </ScrollAreaPrimitive.Scrollbar>
- );
-}
-
-export { ScrollArea, ScrollBar }
diff --git a/frontend/src/components/ui/toggle-group.tsx b/frontend/src/components/ui/toggle-group.tsx
deleted file mode 100644
index 714cf1a..0000000
--- a/frontend/src/components/ui/toggle-group.tsx
+++ /dev/null
@@ -1,85 +0,0 @@
-import * as React from "react"
-import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
-import { ToggleGroup as ToggleGroupPrimitive } from "@base-ui/react/toggle-group"
-
-import { cn } from "@/lib/utils"
-import { toggleVariants } from "@/components/ui/toggle"
-import type { VariantProps } from "class-variance-authority"
-
-interface ToggleGroupContextValue extends VariantProps<typeof toggleVariants> {
- spacing?: number
- orientation?: "horizontal" | "vertical"
-}
-
-const ToggleGroupContext = React.createContext<ToggleGroupContextValue>({
- size: "default",
- variant: "default",
- spacing: 2,
- orientation: "horizontal",
-})
-
-function ToggleGroup({
- className,
- variant,
- size,
- spacing = 2,
- orientation = "horizontal",
- children,
- ...props
-}: ToggleGroupPrimitive.Props &
- VariantProps<typeof toggleVariants> & {
- spacing?: number
- orientation?: "horizontal" | "vertical"
- }) {
- return (
- <ToggleGroupPrimitive
- data-slot="toggle-group"
- data-variant={variant}
- data-size={size}
- data-spacing={spacing}
- data-orientation={orientation}
- style={{
- "--gap": spacing
- } as React.CSSProperties}
- className={cn(
- "group/toggle-group flex w-fit flex-row items-center gap-[--spacing(var(--gap))] rounded-lg data-[size=sm]:rounded-[min(var(--radius-md),10px)] data-vertical:flex-col data-vertical:items-stretch",
- className
- )}
- {...props}>
- <ToggleGroupContext.Provider value={{ variant, size, spacing, orientation }}>
- {children}
- </ToggleGroupContext.Provider>
- </ToggleGroupPrimitive>
- );
-}
-
-function ToggleGroupItem({
- className,
- children,
- variant = "default",
- size = "default",
- ...props
-}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
- const context = React.useContext(ToggleGroupContext)
-
- return (
- <TogglePrimitive
- data-slot="toggle-group-item"
- data-variant={context.variant || variant}
- data-size={context.size || size}
- data-spacing={context.spacing}
- className={cn(
- "shrink-0 group-data-[spacing=0]/toggle-group:rounded-none group-data-[spacing=0]/toggle-group:px-2 focus:z-10 focus-visible:z-10 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-end]:pr-1.5 group-data-[spacing=0]/toggle-group:has-data-[icon=inline-start]:pl-1.5 group-data-horizontal/toggle-group:data-[spacing=0]:first:rounded-l-lg group-data-vertical/toggle-group:data-[spacing=0]:first:rounded-t-lg group-data-horizontal/toggle-group:data-[spacing=0]:last:rounded-r-lg group-data-vertical/toggle-group:data-[spacing=0]:last:rounded-b-lg group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:border-l-0 group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:border-t-0 group-data-horizontal/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-l group-data-vertical/toggle-group:data-[spacing=0]:data-[variant=outline]:first:border-t",
- toggleVariants({
- variant: context.variant || variant,
- size: context.size || size,
- }),
- className
- )}
- {...props}>
- {children}
- </TogglePrimitive>
- );
-}
-
-export { ToggleGroup, ToggleGroupItem }
diff --git a/frontend/src/components/ui/toggle.tsx b/frontend/src/components/ui/toggle.tsx
deleted file mode 100644
index eadcddd..0000000
--- a/frontend/src/components/ui/toggle.tsx
+++ /dev/null
@@ -1,44 +0,0 @@
-"use client"
-
-import { Toggle as TogglePrimitive } from "@base-ui/react/toggle"
-import { cva, type VariantProps } from "class-variance-authority";
-
-import { cn } from "@/lib/utils"
-
-const toggleVariants = cva(
- "group/toggle inline-flex items-center justify-center gap-1 rounded-lg text-sm font-medium whitespace-nowrap transition-all outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-destructive/20 aria-pressed:bg-muted data-[state=on]:bg-muted dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
- {
- variants: {
- variant: {
- default: "bg-transparent",
- outline: "border border-input bg-transparent hover:bg-muted",
- },
- size: {
- default:
- "h-8 min-w-8 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
- sm: "h-7 min-w-7 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3.5",
- lg: "h-9 min-w-9 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",
- },
- },
- defaultVariants: {
- variant: "default",
- size: "default",
- },
- }
-)
-
-function Toggle({
- className,
- variant = "default",
- size = "default",
- ...props
-}: TogglePrimitive.Props & VariantProps<typeof toggleVariants>) {
- return (
- <TogglePrimitive
- data-slot="toggle"
- className={cn(toggleVariants({ variant, size, className }))}
- {...props} />
- );
-}
-
-export { Toggle, toggleVariants }