cinny/src/app/atoms/button/RadioButton.jsx
Ajay Bura a0399b7f5e Add disabled attribute in Checkbox, Toggle and RadioButton
Signed-off-by: Ajay Bura <ajbura@gmail.com>
2021-12-31 17:38:25 +05:30

30 lines
751 B
JavaScript

import React from 'react';
import PropTypes from 'prop-types';
import './RadioButton.scss';
function RadioButton({ isActive, onToggle, disabled }) {
if (onToggle === null) return <span className={`radio-btn${isActive ? ' radio-btn--active' : ''}`} />;
return (
// eslint-disable-next-line jsx-a11y/control-has-associated-label
<button
onClick={() => onToggle(!isActive)}
className={`radio-btn${isActive ? ' radio-btn--active' : ''}`}
type="button"
disabled={disabled}
/>
);
}
RadioButton.defaultProps = {
isActive: false,
onToggle: null,
disabled: false,
};
RadioButton.propTypes = {
isActive: PropTypes.bool,
onToggle: PropTypes.func,
disabled: PropTypes.bool,
};
export default RadioButton;