GRV-Admin/src/components/ui/switch.tsx
kirukib 408b707437 Add GRV Summit admin portal
Vite + React 19 + TypeScript staff/admin SPA built against GRV-Backend/API.md:
email OTP login (staff/admin only, 401 -> login), dashboard stats and
leaderboard, application review (filters, bulk status, CSV export, scoring),
inquiries by intent, orders and ticket check-in, tiers, discount codes, merch
items and pickup queue, QR checkpoints with printable A6 cards, startup badges,
raffles with draw, and attendees.

Shell and UI primitives adapted from the Booking platform admin; theme, fonts,
logo and topography pattern match the public GRVSummit site. Static deploy to
Cloudflare Pages via public/_redirects.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-17 21:37:33 +03:00

52 lines
1.9 KiB
TypeScript

import * as React from 'react';
import * as SwitchPrimitive from '@radix-ui/react-switch';
import { cn } from '@/lib/utils';
export const Switch = React.forwardRef<
React.ElementRef<typeof SwitchPrimitive.Root>,
React.ComponentPropsWithoutRef<typeof SwitchPrimitive.Root>
>(({ className, ...props }, ref) => (
<SwitchPrimitive.Root
ref={ref}
className={cn(
'hit-44 peer inline-flex h-6 w-11 shrink-0 cursor-pointer items-center rounded-full border-2 border-transparent transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-focus focus-visible:ring-offset-2 focus-visible:ring-offset-canvas disabled:cursor-not-allowed disabled:opacity-50 data-[state=checked]:bg-primary data-[state=unchecked]:bg-input',
className,
)}
{...props}
>
<SwitchPrimitive.Thumb className="pointer-events-none block h-5 w-5 rounded-full bg-surface shadow-card transition-transform data-[state=checked]:translate-x-5 data-[state=unchecked]:translate-x-0" />
</SwitchPrimitive.Root>
));
Switch.displayName = 'Switch';
/** Switch with a label and optional description, the whole row clickable. */
export function SwitchRow({
label,
description,
checked,
onCheckedChange,
disabled,
id,
}: {
label: React.ReactNode;
description?: React.ReactNode;
checked: boolean;
onCheckedChange: (v: boolean) => void;
disabled?: boolean;
id?: string;
}) {
const auto = React.useId();
const sid = id ?? auto;
return (
<div className="flex items-start justify-between gap-4 py-2">
<label htmlFor={sid} className="min-w-0 cursor-pointer">
<span className="block text-sm font-medium text-fg">{label}</span>
{description ? (
<span className="mt-0.5 block text-xs text-muted">{description}</span>
) : null}
</label>
<Switch id={sid} checked={checked} onCheckedChange={onCheckedChange} disabled={disabled} />
</div>
);
}