mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-04 06:39:02 +02:00
9a129e7cab
[web] update copy & layout for notifications settings GitOrigin-RevId: 13b6b78b0b2bddd9d0137362a14bfdbdba9d7d20
45 lines
1.1 KiB
TypeScript
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>
|
|
)
|
|
}
|