mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-01 21:31:36 +02:00
Tearing down of old Editor (Settings) GitOrigin-RevId: d9e23e61a8e34eb22e9c9e3453a157fb275f68f0
52 lines
1.3 KiB
TypeScript
52 lines
1.3 KiB
TypeScript
import React from 'react'
|
|
|
|
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 => (
|
|
<label key={`${id}-${option.value}`} className="ide-radio-option">
|
|
<input
|
|
type="radio"
|
|
id={`${id}-${option.value}`}
|
|
name={id}
|
|
value={option.value}
|
|
checked={value === option.value}
|
|
onChange={handleChange}
|
|
className="ide-radio-input"
|
|
/>
|
|
<div className="ide-radio-text">
|
|
<span className="ide-setting-title">{option.label}</span>
|
|
{option.description && (
|
|
<span className="ide-setting-description">
|
|
{option.description}
|
|
</span>
|
|
)}
|
|
</div>
|
|
</label>
|
|
))}
|
|
</div>
|
|
)
|
|
}
|