import React, { forwardRef } from 'react' /** * Nova Checkbox – fully custom rendering (appearance-none + SVG tick). * Avoids @tailwindcss/forms overriding the checked background colour. * * @prop {string} label - label text rendered alongside the box * @prop {string} hint - small helper line below label * @prop {string} error - inline error * @prop {number|string} size - pixel size (default 18) * @prop {string} variant - 'accent' | 'emerald' | 'sky' */ const variantStyles = { accent: { checked: '#E07A21', ring: 'rgba(224,122,33,0.45)' }, emerald: { checked: '#10b981', ring: 'rgba(16,185,129,0.45)' }, sky: { checked: '#0ea5e9', ring: 'rgba(14,165,233,0.45)' }, } const Checkbox = forwardRef(function Checkbox( { label, hint, error, size = 18, variant = 'accent', id, className = '', checked, disabled, onChange, ...rest }, ref, ) { const dim = typeof size === 'number' ? `${size}px` : size const numSize = typeof size === 'number' ? size : parseInt(size, 10) const inputId = id ?? (label ? `cb-${label.toLowerCase().replace(/\s+/g, '-')}` : undefined) const colors = variantStyles[variant] ?? variantStyles.accent // Tick sizes relative to box const tickInset = Math.round(numSize * 0.18) const strokeWidth = Math.max(1.5, numSize * 0.1) return (
{error}
)}