2023-05-28 15:18:23 +03:00
|
|
|
import * as React from 'react';
|
2023-05-10 13:59:29 +03:00
|
|
|
|
2023-05-08 12:12:53 +03:00
|
|
|
import classNames from 'classnames';
|
|
|
|
|
2023-05-10 13:59:29 +03:00
|
|
|
interface Props {
|
2023-05-08 12:12:53 +03:00
|
|
|
value: string;
|
|
|
|
checked: boolean;
|
|
|
|
name: string;
|
|
|
|
onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
|
|
|
|
label: React.ReactNode;
|
2023-05-10 13:59:29 +03:00
|
|
|
}
|
2023-05-08 12:12:53 +03:00
|
|
|
|
2023-05-10 00:41:18 +03:00
|
|
|
export const RadioButton: React.FC<Props> = ({
|
|
|
|
name,
|
|
|
|
value,
|
|
|
|
checked,
|
|
|
|
onChange,
|
|
|
|
label,
|
|
|
|
}) => {
|
2023-05-08 12:12:53 +03:00
|
|
|
return (
|
|
|
|
<label className='radio-button'>
|
|
|
|
<input
|
|
|
|
name={name}
|
|
|
|
type='radio'
|
|
|
|
value={value}
|
|
|
|
checked={checked}
|
|
|
|
onChange={onChange}
|
|
|
|
/>
|
|
|
|
|
|
|
|
<span className={classNames('radio-button__input', { checked })} />
|
|
|
|
|
|
|
|
<span>{label}</span>
|
|
|
|
</label>
|
|
|
|
);
|
|
|
|
};
|