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 base components - button, input, select, badge, card, avatar, alert
valzor8b356f41b4be
diff --git a/frontend/src/components/ui/alert.jsx b/frontend/src/components/ui/alert.jsxnew file mode 100644index 0000000..bc53c0c--- /dev/null+++ b/frontend/src/components/ui/alert.jsx@@ -0,0 +1,78 @@+import * as React from "react"+import { cva } from "class-variance-authority";++import { cn } from "@/lib/utils"++const alertVariants = cva(+ "group/alert relative grid w-full gap-0.5 rounded-lg border px-2.5 py-2 text-left text-sm has-data-[slot=alert-action]:relative has-data-[slot=alert-action]:pr-18 has-[>svg]:grid-cols-[auto_1fr] has-[>svg]:gap-x-2 *:[svg]:row-span-2 *:[svg]:translate-y-0.5 *:[svg]:text-current *:[svg:not([class*='size-'])]:size-4",+ {+ variants: {+ variant: {+ default: "bg-card text-card-foreground",+ destructive:+ "bg-card text-destructive *:data-[slot=alert-description]:text-destructive/90 *:[svg]:text-current",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+)++function Alert({+ className,+ variant,+ ...props+}) {+ return (+ <div+ data-slot="alert"+ role="alert"+ className={cn(alertVariants({ variant }), className)}+ {...props} />+ );+}++function AlertTitle({+ className,+ ...props+}) {+ return (+ <div+ data-slot="alert-title"+ className={cn(+ "font-medium group-has-[>svg]/alert:col-start-2 [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground",+ className+ )}+ {...props} />+ );+}++function AlertDescription({+ className,+ ...props+}) {+ return (+ <div+ data-slot="alert-description"+ className={cn(+ "text-sm text-balance text-muted-foreground md:text-pretty [&_a]:underline [&_a]:underline-offset-3 [&_a]:hover:text-foreground [&_p:not(:last-child)]:mb-4",+ className+ )}+ {...props} />+ );+}++function AlertAction({+ className,+ ...props+}) {+ return (+ <div+ data-slot="alert-action"+ className={cn("absolute top-2 right-2", className)}+ {...props} />+ );+}++export { Alert, AlertTitle, AlertDescription, AlertAction }diff --git a/frontend/src/components/ui/avatar.jsx b/frontend/src/components/ui/avatar.jsxnew file mode 100644index 0000000..fee91c8--- /dev/null+++ b/frontend/src/components/ui/avatar.jsx@@ -0,0 +1,105 @@+import * as React from "react"+import { Avatar as AvatarPrimitive } from "@base-ui/react/avatar"++import { cn } from "@/lib/utils"++function Avatar({+ className,+ size = "default",+ ...props+}) {+ return (+ <AvatarPrimitive.Root+ data-slot="avatar"+ data-size={size}+ className={cn(+ "group/avatar relative flex size-8 shrink-0 rounded-full select-none after:absolute after:inset-0 after:rounded-full after:border after:border-border after:mix-blend-darken data-[size=lg]:size-10 data-[size=sm]:size-6 dark:after:mix-blend-lighten",+ className+ )}+ {...props} />+ );+}++function AvatarImage({+ className,+ ...props+}) {+ return (+ <AvatarPrimitive.Image+ data-slot="avatar-image"+ className={cn("aspect-square size-full rounded-full object-cover", className)}+ {...props} />+ );+}++function AvatarFallback({+ className,+ ...props+}) {+ return (+ <AvatarPrimitive.Fallback+ data-slot="avatar-fallback"+ className={cn(+ "flex size-full items-center justify-center rounded-full bg-muted text-sm text-muted-foreground group-data-[size=sm]/avatar:text-xs",+ className+ )}+ {...props} />+ );+}++function AvatarBadge({+ className,+ ...props+}) {+ return (+ <span+ data-slot="avatar-badge"+ className={cn(+ "absolute right-0 bottom-0 z-10 inline-flex items-center justify-center rounded-full bg-primary text-primary-foreground bg-blend-color ring-2 ring-background select-none",+ "group-data-[size=sm]/avatar:size-2 group-data-[size=sm]/avatar:[&>svg]:hidden",+ "group-data-[size=default]/avatar:size-2.5 group-data-[size=default]/avatar:[&>svg]:size-2",+ "group-data-[size=lg]/avatar:size-3 group-data-[size=lg]/avatar:[&>svg]:size-2",+ className+ )}+ {...props} />+ );+}++function AvatarGroup({+ className,+ ...props+}) {+ return (+ <div+ data-slot="avatar-group"+ className={cn(+ "group/avatar-group flex -space-x-2 *:data-[slot=avatar]:ring-2 *:data-[slot=avatar]:ring-background",+ className+ )}+ {...props} />+ );+}++function AvatarGroupCount({+ className,+ ...props+}) {+ return (+ <div+ data-slot="avatar-group-count"+ className={cn(+ "relative flex size-8 shrink-0 items-center justify-center rounded-full bg-muted text-sm text-muted-foreground ring-2 ring-background group-has-data-[size=lg]/avatar-group:size-10 group-has-data-[size=sm]/avatar-group:size-6 [&>svg]:size-4 group-has-data-[size=lg]/avatar-group:[&>svg]:size-5 group-has-data-[size=sm]/avatar-group:[&>svg]:size-3",+ className+ )}+ {...props} />+ );+}++export {+ Avatar,+ AvatarImage,+ AvatarFallback,+ AvatarGroup,+ AvatarGroupCount,+ AvatarBadge,+}diff --git a/frontend/src/components/ui/badge.jsx b/frontend/src/components/ui/badge.jsxnew file mode 100644index 0000000..d7622ba--- /dev/null+++ b/frontend/src/components/ui/badge.jsx@@ -0,0 +1,49 @@+import { mergeProps } from "@base-ui/react/merge-props"+import { useRender } from "@base-ui/react/use-render"+import { cva } from "class-variance-authority";++import { cn } from "@/lib/utils"++const badgeVariants = cva(+ "group/badge inline-flex h-5 w-fit shrink-0 items-center justify-center gap-1 overflow-hidden rounded-4xl border border-transparent px-2 py-0.5 text-xs font-medium whitespace-nowrap transition-all focus-visible:border-ring focus-visible:ring-[3px] focus-visible:ring-ring/50 has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 aria-invalid:border-destructive aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 [&>svg]:pointer-events-none [&>svg]:size-3!",+ {+ variants: {+ variant: {+ default: "bg-primary text-primary-foreground [a]:hover:bg-primary/80",+ secondary:+ "bg-secondary text-secondary-foreground [a]:hover:bg-secondary/80",+ destructive:+ "bg-destructive/10 text-destructive focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:focus-visible:ring-destructive/40 [a]:hover:bg-destructive/20",+ outline:+ "border-border text-foreground [a]:hover:bg-muted [a]:hover:text-muted-foreground",+ ghost:+ "hover:bg-muted hover:text-muted-foreground dark:hover:bg-muted/50",+ link: "text-primary underline-offset-4 hover:underline",+ },+ },+ defaultVariants: {+ variant: "default",+ },+ }+)++function Badge({+ className,+ variant = "default",+ render,+ ...props+}) {+ return useRender({+ defaultTagName: "span",+ props: mergeProps({+ className: cn(badgeVariants({ variant }), className),+ }, props),+ render,+ state: {+ slot: "badge",+ variant,+ },+ });+}++export { Badge, badgeVariants }diff --git a/frontend/src/components/ui/button.jsx b/frontend/src/components/ui/button.jsxnew file mode 100644index 0000000..87c07ba--- /dev/null+++ b/frontend/src/components/ui/button.jsx@@ -0,0 +1,57 @@+import { Button as ButtonPrimitive } from "@base-ui/react/button"+import { cva } from "class-variance-authority";++import { cn } from "@/lib/utils"++const buttonVariants = cva(+ "group/button inline-flex shrink-0 items-center justify-center rounded-lg border border-transparent bg-clip-padding text-sm font-medium whitespace-nowrap transition-all outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 active:not-aria-[haspopup]:translate-y-px disabled:pointer-events-none disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ {+ variants: {+ variant: {+ default: "bg-primary text-primary-foreground hover:bg-primary/80",+ outline:+ "border-border bg-background hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:border-input dark:bg-input/30 dark:hover:bg-input/50",+ secondary:+ "bg-secondary text-secondary-foreground hover:bg-[color-mix(in_oklch,var(--secondary),var(--foreground)_5%)] aria-expanded:bg-secondary aria-expanded:text-secondary-foreground",+ ghost:+ "hover:bg-muted hover:text-foreground aria-expanded:bg-muted aria-expanded:text-foreground dark:hover:bg-muted/50",+ destructive:+ "bg-destructive/10 text-destructive hover:bg-destructive/20 focus-visible:border-destructive/40 focus-visible:ring-destructive/20 dark:bg-destructive/20 dark:hover:bg-destructive/30 dark:focus-visible:ring-destructive/40",+ link: "text-primary underline-offset-4 hover:underline",+ },+ size: {+ default:+ "h-8 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",+ xs: "h-6 gap-1 rounded-[min(var(--radius-md),10px)] px-2 text-xs in-data-[slot=button-group]:rounded-lg has-data-[icon=inline-end]:pr-1.5 has-data-[icon=inline-start]:pl-1.5 [&_svg:not([class*='size-'])]:size-3",+ sm: "h-7 gap-1 rounded-[min(var(--radius-md),12px)] px-2.5 text-[0.8rem] in-data-[slot=button-group]:rounded-lg 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 gap-1.5 px-2.5 has-data-[icon=inline-end]:pr-2 has-data-[icon=inline-start]:pl-2",+ icon: "size-8",+ "icon-xs":+ "size-6 rounded-[min(var(--radius-md),10px)] in-data-[slot=button-group]:rounded-lg [&_svg:not([class*='size-'])]:size-3",+ "icon-sm":+ "size-7 rounded-[min(var(--radius-md),12px)] in-data-[slot=button-group]:rounded-lg",+ "icon-lg": "size-9",+ },+ },+ defaultVariants: {+ variant: "default",+ size: "default",+ },+ }+)++function Button({+ className,+ variant = "default",+ size = "default",+ ...props+}) {+ return (+ <ButtonPrimitive+ data-slot="button"+ className={cn(buttonVariants({ variant, size, className }))}+ {...props} />+ );+}++export { Button, buttonVariants }diff --git a/frontend/src/components/ui/card.jsx b/frontend/src/components/ui/card.jsxnew file mode 100644index 0000000..6c66656--- /dev/null+++ b/frontend/src/components/ui/card.jsx@@ -0,0 +1,114 @@+import * as React from "react"++import { cn } from "@/lib/utils"++function Card({+ className,+ size = "default",+ ...props+}) {+ return (+ <div+ data-slot="card"+ data-size={size}+ className={cn(+ "group/card flex flex-col gap-(--card-spacing) overflow-hidden rounded-xl bg-card py-(--card-spacing) text-sm text-card-foreground ring-1 ring-foreground/10 [--card-spacing:--spacing(4)] 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-xl *:[img:last-child]:rounded-b-xl",+ className+ )}+ {...props} />+ );+}++function CardHeader({+ className,+ ...props+}) {+ 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+}) {+ return (+ <div+ data-slot="card-title"+ className={cn(+ "font-heading text-base leading-snug font-medium group-data-[size=sm]/card:text-sm",+ className+ )}+ {...props} />+ );+}++function CardDescription({+ className,+ ...props+}) {+ return (+ <div+ data-slot="card-description"+ className={cn("text-sm text-muted-foreground", className)}+ {...props} />+ );+}++function CardAction({+ className,+ ...props+}) {+ 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+}) {+ return (+ <div+ data-slot="card-content"+ className={cn("px-(--card-spacing)", className)}+ {...props} />+ );+}++function CardFooter({+ className,+ ...props+}) {+ return (+ <div+ data-slot="card-footer"+ className={cn(+ "flex items-center rounded-b-xl border-t bg-muted/50 p-(--card-spacing)",+ className+ )}+ {...props} />+ );+}++export {+ Card,+ CardHeader,+ CardFooter,+ CardTitle,+ CardAction,+ CardDescription,+ CardContent,+}diff --git a/frontend/src/components/ui/input.jsx b/frontend/src/components/ui/input.jsxnew file mode 100644index 0000000..d6ff8e4--- /dev/null+++ b/frontend/src/components/ui/input.jsx@@ -0,0 +1,23 @@+import * as React from "react"+import { Input as InputPrimitive } from "@base-ui/react/input"++import { cn } from "@/lib/utils"++function Input({+ className,+ type,+ ...props+}) {+ return (+ <InputPrimitive+ type={type}+ data-slot="input"+ className={cn(+ "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none file:inline-flex file:h-6 file:border-0 file:bg-transparent file:text-sm file:font-medium file:text-foreground placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",+ className+ )}+ {...props} />+ );+}++export { Input }diff --git a/frontend/src/components/ui/label.jsx b/frontend/src/components/ui/label.jsxnew file mode 100644index 0000000..773076b--- /dev/null+++ b/frontend/src/components/ui/label.jsx@@ -0,0 +1,22 @@+"use client"++import * as React from "react"++import { cn } from "@/lib/utils"++function Label({+ className,+ ...props+}) {+ 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/select.jsx b/frontend/src/components/ui/select.jsxnew file mode 100644index 0000000..ea68942--- /dev/null+++ b/frontend/src/components/ui/select.jsx@@ -0,0 +1,189 @@+import * as React from "react"+import { Select as SelectPrimitive } from "@base-ui/react/select"++import { cn } from "@/lib/utils"+import { ChevronDownIcon, CheckIcon, ChevronUpIcon } from "lucide-react"++const Select = SelectPrimitive.Root++function SelectGroup({+ className,+ ...props+}) {+ return (+ <SelectPrimitive.Group+ data-slot="select-group"+ className={cn("scroll-my-1 p-1", className)}+ {...props} />+ );+}++function SelectValue({+ className,+ ...props+}) {+ return (+ <SelectPrimitive.Value+ data-slot="select-value"+ className={cn("flex flex-1 text-left", className)}+ {...props} />+ );+}++function SelectTrigger({+ className,+ size = "default",+ children,+ ...props+}) {+ return (+ <SelectPrimitive.Trigger+ data-slot="select-trigger"+ data-size={size}+ className={cn(+ "flex w-fit items-center justify-between gap-1.5 rounded-lg border border-input bg-transparent py-2 pr-2 pl-2.5 text-sm whitespace-nowrap transition-colors outline-none select-none focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-placeholder:text-muted-foreground data-[size=default]:h-8 data-[size=sm]:h-7 data-[size=sm]:rounded-[min(var(--radius-md),10px)] *:data-[slot=select-value]:line-clamp-1 *:data-[slot=select-value]:flex *:data-[slot=select-value]:items-center *:data-[slot=select-value]:gap-1.5 dark:bg-input/30 dark:hover:bg-input/50 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4",+ className+ )}+ {...props}>+ {children}+ <SelectPrimitive.Icon+ render={+ <ChevronDownIcon className="pointer-events-none size-4 text-muted-foreground" />+ } />+ </SelectPrimitive.Trigger>+ );+}++function SelectContent({+ className,+ children,+ side = "bottom",+ sideOffset = 4,+ align = "center",+ alignOffset = 0,+ alignItemWithTrigger = true,+ ...props+}) {+ return (+ <SelectPrimitive.Portal>+ <SelectPrimitive.Positioner+ side={side}+ sideOffset={sideOffset}+ align={align}+ alignOffset={alignOffset}+ alignItemWithTrigger={alignItemWithTrigger}+ className="isolate z-50">+ <SelectPrimitive.Popup+ data-slot="select-content"+ data-align-trigger={alignItemWithTrigger}+ className={cn(+ "relative isolate z-50 max-h-(--available-height) w-(--anchor-width) min-w-36 origin-(--transform-origin) overflow-x-hidden overflow-y-auto rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-[align-trigger=true]:animate-none data-[side=bottom]:slide-in-from-top-2 data-[side=inline-end]:slide-in-from-left-2 data-[side=inline-start]:slide-in-from-right-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",+ className+ )}+ {...props}>+ <SelectScrollUpButton />+ <SelectPrimitive.List>{children}</SelectPrimitive.List>+ <SelectScrollDownButton />+ </SelectPrimitive.Popup>+ </SelectPrimitive.Positioner>+ </SelectPrimitive.Portal>+ );+}++function SelectLabel({+ className,+ ...props+}) {+ return (+ <SelectPrimitive.GroupLabel+ data-slot="select-label"+ className={cn("px-1.5 py-1 text-xs text-muted-foreground", className)}+ {...props} />+ );+}++function SelectItem({+ className,+ children,+ ...props+}) {+ return (+ <SelectPrimitive.Item+ data-slot="select-item"+ className={cn(+ "relative flex w-full cursor-default items-center gap-1.5 rounded-md py-1 pr-8 pl-1.5 text-sm outline-hidden select-none focus:bg-accent focus:text-accent-foreground not-data-[variant=destructive]:focus:**:text-accent-foreground data-disabled:pointer-events-none data-disabled:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4 *:[span]:last:flex *:[span]:last:items-center *:[span]:last:gap-2",+ className+ )}+ {...props}>+ <SelectPrimitive.ItemText className="flex flex-1 shrink-0 gap-2 whitespace-nowrap">+ {children}+ </SelectPrimitive.ItemText>+ <SelectPrimitive.ItemIndicator+ render={+ <span+ className="pointer-events-none absolute right-2 flex size-4 items-center justify-center" />+ }>+ <CheckIcon className="pointer-events-none" />+ </SelectPrimitive.ItemIndicator>+ </SelectPrimitive.Item>+ );+}++function SelectSeparator({+ className,+ ...props+}) {+ return (+ <SelectPrimitive.Separator+ data-slot="select-separator"+ className={cn("pointer-events-none -mx-1 my-1 h-px bg-border", className)}+ {...props} />+ );+}++function SelectScrollUpButton({+ className,+ ...props+}) {+ return (+ <SelectPrimitive.ScrollUpArrow+ data-slot="select-scroll-up-button"+ className={cn(+ "top-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",+ className+ )}+ {...props}>+ <ChevronUpIcon />+ </SelectPrimitive.ScrollUpArrow>+ );+}++function SelectScrollDownButton({+ className,+ ...props+}) {+ return (+ <SelectPrimitive.ScrollDownArrow+ data-slot="select-scroll-down-button"+ className={cn(+ "bottom-0 z-10 flex w-full cursor-default items-center justify-center bg-popover py-1 [&_svg:not([class*='size-'])]:size-4",+ className+ )}+ {...props}>+ <ChevronDownIcon />+ </SelectPrimitive.ScrollDownArrow>+ );+}++export {+ Select,+ SelectContent,+ SelectGroup,+ SelectItem,+ SelectLabel,+ SelectScrollDownButton,+ SelectScrollUpButton,+ SelectSeparator,+ SelectTrigger,+ SelectValue,+}diff --git a/frontend/src/components/ui/textarea.jsx b/frontend/src/components/ui/textarea.jsxnew file mode 100644index 0000000..decf453--- /dev/null+++ b/frontend/src/components/ui/textarea.jsx@@ -0,0 +1,20 @@+import * as React from "react"++import { cn } from "@/lib/utils"++function Textarea({+ className,+ ...props+}) {+ return (+ <textarea+ data-slot="textarea"+ className={cn(+ "flex field-sizing-content min-h-16 w-full rounded-lg border border-input bg-transparent px-2.5 py-2 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40",+ className+ )}+ {...props} />+ );+}++export { Textarea }