import React from 'react'; import clsx from 'clsx'; import {ButtonBase} from '../buttons/button-base'; type Props = { onChange?: (e: string) => void; value?: string; colors: string[]; }; export function ColorSwatch({onChange, value, colors}: Props) { const presetButtons = colors.map(color => { const isSelected = value === color; return ( { onChange?.(color); }} className={clsx( 'relative block flex-shrink-0 w-26 h-26 border rounded', isSelected && 'shadow-md' )} style={{backgroundColor: color}} > {isSelected && ( )} ); }); return
{presetButtons}
; }