mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
a2946f8601
Radio buttons for Onboarding Data Collection GitOrigin-RevId: 8c4d1e965f3263b4c8a41c129c5c3d6e3ef10986
42 lines
782 B
TypeScript
42 lines
782 B
TypeScript
import React from 'react'
|
|
|
|
type RadioChipProps<ValueType> = {
|
|
checked?: boolean
|
|
disabled?: boolean
|
|
name: string
|
|
onChange: (value: ValueType) => void
|
|
required?: boolean
|
|
label: React.ReactElement | string
|
|
value: ValueType
|
|
}
|
|
|
|
const RadioChip = <T extends string>({
|
|
checked,
|
|
disabled,
|
|
name,
|
|
onChange,
|
|
label,
|
|
required,
|
|
value,
|
|
}: RadioChipProps<T>) => {
|
|
const handleChange = () => {
|
|
onChange(value)
|
|
}
|
|
|
|
return (
|
|
<label className="radio-chip" data-disabled={disabled ? 'true' : undefined}>
|
|
<input
|
|
checked={checked}
|
|
disabled={disabled}
|
|
name={name}
|
|
onChange={handleChange}
|
|
type="radio"
|
|
required={required}
|
|
value={value}
|
|
/>
|
|
{label}
|
|
</label>
|
|
)
|
|
}
|
|
|
|
export default RadioChip
|