|
| 1 | +import * as React from "react"; |
| 2 | +import * as CheckboxPrimitive from "@radix-ui/react-checkbox"; |
| 3 | +import { cn } from "../../utilities"; |
| 4 | + |
| 5 | +const CheckboxRoot = CheckboxPrimitive.Root; |
| 6 | + |
| 7 | +const CheckboxIndicator = CheckboxPrimitive.Indicator; |
| 8 | + |
| 9 | +const Checkbox = React.forwardRef< |
| 10 | + React.ElementRef<typeof CheckboxPrimitive.Root>, |
| 11 | + React.ComponentPropsWithoutRef<typeof CheckboxPrimitive.Root> |
| 12 | +>(({ className, ...props }, ref) => ( |
| 13 | + <CheckboxPrimitive.Root |
| 14 | + ref={ref} |
| 15 | + className={cn( |
| 16 | + [ |
| 17 | + "flex h-4 w-4 shrink-0 items-center justify-center rounded-[4px] border border-theme-border-bold bg-theme-surface-primary", |
| 18 | + "hover:ring-4 hover:ring-theme-surface-tertiary", |
| 19 | + "focus:outline-none focus:ring-4 focus:ring-theme-surface-tertiary", |
| 20 | + "data-[state=checked]:border-theme-surface-strong data-[state=checked]:bg-theme-surface-strong data-[state=checked]:active:border-primary-200 data-[state=checked]:active:bg-primary-200", |
| 21 | + "active:bg-theme-surface-tertiary", |
| 22 | + "disabled:pointer-events-none disabled:border-neutral-300 disabled:data-[state=checked]:border-neutral-300 disabled:data-[state=checked]:bg-neutral-300" |
| 23 | + ], |
| 24 | + className |
| 25 | + )} |
| 26 | + {...props} |
| 27 | + > |
| 28 | + <CheckboxPrimitive.Indicator className={cn("flex items-center justify-center text-current")}> |
| 29 | + <svg |
| 30 | + className="w-2 h-2 fill-white" |
| 31 | + viewBox="0 0 12 10" |
| 32 | + fill="black" |
| 33 | + xmlns="http://www.w3.org/2000/svg" |
| 34 | + > |
| 35 | + <path |
| 36 | + fillRule="evenodd" |
| 37 | + clipRule="evenodd" |
| 38 | + d="M4.28267 6.34605L2.09696 4.09419L0.666677 5.55738L4.28267 9.28281L11.3333 2.01874L9.91314 0.555542L4.28267 6.34605Z" |
| 39 | + /> |
| 40 | + </svg> |
| 41 | + </CheckboxPrimitive.Indicator> |
| 42 | + </CheckboxPrimitive.Root> |
| 43 | +)); |
| 44 | +Checkbox.displayName = CheckboxPrimitive.Root.displayName; |
| 45 | + |
| 46 | +export { Checkbox, CheckboxRoot, CheckboxIndicator }; |
0 commit comments