import { useCallback } from 'react';
import { Pressable, View } from 'react-native';
import { cn } from '../../../lib/cn';
const SWATCH_SIZE = 24;
type SwatchProps = { hex: string; selected: boolean; onSelect: (hex: string) => void; testID?: string };
function Swatch({ hex, selected, onSelect, testID }: SwatchProps) {
const handlePress = useCallback(() => onSelect(hex), [onSelect, hex]);
return (
);
}
export type SwatchesProps = {
colors: readonly string[];
/** Current hex — the matching swatch gets a stronger ring. */
value: string;
onSelect: (hex: string) => void;
testID?: string;
};
/**
* A wrap of preset colour squares. Tapping one commits it outright — a discrete
* pick, unlike the continuous drag of the panel and slider.
*/
export function Swatches({ colors, value, onSelect, testID }: SwatchesProps) {
const current = value.toLowerCase();
return (
{colors.map((hex, index) => (
))}
);
}