Files
overleaf-cep/services/web/frontend/js/features/ide-settings/components/radio-button-setting.tsx
T
Mathias Jakobsen 3a3adf5e5a Merge pull request #34980 from overleaf/mj-ide-settings-feature
[web] Consolidate ide settings in `features/ide-settings`

GitOrigin-RevId: cbf0ff069399f418d8cb0d8165628df190046ea9
2026-09-17 11:13:11 +00:00

45 lines
1.1 KiB
TypeScript

import React from 'react'
import OLFormCheckbox from '@/shared/components/ol/ol-form-checkbox'
export type RadioOption<T extends string = string> = {
value: T
label: string
description?: string
}
type RadioButtonSettingProps<T extends string = string> = {
id: string
options: Array<RadioOption<T>>
value: T | undefined
onChange: (value: T) => void
}
export default function RadioButtonSetting<T extends string = string>({
id,
options,
value,
onChange,
}: RadioButtonSettingProps<T>) {
const handleChange = (event: React.ChangeEvent<HTMLInputElement>) => {
onChange(event.target.value as T)
}
return (
<div className="ide-radio-setting-options">
{options.map(option => (
<OLFormCheckbox
key={`${id}-${option.value}`}
type="radio"
id={`${id}-${option.value}`}
name={id}
value={option.value}
checked={value === option.value}
onChange={handleChange}
label={option.label}
description={option.description}
/>
))}
</div>
)
}