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,9 @@ import React from 'react';
import PropTypes from 'prop-types';
import './Checkbox.scss';
function Checkbox({ variant, isActive, onToggle }) {
function Checkbox({
variant, isActive, onToggle, disabled,
}) {
const className = `checkbox checkbox-${variant}${isActive ? ' checkbox--active' : ''}`;
if (onToggle === null) return <span className={className} />;
return (
@ -11,6 +13,7 @@ function Checkbox({ variant, isActive, onToggle }) {
onClick={() => onToggle(!isActive)}
className={className}
type="button"
disabled={disabled}
/>
);
}
@ -19,12 +22,14 @@ Checkbox.defaultProps = {
variant: 'primary',
isActive: false,
onToggle: null,
disabled: false,
};
Checkbox.propTypes = {
variant: PropTypes.oneOf(['primary', 'positive', 'caution', 'danger']),
isActive: PropTypes.bool,
onToggle: PropTypes.func,
disabled: PropTypes.bool,
};
export default Checkbox;