~cytrogen/masto-fe

ref: 76264e3fe86d1ac3c9f6d91290e77db8d9272d1a masto-fe/app/javascript/mastodon/components/radio_button.tsx -rw-r--r-- 662 bytes
76264e3f — たいち ひ Rewrite RadioButton component as FC (#24897) 2 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
import React from 'react';
import classNames from 'classnames';

type Props = {
  value: string;
  checked: boolean;
  name: string;
  onChange: (event: React.ChangeEvent<HTMLInputElement>) => void;
  label: React.ReactNode;
};

export const RadioButton: React.FC<Props> = ({ name, value, checked, onChange, label }) => {
  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>
  );
};

export default RadioButton;