import { For, splitProps, mergeProps, createMemo } from 'solid-js'; export default function ColorPicker(props) { const merged = mergeProps({ value: '', colors: ['#6366f1', '#10b981', '#f59e0b', '#1f2937'] }, props); const [local, others] = splitProps(merged, ['value', 'onInput', 'class', 'colors']); const colors = local.colors; const isCustomColor = createMemo(() => { return !colors.includes(local.value?.toLowerCase()); }); const select = (color) => { local.onInput?.(color); }; return (
{(color) => ( select(color)} style={{ background: color }} class={`ap-w-8 ap-h-8 ap-rounded-full ap-cursor-pointer ap-transition-all ap-ring-1 ${ color === local.value ? 'ap-ring-2 ap-ring-indigo-500 ap--translate-y-0.5' : 'ap-ring-slate-300 hover:ap-ring-indigo-200 hover:ap--translate-y-0.5' }`} /> )}
); }