Add a theme preview and update the theme when highlight changes. (#151)

This commit is contained in:
Jacob Richman
2025-04-24 11:36:34 -07:00
committed by GitHub
parent d8c0587346
commit 5790a5d7cf
4 changed files with 70 additions and 5 deletions

View File

@@ -34,6 +34,9 @@ export interface RadioButtonSelectProps<T> {
/** Function called when an item is selected. Receives the `value` of the selected item. */
onSelect: (value: T) => void;
/** Function called when an item is highlighted. Receives the `value` of the selected item. */
onHighlight?: (value: T) => void;
}
/**
@@ -73,10 +76,16 @@ export function RadioButtonSelect<T>({
items,
initialIndex,
onSelect,
onHighlight,
}: RadioButtonSelectProps<T>): React.JSX.Element {
const handleSelect = (item: RadioSelectItem<T>) => {
onSelect(item.value);
};
const handleHighlight = (item: RadioSelectItem<T>) => {
if (onHighlight) {
onHighlight(item.value);
}
};
initialIndex = initialIndex ?? 0;
return (
<SelectInput
@@ -85,6 +94,7 @@ export function RadioButtonSelect<T>({
items={items}
initialIndex={initialIndex}
onSelect={handleSelect}
onHighlight={handleHighlight}
/>
);
}