AI Resource Pro / website · airesourcepro.com / src / app / roadmap / start / option-button.tsx
| 1 | "use client"; |
| 2 | |
| 3 | import { Check } from "lucide-react"; |
| 4 | import type { Option } from "@/lib/onboarding"; |
| 5 | import { cn } from "@/lib/utils"; |
| 6 | |
| 7 | // One answer in the onboarding questions. `compact` is for long lists where many answers share the screen. |
| 8 | export function OptionButton({ |
| 9 | option, |
| 10 | selected, |
| 11 | multi, |
| 12 | compact = false, |
| 13 | onClick, |
| 14 | }: { |
| 15 | option: Option<string>; |
| 16 | selected: boolean; |
| 17 | multi: boolean; |
| 18 | compact?: boolean; |
| 19 | onClick: () => void; |
| 20 | }) { |
| 21 | return ( |
| 22 | <button |
| 23 | type="button" |
| 24 | role={multi ? "checkbox" : "radio"} |
| 25 | aria-checked={selected} |
| 26 | onClick={onClick} |
| 27 | className={cn( |
| 28 | "group flex w-full items-center rounded-2xl border text-left transition-colors duration-300", |
| 29 | compact ? "gap-3 px-4 py-3" : "gap-4 px-5 py-4 sm:px-6 sm:py-5", |
| 30 | selected ? "border-primary bg-primary/10" : "border-border [@media(hover:hover)]:hover:border-foreground/40" |
| 31 | )} |
| 32 | > |
| 33 | <span |
| 34 | aria-hidden |
| 35 | className={cn( |
| 36 | "flex shrink-0 items-center justify-center border transition-colors", |
| 37 | compact ? "h-5 w-5" : "h-6 w-6", |
| 38 | multi ? "rounded-md" : "rounded-full", |
| 39 | selected ? "border-primary bg-primary text-primary-foreground" : "border-foreground/30" |
| 40 | )} |
| 41 | > |
| 42 | {selected && <Check className={compact ? "h-3.5 w-3.5" : "h-4 w-4"} strokeWidth={2.5} />} |
| 43 | </span> |
| 44 | <span className="min-w-0"> |
| 45 | <span className={cn("block font-normal leading-snug text-foreground", compact ? "text-[15px] sm:text-[16px]" : "text-[17px] sm:text-[19px]")}> |
| 46 | {option.label} |
| 47 | </span> |
| 48 | {option.hint && ( |
| 49 | <span className={cn("mt-1 block leading-snug text-[var(--ash)]", compact ? "text-[13px]" : "text-[14px]")}>{option.hint}</span> |
| 50 | )} |
| 51 | </span> |
| 52 | </button> |
| 53 | ); |
| 54 | } |