refactor: radio button group value generic

This commit is contained in:
Aman Harwara
2023-09-13 15:59:57 +05:30
parent 7c9cc821a2
commit a07fa23c70
2 changed files with 7 additions and 7 deletions

View File

@@ -1,19 +1,19 @@
import { VisuallyHidden, Radio, RadioGroup, useRadioStore } from '@ariakit/react'
import { classNames } from '@standardnotes/utils'
type Props = {
items: { label: string; value: string }[]
value: string
onChange: (value: string) => void
type Props<Value extends string> = {
items: { label: string; value: Value }[]
value: Value
onChange: (value: Value) => void
className?: string
}
const RadioButtonGroup = ({ value, items, onChange, className }: Props) => {
function RadioButtonGroup<Value extends string>({ value, items, onChange, className }: Props<Value>) {
const radio = useRadioStore({
value,
orientation: 'horizontal',
setValue(value) {
onChange(value as string)
onChange(value as Value)
},
})

View File

@@ -35,7 +35,7 @@ const VaultSelectionMenu = () => {
{ label: 'One', value: 'single' },
]}
value={mode}
onChange={(value) => changeSelectionMode(value as SettingsMode)}
onChange={(value) => changeSelectionMode(value)}
className="m-3 mt-1"
/>
{mode === 'many' && <ManyVaultSelectionMenu />}