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.

feat: add shadcn/ui display components - table, tabs, switch, progress, skeleton, pagination

valzor0a31e6dfd55d
diff --git a/frontend/src/components/ui/pagination.jsx b/frontend/src/components/ui/pagination.jsx
new file mode 100644
index 0000000..1321da5
--- /dev/null
+++ b/frontend/src/components/ui/pagination.jsx
@@ -0,0 +1,122 @@
+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
+}) {
+ 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
+}) {
+ return (
+ <ul
+ data-slot="pagination-content"
+ className={cn("flex items-center gap-0.5", className)}
+ {...props} />
+ );
+}
+
+function PaginationItem({
+ ...props
+}) {
+ return <li data-slot="pagination-item" {...props} />;
+}
+
+function PaginationLink({
+ className,
+ isActive,
+ size = "icon",
+ ...props
+}) {
+ 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
+}) {
+ 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
+}) {
+ 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
+}) {
+ 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/progress.jsx b/frontend/src/components/ui/progress.jsx
new file mode 100644
index 0000000..d43495b
--- /dev/null
+++ b/frontend/src/components/ui/progress.jsx
@@ -0,0 +1,82 @@
+import { Progress as ProgressPrimitive } from "@base-ui/react/progress"
+
+import { cn } from "@/lib/utils"
+
+function Progress({
+ className,
+ children,
+ value,
+ ...props
+}) {
+ return (
+ <ProgressPrimitive.Root
+ value={value}
+ data-slot="progress"
+ className={cn("flex flex-wrap gap-3", className)}
+ {...props}>
+ {children}
+ <ProgressTrack>
+ <ProgressIndicator />
+ </ProgressTrack>
+ </ProgressPrimitive.Root>
+ );
+}
+
+function ProgressTrack({
+ className,
+ ...props
+}) {
+ return (
+ <ProgressPrimitive.Track
+ className={cn(
+ "relative flex h-1 w-full items-center overflow-x-hidden rounded-full bg-muted",
+ className
+ )}
+ data-slot="progress-track"
+ {...props} />
+ );
+}
+
+function ProgressIndicator({
+ className,
+ ...props
+}) {
+ return (
+ <ProgressPrimitive.Indicator
+ data-slot="progress-indicator"
+ className={cn("h-full bg-primary transition-all", className)}
+ {...props} />
+ );
+}
+
+function ProgressLabel({
+ className,
+ ...props
+}) {
+ return (
+ <ProgressPrimitive.Label
+ className={cn("text-sm font-medium", className)}
+ data-slot="progress-label"
+ {...props} />
+ );
+}
+
+function ProgressValue({
+ className,
+ ...props
+}) {
+ return (
+ <ProgressPrimitive.Value
+ className={cn("ml-auto text-sm text-muted-foreground tabular-nums", className)}
+ data-slot="progress-value"
+ {...props} />
+ );
+}
+
+export {
+ Progress,
+ ProgressTrack,
+ ProgressIndicator,
+ ProgressLabel,
+ ProgressValue,
+}
diff --git a/frontend/src/components/ui/scroll-area.jsx b/frontend/src/components/ui/scroll-area.jsx
new file mode 100644
index 0000000..24ec853
--- /dev/null
+++ b/frontend/src/components/ui/scroll-area.jsx
@@ -0,0 +1,46 @@
+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
+}) {
+ 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
+}) {
+ 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/separator.jsx b/frontend/src/components/ui/separator.jsx
new file mode 100644
index 0000000..45c56c2
--- /dev/null
+++ b/frontend/src/components/ui/separator.jsx
@@ -0,0 +1,22 @@
+import { Separator as SeparatorPrimitive } from "@base-ui/react/separator"
+
+import { cn } from "@/lib/utils"
+
+function Separator({
+ className,
+ orientation = "horizontal",
+ ...props
+}) {
+ return (
+ <SeparatorPrimitive
+ data-slot="separator"
+ orientation={orientation}
+ className={cn(
+ "shrink-0 bg-border data-horizontal:h-px data-horizontal:w-full data-vertical:w-px data-vertical:self-stretch",
+ className
+ )}
+ {...props} />
+ );
+}
+
+export { Separator }
diff --git a/frontend/src/components/ui/skeleton.jsx b/frontend/src/components/ui/skeleton.jsx
new file mode 100644
index 0000000..38345a7
--- /dev/null
+++ b/frontend/src/components/ui/skeleton.jsx
@@ -0,0 +1,15 @@
+import { cn } from "@/lib/utils"
+
+function Skeleton({
+ className,
+ ...props
+}) {
+ return (
+ <div
+ data-slot="skeleton"
+ className={cn("animate-pulse rounded-md bg-muted", className)}
+ {...props} />
+ );
+}
+
+export { Skeleton }
diff --git a/frontend/src/components/ui/switch.jsx b/frontend/src/components/ui/switch.jsx
new file mode 100644
index 0000000..8bf23bc
--- /dev/null
+++ b/frontend/src/components/ui/switch.jsx
@@ -0,0 +1,26 @@
+import { Switch as SwitchPrimitive } from "@base-ui/react/switch"
+
+import { cn } from "@/lib/utils"
+
+function Switch({
+ className,
+ size = "default",
+ ...props
+}) {
+ return (
+ <SwitchPrimitive.Root
+ data-slot="switch"
+ data-size={size}
+ className={cn(
+ "peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50",
+ className
+ )}
+ {...props}>
+ <SwitchPrimitive.Thumb
+ data-slot="switch-thumb"
+ className="pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground" />
+ </SwitchPrimitive.Root>
+ );
+}
+
+export { Switch }
diff --git a/frontend/src/components/ui/table.jsx b/frontend/src/components/ui/table.jsx
new file mode 100644
index 0000000..5128be4
--- /dev/null
+++ b/frontend/src/components/ui/table.jsx
@@ -0,0 +1,121 @@
+import * as React from "react"
+
+import { cn } from "@/lib/utils"
+
+function Table({
+ className,
+ ...props
+}) {
+ return (
+ <div data-slot="table-container" className="relative w-full overflow-x-auto">
+ <table
+ data-slot="table"
+ className={cn("w-full caption-bottom text-sm", className)}
+ {...props} />
+ </div>
+ );
+}
+
+function TableHeader({
+ className,
+ ...props
+}) {
+ return (
+ <thead
+ data-slot="table-header"
+ className={cn("[&_tr]:border-b", className)}
+ {...props} />
+ );
+}
+
+function TableBody({
+ className,
+ ...props
+}) {
+ return (
+ <tbody
+ data-slot="table-body"
+ className={cn("[&_tr:last-child]:border-0", className)}
+ {...props} />
+ );
+}
+
+function TableFooter({
+ className,
+ ...props
+}) {
+ return (
+ <tfoot
+ data-slot="table-footer"
+ className={cn("border-t bg-muted/50 font-medium [&>tr]:last:border-b-0", className)}
+ {...props} />
+ );
+}
+
+function TableRow({
+ className,
+ ...props
+}) {
+ return (
+ <tr
+ data-slot="table-row"
+ className={cn(
+ "border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted",
+ className
+ )}
+ {...props} />
+ );
+}
+
+function TableHead({
+ className,
+ ...props
+}) {
+ return (
+ <th
+ data-slot="table-head"
+ className={cn(
+ "h-10 px-2 text-left align-middle font-medium whitespace-nowrap text-foreground [&:has([role=checkbox])]:pr-0",
+ className
+ )}
+ {...props} />
+ );
+}
+
+function TableCell({
+ className,
+ ...props
+}) {
+ return (
+ <td
+ data-slot="table-cell"
+ className={cn(
+ "p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0",
+ className
+ )}
+ {...props} />
+ );
+}
+
+function TableCaption({
+ className,
+ ...props
+}) {
+ return (
+ <caption
+ data-slot="table-caption"
+ className={cn("mt-4 text-sm text-muted-foreground", className)}
+ {...props} />
+ );
+}
+
+export {
+ Table,
+ TableHeader,
+ TableBody,
+ TableFooter,
+ TableHead,
+ TableRow,
+ TableCell,
+ TableCaption,
+}
diff --git a/frontend/src/components/ui/tabs.jsx b/frontend/src/components/ui/tabs.jsx
new file mode 100644
index 0000000..266ddd8
--- /dev/null
+++ b/frontend/src/components/ui/tabs.jsx
@@ -0,0 +1,81 @@
+"use client"
+
+import { Tabs as TabsPrimitive } from "@base-ui/react/tabs"
+import { cva } from "class-variance-authority";
+
+import { cn } from "@/lib/utils"
+
+function Tabs({
+ className,
+ orientation = "horizontal",
+ ...props
+}) {
+ return (
+ <TabsPrimitive.Root
+ data-slot="tabs"
+ data-orientation={orientation}
+ className={cn("group/tabs flex gap-2 data-horizontal:flex-col", className)}
+ {...props} />
+ );
+}
+
+const tabsListVariants = cva(
+ "group/tabs-list inline-flex w-fit items-center justify-center rounded-lg p-[3px] text-muted-foreground group-data-horizontal/tabs:h-8 group-data-vertical/tabs:h-fit group-data-vertical/tabs:flex-col data-[variant=line]:rounded-none",
+ {
+ variants: {
+ variant: {
+ default: "bg-muted",
+ line: "gap-1 bg-transparent",
+ },
+ },
+ defaultVariants: {
+ variant: "default",
+ },
+ }
+)
+
+function TabsList({
+ className,
+ variant = "default",
+ ...props
+}) {
+ return (
+ <TabsPrimitive.List
+ data-slot="tabs-list"
+ data-variant={variant}
+ className={cn(tabsListVariants({ variant }), className)}
+ {...props} />
+ );
+}
+
+function TabsTrigger({
+ className,
+ ...props
+}) {
+ return (
+ <TabsPrimitive.Tab
+ data-slot="tabs-trigger"
+ className={cn(
+ "relative inline-flex h-[calc(100%-1px)] flex-1 items-center justify-center gap-1.5 rounded-md border border-transparent px-1.5 py-0.5 text-sm font-medium whitespace-nowrap text-foreground/60 transition-all group-data-vertical/tabs:w-full group-data-vertical/tabs:justify-start hover:text-foreground focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 focus-visible:outline-1 focus-visible:outline-ring disabled:pointer-events-none disabled:opacity-50 has-data-[icon=inline-end]:pr-1 has-data-[icon=inline-start]:pl-1 aria-disabled:pointer-events-none aria-disabled:opacity-50 dark:text-muted-foreground dark:hover:text-foreground group-data-[variant=default]/tabs-list:data-active:shadow-sm group-data-[variant=line]/tabs-list:data-active:shadow-none [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",
+ "group-data-[variant=line]/tabs-list:bg-transparent group-data-[variant=line]/tabs-list:data-active:bg-transparent dark:group-data-[variant=line]/tabs-list:data-active:border-transparent dark:group-data-[variant=line]/tabs-list:data-active:bg-transparent",
+ "data-active:bg-background data-active:text-foreground dark:data-active:border-input dark:data-active:bg-input/30 dark:data-active:text-foreground",
+ "after:absolute after:bg-foreground after:opacity-0 after:transition-opacity group-data-horizontal/tabs:after:inset-x-0 group-data-horizontal/tabs:after:bottom-[-5px] group-data-horizontal/tabs:after:h-0.5 group-data-vertical/tabs:after:inset-y-0 group-data-vertical/tabs:after:-right-1 group-data-vertical/tabs:after:w-0.5 group-data-[variant=line]/tabs-list:data-active:after:opacity-100",
+ className
+ )}
+ {...props} />
+ );
+}
+
+function TabsContent({
+ className,
+ ...props
+}) {
+ return (
+ <TabsPrimitive.Panel
+ data-slot="tabs-content"
+ className={cn("flex-1 text-sm outline-none", className)}
+ {...props} />
+ );
+}
+
+export { Tabs, TabsList, TabsTrigger, TabsContent, tabsListVariants }