Add disabled attribute in Checkbox, Toggle and RadioButton

Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
Ajay Bura 2021-12-31 17:38:25 +05:30
parent 387f6bcad4
commit a0399b7f5e
6 changed files with 25 additions and 5 deletions

View file

@ -2,7 +2,7 @@ import React from 'react';
import PropTypes from 'prop-types';
import './RadioButton.scss';
function RadioButton({ isActive, onToggle }) {
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
@ -10,6 +10,7 @@ function RadioButton({ isActive, onToggle }) {
onClick={() => onToggle(!isActive)}
className={`radio-btn${isActive ? ' radio-btn--active' : ''}`}
type="button"
disabled={disabled}
/>
);
}
@ -17,11 +18,13 @@ function RadioButton({ isActive, onToggle }) {
RadioButton.defaultProps = {
isActive: false,
onToggle: null,
disabled: false,
};
RadioButton.propTypes = {
isActive: PropTypes.bool,
onToggle: PropTypes.func,
disabled: PropTypes.bool,
};
export default RadioButton;