Merge pull request 'Milestone 4: admin web UI (Vite, React, shadcn/ui)' (#12) from feat/m4-admin-ui into main

This commit is contained in:
squidd 2026-11-09 15:42:37 +01:00
commit 16124bbaf3
65 changed files with 10263 additions and 1 deletions

7
.dockerignore Normal file
View file

@ -0,0 +1,7 @@
.git
admin/node_modules
internal/adminui/dist/*
!internal/adminui/dist/.gitkeep
parsimony
*.db
*.db-*

3
.gitignore vendored
View file

@ -1,3 +1,6 @@
parsimony
*.db
*.db-*
admin/node_modules
internal/adminui/dist/*
!internal/adminui/dist/.gitkeep

View file

@ -1,8 +1,17 @@
FROM node:24 AS admin
WORKDIR /src/admin
COPY admin/package.json admin/package-lock.json ./
RUN npm ci
COPY admin/ ./
# The build writes into ../internal/adminui/dist
RUN mkdir -p /src/internal/adminui/dist && npm run build
FROM golang:1.27 AS build
WORKDIR /src
COPY go.mod go.sum ./
RUN go mod download
COPY . .
COPY --from=admin /src/internal/adminui/dist ./internal/adminui/dist
RUN CGO_ENABLED=0 go build -o /parsimony ./cmd/parsimony
FROM gcr.io/distroless/static-debian12

18
Makefile Normal file
View file

@ -0,0 +1,18 @@
.PHONY: all admin test build clean
all: admin build
# Build the admin UI into internal/adminui/dist, which the Go binary embeds.
admin:
cd admin && npm ci && npm run build
build:
go build -o parsimony ./cmd/parsimony
test:
go test ./...
cd admin && npm test
clean:
rm -f parsimony
node admin/scripts/clean.mjs

View file

@ -15,6 +15,8 @@ A modern, single-binary mailing list manager: an evolution of Mailman.
- Per-recipient one-click unsubscribe links (RFC 8058) with signed tokens.
- SQLite storage, one YAML config file.
- Admin REST API under `/api/v1` (see `docs/openapi.yaml`).
- Admin web UI (Vite, React, shadcn/ui) served by the API listener at `/`: lists, settings,
members, held queue and archive.
## Run
@ -40,6 +42,21 @@ the unsubscribe links in every message use it. Keep the `api` listener private.
curl -H "Authorization: Bearer $PARSIMONY_API_TOKEN" -d '{"name":"dev","domain":"example.org","title":"Dev"}' localhost:8080/api/v1/lists
```
## Admin UI
The UI is a single-page app in `admin/`, built into `internal/adminui/dist` and embedded in the binary.
It is served on the API listener together with `/api`, so it needs no CORS, and only when
`PARSIMONY_API_TOKEN` is set. You sign in with that token (kept in `sessionStorage`, gone when the tab closes).
```
make admin # npm ci && npm run build
make build # go build, embeds the UI
make test # go test + vitest
```
Without `make admin` the binary still builds and the UI answers 503 with a hint.
For frontend work run the daemon, then `cd admin && npm run dev` (Vite proxies `/api` to `127.0.0.1:8080`).
## Postfix
Deliver the list domains to parsimony over LMTP and keep the `+` extensions intact, for example:

24
admin/.gitignore vendored Normal file
View file

@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*
node_modules
dist
dist-ssr
*.local
# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?

8
admin/.oxlintrc.json Normal file
View file

@ -0,0 +1,8 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"plugins": ["react", "typescript", "oxc"],
"rules": {
"react/rules-of-hooks": "error",
"react/only-export-components": ["warn", { "allowConstantExport": true }]
}
}

25
admin/components.json Normal file
View file

@ -0,0 +1,25 @@
{
"$schema": "https://ui.shadcn.com/schema.json",
"style": "base-nova",
"rsc": false,
"tsx": true,
"tailwind": {
"config": "",
"css": "src/index.css",
"baseColor": "neutral",
"cssVariables": true,
"prefix": ""
},
"iconLibrary": "lucide",
"rtl": false,
"aliases": {
"components": "@/components",
"utils": "@/lib/utils",
"ui": "@/components/ui",
"lib": "@/lib",
"hooks": "@/hooks"
},
"menuColor": "default",
"menuAccent": "subtle",
"registries": {}
}

13
admin/index.html Normal file
View file

@ -0,0 +1,13 @@
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/favicon.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>admin</title>
</head>
<body>
<div id="root"></div>
<script type="module" src="/src/main.tsx"></script>
</body>
</html>

5982
admin/package-lock.json generated Normal file

File diff suppressed because it is too large Load diff

47
admin/package.json Normal file
View file

@ -0,0 +1,47 @@
{
"name": "admin",
"private": true,
"version": "0.0.0",
"type": "module",
"scripts": {
"dev": "vite",
"build": "node scripts/clean.mjs && tsc -b && vite build",
"lint": "oxlint",
"preview": "vite preview",
"test": "vitest run",
"test:watch": "vitest"
},
"dependencies": {
"@base-ui/react": "^1.9.0",
"@fontsource-variable/geist": "^5.3.0",
"@tailwindcss/vite": "^4.3.5",
"@tanstack/react-query": "^5.107.1",
"class-variance-authority": "^0.7.1",
"clsx": "^2.1.1",
"lucide-react": "^1.70.0",
"next-themes": "^0.4.6",
"react": "^19.3.1",
"react-dom": "^19.3.1",
"react-router": "^8.5.1",
"shadcn": "^4.23.0",
"sonner": "^2.0.8",
"tailwind-merge": "^3.7.0",
"tailwindcss": "^4.3.5",
"tw-animate-css": "^1.4.0"
},
"devDependencies": {
"@testing-library/dom": "^10.4.2",
"@testing-library/jest-dom": "^7.0.1",
"@testing-library/react": "^16.3.3",
"@testing-library/user-event": "^14.6.8",
"@types/node": "^24.19.2",
"@types/react": "^19.3.0",
"@types/react-dom": "^19.3.0",
"@vitejs/plugin-react": "^6.1.2",
"jsdom": "^31.0.0",
"oxlint": "^1.90.0",
"typescript": "~7.0.2",
"vite": "^8.3.6",
"vitest": "^5.1.0"
}
}

1
admin/public/favicon.svg Normal file

File diff suppressed because one or more lines are too long

After

Width:  |  Height:  |  Size: 9.3 KiB

8
admin/scripts/clean.mjs Normal file
View file

@ -0,0 +1,8 @@
// Empties the Go embed directory but keeps .gitkeep, so `go build` always works.
import { readdirSync, rmSync } from 'node:fs'
import { join } from 'node:path'
const dist = new URL('../../internal/adminui/dist', import.meta.url).pathname
for (const name of readdirSync(dist)) {
if (name !== '.gitkeep') rmSync(join(dist, name), { recursive: true, force: true })
}

110
admin/src/App.test.tsx Normal file
View file

@ -0,0 +1,110 @@
import { screen, waitFor } from '@testing-library/react'
import { describe, expect, it } from 'vitest'
import { aList, installFakeApi, newState } from '@/test/fakeApi'
import { renderApp } from '@/test/render'
describe('authentication', () => {
it('does not keep the token when the check fails for another reason than 401', async () => {
installFakeApi(newState({ fail: { 'GET /lists': { status: 500, error: 'database is locked' } } }))
const { user } = renderApp('/login')
await user.type(await screen.findByLabelText(/api token/i), 'good')
await user.click(screen.getByRole('button', { name: /sign in/i }))
expect(await screen.findByText('database is locked')).toBeInTheDocument()
expect(sessionStorage.getItem('parsimony.token')).toBeNull()
})
it('drops cached data when the session ends', async () => {
const state = installFakeApi(newState({ lists: [aList()] }))
const { client } = renderApp('/', { token: 'good', keepCache: true })
await screen.findByText('dev@example.org')
expect(client.getQueryData(['lists'])).toBeDefined()
state.token = 'rotated'
const { api } = await import('@/lib/api')
await api.lists.list().catch(() => undefined)
await screen.findByRole('heading', { name: /sign in/i })
expect(client.getQueryData(['lists'])).toBeUndefined()
})
it('drops cached data on sign out', async () => {
installFakeApi(newState({ lists: [aList()] }))
const { user, client } = renderApp('/', { token: 'good', keepCache: true })
await screen.findByText('dev@example.org')
await user.click(screen.getByRole('button', { name: /sign out/i }))
await screen.findByRole('heading', { name: /sign in/i })
expect(client.getQueryData(['lists'])).toBeUndefined()
})
it('sends anonymous visitors to the login page', async () => {
installFakeApi(newState())
renderApp('/')
expect(await screen.findByRole('heading', { name: /sign in/i })).toBeInTheDocument()
expect(screen.getByLabelText(/api token/i)).toHaveAttribute('type', 'password')
})
it('also protects deep links', async () => {
installFakeApi(newState({ lists: [aList()] }))
renderApp('/lists/1/members')
expect(await screen.findByRole('heading', { name: /sign in/i })).toBeInTheDocument()
})
it('shows the server error for a wrong token and stays on the login page', async () => {
const state = installFakeApi(newState())
const { user } = renderApp('/login')
await user.type(await screen.findByLabelText(/api token/i), 'wrong')
await user.click(screen.getByRole('button', { name: /sign in/i }))
expect(await screen.findByText('invalid or missing token')).toBeInTheDocument()
expect(screen.getByRole('heading', { name: /sign in/i })).toBeInTheDocument()
expect(sessionStorage.getItem('parsimony.token')).toBeNull()
expect(state.calls).toEqual(['GET /lists'])
})
it('does not call the API with an empty token', async () => {
const state = installFakeApi(newState())
const { user } = renderApp('/login')
await user.click(await screen.findByRole('button', { name: /sign in/i }))
expect(await screen.findByText(/enter the api token/i)).toBeInTheDocument()
expect(state.calls).toEqual([])
})
it('signs in with a good token and shows the lists', async () => {
installFakeApi(newState({ lists: [aList()] }))
const { user } = renderApp('/login')
await user.type(await screen.findByLabelText(/api token/i), 'good')
await user.click(screen.getByRole('button', { name: /sign in/i }))
expect(await screen.findByRole('heading', { name: /^lists$/i })).toBeInTheDocument()
expect(await screen.findByText('dev@example.org')).toBeInTheDocument()
expect(sessionStorage.getItem('parsimony.token')).toBe('good')
})
it('goes straight to the lists when a token is already stored', async () => {
installFakeApi(newState({ lists: [aList()] }))
renderApp('/', { token: 'good' })
expect(await screen.findByText('dev@example.org')).toBeInTheDocument()
})
it('signs out', async () => {
installFakeApi(newState())
const { user } = renderApp('/', { token: 'good' })
await user.click(await screen.findByRole('button', { name: /sign out/i }))
expect(await screen.findByRole('heading', { name: /sign in/i })).toBeInTheDocument()
expect(sessionStorage.getItem('parsimony.token')).toBeNull()
})
it('falls back to the login page when the token stops working', async () => {
const state = installFakeApi(newState({ lists: [aList()] }))
renderApp('/', { token: 'good' })
await screen.findByText('dev@example.org')
state.token = 'rotated' // the server no longer accepts the stored token
const { api } = await import('@/lib/api')
await api.lists.list().catch(() => undefined)
await waitFor(() => expect(screen.getByRole('heading', { name: /sign in/i })).toBeInTheDocument())
expect(sessionStorage.getItem('parsimony.token')).toBeNull()
})
it('unknown paths show a not-found page with a way back', async () => {
installFakeApi(newState())
renderApp('/nowhere', { token: 'good' })
expect(await screen.findByRole('heading', { name: /not found/i })).toBeInTheDocument()
expect(screen.getByRole('link', { name: /back to lists/i })).toHaveAttribute('href', '/')
})
})

33
admin/src/App.tsx Normal file
View file

@ -0,0 +1,33 @@
import { Route, Routes } from 'react-router'
import { Shell } from '@/components/Shell'
import { ListPage } from '@/pages/ListPage'
import { ListsPage } from '@/pages/ListsPage'
import { LoginPage } from '@/pages/LoginPage'
import { NotFoundPage } from '@/pages/NotFoundPage'
import { ArchiveTab } from '@/tabs/ArchiveTab'
import { HeldTab } from '@/tabs/HeldTab'
import { MembersTab } from '@/tabs/MembersTab'
import { SettingsTab } from '@/tabs/SettingsTab'
import { Toaster } from '@/components/ui/sonner'
/** Routes only: providers (query client, router, auth) are set up by the caller. */
export function App() {
return (
<>
<Routes>
<Route path="/login" element={<LoginPage />} />
<Route element={<Shell />}>
<Route index element={<ListsPage />} />
<Route path="lists/:id" element={<ListPage />}>
<Route index element={<SettingsTab />} />
<Route path="members" element={<MembersTab />} />
<Route path="held" element={<HeldTab />} />
<Route path="archive" element={<ArchiveTab />} />
</Route>
<Route path="*" element={<NotFoundPage />} />
</Route>
</Routes>
<Toaster />
</>
)
}

View file

@ -0,0 +1,82 @@
import { useMutation, useQueryClient } from '@tanstack/react-query'
import { useState, type FormEvent } from 'react'
import { toast } from 'sonner'
import { Button } from '@/components/ui/button'
import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from '@/components/ui/dialog'
import { Input } from '@/components/ui/input'
import { Label } from '@/components/ui/label'
import { api } from '@/lib/api'
export function CreateListDialog({ open, onOpenChange }: { open: boolean; onOpenChange: (open: boolean) => void }) {
return (
<Dialog open={open} onOpenChange={onOpenChange}>
<DialogContent>
<DialogHeader>
<DialogTitle>New list</DialogTitle>
<DialogDescription>The address will be name@domain.</DialogDescription>
</DialogHeader>
{/* The form lives inside the popup, so its state is dropped every time the dialog closes. */}
<CreateListForm onDone={() => onOpenChange(false)} />
</DialogContent>
</Dialog>
)
}
function CreateListForm({ onDone }: { onDone: () => void }) {
const queryClient = useQueryClient()
const [name, setName] = useState('')
const [domain, setDomain] = useState('')
const [title, setTitle] = useState('')
const [error, setError] = useState<string | null>(null)
const create = useMutation({
mutationFn: api.lists.create,
onSuccess: async (list) => {
await queryClient.invalidateQueries({ queryKey: ['lists'] })
toast.success(`Created ${list.address}`)
onDone()
},
onError: (e: Error) => setError(e.message),
})
function submit(e: FormEvent) {
e.preventDefault()
const n = name.trim()
const d = domain.trim()
if (!n || !d) {
setError('Name and domain are required')
return
}
if (/[@+\s]/.test(n) || /[@+\s]/.test(d)) {
setError("Name and domain must not contain '@', '+' or spaces")
return
}
setError(null)
create.mutate({ name: n, domain: d, title: title.trim() || undefined })
}
return (
<form onSubmit={submit} className="space-y-4">
<div className="space-y-2">
<Label htmlFor="list-name">Name</Label>
<Input id="list-name" value={name} onChange={(e) => setName(e.target.value)} placeholder="dev" autoComplete="off" />
</div>
<div className="space-y-2">
<Label htmlFor="list-domain">Domain</Label>
<Input id="list-domain" value={domain} onChange={(e) => setDomain(e.target.value)} placeholder="example.org" autoComplete="off" />
</div>
<div className="space-y-2">
<Label htmlFor="list-title">Title</Label>
<Input id="list-title" value={title} onChange={(e) => setTitle(e.target.value)} placeholder="Optional" autoComplete="off" />
</div>
{error && (
<p role="alert" className="text-sm text-destructive">
{error}
</p>
)}
<Button type="submit" className="w-full" disabled={create.isPending}>
Create list
</Button>
</form>
)
}

View file

@ -0,0 +1,40 @@
import { Label } from '@/components/ui/label'
import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '@/components/ui/select'
export interface Option<T extends string> {
value: T
label: string
}
/** A labelled select. The label is also the accessible name of the control. */
export function SelectField<T extends string>({
id,
label,
value,
options,
onChange,
}: {
id: string
label: string
value: T
options: Option<T>[]
onChange: (value: T) => void
}) {
return (
<div className="space-y-2">
<Label htmlFor={id}>{label}</Label>
<Select value={value} onValueChange={(v) => v && onChange(v as T)} items={options}>
<SelectTrigger id={id} className="w-full">
<SelectValue />
</SelectTrigger>
<SelectContent>
{options.map((o) => (
<SelectItem key={o.value} value={o.value}>
{o.label}
</SelectItem>
))}
</SelectContent>
</Select>
</div>
)
}

View file

@ -0,0 +1,27 @@
import { Link, Navigate, Outlet, useLocation } from 'react-router'
import { Button } from '@/components/ui/button'
import { useAuth } from '@/lib/auth'
/** Layout for every page that needs a session. */
export function Shell() {
const { authed, logout } = useAuth()
const location = useLocation()
if (!authed) return <Navigate to="/login" replace state={{ from: location.pathname }} />
return (
<div className="min-h-screen">
<header className="border-b">
<div className="mx-auto flex max-w-5xl items-center justify-between p-4">
<Link to="/" className="text-lg font-semibold">
Parsimony
</Link>
<Button variant="outline" size="sm" onClick={logout}>
Sign out
</Button>
</div>
</header>
<main className="mx-auto max-w-5xl p-4">
<Outlet />
</main>
</div>
)
}

View file

@ -0,0 +1,185 @@
import * as React from "react"
import { AlertDialog as AlertDialogPrimitive } from "@base-ui/react/alert-dialog"
import { cn } from "@/lib/utils"
import { Button } from "@/components/ui/button"
function AlertDialog({ ...props }: AlertDialogPrimitive.Root.Props) {
return <AlertDialogPrimitive.Root data-slot="alert-dialog" {...props} />
}
function AlertDialogTrigger({ ...props }: AlertDialogPrimitive.Trigger.Props) {
return (
<AlertDialogPrimitive.Trigger data-slot="alert-dialog-trigger" {...props} />
)
}
function AlertDialogPortal({ ...props }: AlertDialogPrimitive.Portal.Props) {
return (
<AlertDialogPrimitive.Portal data-slot="alert-dialog-portal" {...props} />
)
}
function AlertDialogOverlay({
className,
...props
}: AlertDialogPrimitive.Backdrop.Props) {
return (
<AlertDialogPrimitive.Backdrop
data-slot="alert-dialog-overlay"
className={cn(
"fixed inset-0 isolate z-50 bg-black/10 duration-100 supports-backdrop-filter:backdrop-blur-xs data-open:animate-in data-open:fade-in-0 data-closed:animate-out data-closed:fade-out-0",
className
)}
{...props}
/>
)
}
function AlertDialogContent({
className,
size = "default",
...props
}: AlertDialogPrimitive.Popup.Props & {
size?: "default" | "sm"
}) {
return (
<AlertDialogPortal>
<AlertDialogOverlay />
<AlertDialogPrimitive.Popup
data-slot="alert-dialog-content"
data-size={size}
className={cn(
"group/alert-dialog-content fixed top-1/2 left-1/2 z-50 grid w-full -translate-x-1/2 -translate-y-1/2 gap-4 rounded-xl bg-popover p-4 text-popover-foreground ring-1 ring-foreground/10 duration-100 outline-none data-[size=default]:max-w-xs data-[size=sm]:max-w-xs data-[size=default]:sm:max-w-sm 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}
/>
</AlertDialogPortal>
)
}
function AlertDialogHeader({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-header"
className={cn(
"grid grid-rows-[auto_1fr] place-items-center gap-1.5 text-center has-data-[slot=alert-dialog-media]:grid-rows-[auto_auto_1fr] has-data-[slot=alert-dialog-media]:gap-x-4 sm:group-data-[size=default]/alert-dialog-content:place-items-start sm:group-data-[size=default]/alert-dialog-content:text-left sm:group-data-[size=default]/alert-dialog-content:has-data-[slot=alert-dialog-media]:grid-rows-[auto_1fr]",
className
)}
{...props}
/>
)
}
function AlertDialogFooter({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-footer"
className={cn(
"-mx-4 -mb-4 flex flex-col-reverse gap-2 rounded-b-xl border-t bg-muted/50 p-4 group-data-[size=sm]/alert-dialog-content:grid group-data-[size=sm]/alert-dialog-content:grid-cols-2 sm:flex-row sm:justify-end",
className
)}
{...props}
/>
)
}
function AlertDialogMedia({
className,
...props
}: React.ComponentProps<"div">) {
return (
<div
data-slot="alert-dialog-media"
className={cn(
"mb-2 inline-flex size-10 items-center justify-center rounded-md bg-muted sm:group-data-[size=default]/alert-dialog-content:row-span-2 *:[svg:not([class*='size-'])]:size-6",
className
)}
{...props}
/>
)
}
function AlertDialogTitle({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Title>) {
return (
<AlertDialogPrimitive.Title
data-slot="alert-dialog-title"
className={cn(
"font-heading text-base font-medium sm:group-data-[size=default]/alert-dialog-content:group-has-data-[slot=alert-dialog-media]/alert-dialog-content:col-start-2",
className
)}
{...props}
/>
)
}
function AlertDialogDescription({
className,
...props
}: React.ComponentProps<typeof AlertDialogPrimitive.Description>) {
return (
<AlertDialogPrimitive.Description
data-slot="alert-dialog-description"
className={cn(
"text-sm text-balance text-muted-foreground md:text-pretty *:[a]:underline *:[a]:underline-offset-3 *:[a]:hover:text-foreground",
className
)}
{...props}
/>
)
}
function AlertDialogAction({
className,
...props
}: React.ComponentProps<typeof Button>) {
return (
<Button
data-slot="alert-dialog-action"
className={cn(className)}
{...props}
/>
)
}
function AlertDialogCancel({
className,
variant = "outline",
size = "default",
...props
}: AlertDialogPrimitive.Close.Props &
Pick<React.ComponentProps<typeof Button>, "variant" | "size">) {
return (
<AlertDialogPrimitive.Close
data-slot="alert-dialog-cancel"
className={cn(className)}
render={<Button variant={variant} size={size} />}
{...props}
/>
)
}
export {
AlertDialog,
AlertDialogAction,
AlertDialogCancel,
AlertDialogContent,
AlertDialogDescription,
AlertDialogFooter,
AlertDialogHeader,
AlertDialogMedia,
AlertDialogOverlay,
AlertDialogPortal,
AlertDialogTitle,
AlertDialogTrigger,
}

View file

@ -0,0 +1,51 @@
import { mergeProps } from "@base-ui/react/merge-props"
import { useRender } from "@base-ui/react/use-render"
import { cva, type VariantProps } 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
}: useRender.ComponentProps<"span"> & VariantProps<typeof badgeVariants>) {
return useRender({
defaultTagName: "span",
props: mergeProps<"span">(
{
className: cn(badgeVariants({ variant }), className),
},
props
),
render,
state: {
slot: "badge",
variant,
},
})
}
export { Badge, badgeVariants }

Some files were not shown because too many files have changed in this diff Show more