mirror of
https://github.com/cinnyapp/cinny.git
synced 2025-11-11 01:30:29 +03:00
Add disabled attribute in Checkbox, Toggle and RadioButton
Signed-off-by: Ajay Bura <ajbura@gmail.com>
This commit is contained in:
parent
387f6bcad4
commit
a0399b7f5e
6 changed files with 25 additions and 5 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue