refactor(ts): convert all UI primitives + ThemeContext to TSX (B2)
Foundational for phase B: the ui/* primitives were untyped .jsx, and TS infers
React-19 ref-as-prop components as *requiring* a ref, so every consumer errored.
Converted all 22 ui primitives (button, input, card, dialog, select, table,
dropdown-menu, tabs, badge, checkbox, switch, tooltip, separator, label,
Skeleton, collapsible, alert-dialog, sonner, save-status, theme-toggle,
input-dialog, confirm-dialog) using ComponentProps<'el'> / ComponentProps<typeof
Radix.X> + VariantProps for cva components — refs now optional, event params
typed. Also converted ThemeContext.tsx (createContext(null) made useContext's
post-guard return `never`, so setTheme was uncallable — fixed with a typed
context value) and three tracker cells (EditableCell/NotesCell/
LowerThisMonthButton) that consume the branded TrackerRow.
Added a shared errMessage(unknown) helper to utils (strict catch → unknown);
usePaymentActions reuses it. TrackerRow gains monthly_notes + amount_suggestion
(real server fields).
typecheck 0, lint 0 errors (42 warns), build green, 48 client tests. NOTE: the
e2e auth-setup probe is currently red on an unrelated, pre-existing
release-notes-modal dismissal race (reproduces on the last known-good commit;
the a11y snapshot shows these converted primitives rendering correctly) —
investigating separately.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-03 22:57:22 -05:00
|
|
|
import { cva, type VariantProps } from 'class-variance-authority';
|
|
|
|
|
import type { ComponentProps } from 'react';
|
2026-05-03 19:51:57 -05:00
|
|
|
import { cn } from '@/lib/utils';
|
|
|
|
|
|
|
|
|
|
const badgeVariants = cva(
|
|
|
|
|
'inline-flex items-center rounded-full border px-2.5 py-0.5 text-xs font-semibold transition-colors focus:outline-none focus:ring-[3px] focus:ring-ring/50',
|
|
|
|
|
{
|
|
|
|
|
variants: {
|
|
|
|
|
variant: {
|
2026-07-06 14:23:53 -05:00
|
|
|
default: 'border-transparent bg-primary text-primary-foreground shadow hover:bg-primary/80',
|
|
|
|
|
secondary:
|
|
|
|
|
'border-transparent bg-secondary text-secondary-foreground hover:bg-secondary/80',
|
|
|
|
|
destructive:
|
|
|
|
|
'border-transparent bg-destructive text-destructive-foreground shadow hover:bg-destructive/80',
|
|
|
|
|
outline: 'text-foreground',
|
2026-05-03 19:51:57 -05:00
|
|
|
// Bill status variants
|
2026-07-06 14:23:53 -05:00
|
|
|
paid: 'bg-emerald-500/15 text-emerald-700 border-emerald-500/35 dark:text-emerald-200 dark:border-emerald-300/35',
|
|
|
|
|
late: 'bg-orange-500/15 text-orange-700 border-orange-500/45 shadow-sm shadow-orange-950/10 dark:text-orange-100 dark:border-orange-300/55',
|
|
|
|
|
missed:
|
|
|
|
|
'bg-rose-500/15 text-rose-700 border-rose-500/45 shadow-sm shadow-rose-950/10 dark:text-rose-100 dark:border-rose-300/55',
|
|
|
|
|
due_soon:
|
|
|
|
|
'bg-amber-500/15 text-amber-700 border-amber-500/40 dark:text-amber-100 dark:border-amber-300/40',
|
|
|
|
|
upcoming:
|
|
|
|
|
'bg-slate-500/10 text-slate-700 border-slate-400/35 dark:text-slate-200 dark:border-slate-300/30',
|
|
|
|
|
autodraft:
|
|
|
|
|
'bg-teal-500/15 text-teal-700 border-teal-500/35 dark:text-teal-100 dark:border-teal-300/35',
|
2026-05-03 19:51:57 -05:00
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
defaultVariants: {
|
|
|
|
|
variant: 'default',
|
|
|
|
|
},
|
2026-07-06 14:23:53 -05:00
|
|
|
},
|
2026-05-03 19:51:57 -05:00
|
|
|
);
|
|
|
|
|
|
2026-07-06 14:23:53 -05:00
|
|
|
function Badge({
|
|
|
|
|
className,
|
|
|
|
|
variant,
|
|
|
|
|
...props
|
|
|
|
|
}: ComponentProps<'div'> & VariantProps<typeof badgeVariants>) {
|
|
|
|
|
return <div className={cn(badgeVariants({ variant }), className)} {...props} />;
|
2026-05-03 19:51:57 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export { Badge, badgeVariants };
|