Skip to content

Saleor Core: the high performance, composable, headless commerce API.

Add disabled state

dominik-zeglenfa484eed18b7
diff --git a/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx b/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx
index 012eedb865..ee91ab9316 100644
--- a/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx
+++ b/saleor/static/dashboard-next/components/Checkbox/Checkbox.tsx
@@ -24,6 +24,9 @@ const styles = (theme: Theme) =>
},
borderColor: theme.palette.primary.main
},
+ "&$disabled": {
+ borderColor: theme.palette.grey[200]
+ },
"&$indeterminate": {
"&:before": {
background: theme.palette.primary.main,
@@ -54,6 +57,7 @@ const styles = (theme: Theme) =>
width: 14
},
checked: {},
+ disabled: {},
indeterminate: {},
root: {
alignItems: "center",
@@ -70,6 +74,7 @@ const Checkbox = withStyles(styles, { name: "Checkbox" })(
checked,
className,
classes,
+ disabled,
indeterminate,
onChange,
onClick,
@@ -91,13 +96,16 @@ const Checkbox = withStyles(styles, { name: "Checkbox" })(
{...props}
centerRipple
className={classNames(classes.root, className)}
+ disabled={disabled}
onClick={handleClick}
>
<input
className={classNames(classes.box, {
[classes.checked]: checked,
+ [classes.disabled]: disabled,
[classes.indeterminate]: indeterminate
})}
+ disabled={disabled}
type="checkbox"
name={name}
value={checked.toString()}
diff --git a/saleor/static/dashboard-next/storybook/stories/components/Checkbox.tsx b/saleor/static/dashboard-next/storybook/stories/components/Checkbox.tsx
index 9293a48e91..2ff5c51a88 100644
--- a/saleor/static/dashboard-next/storybook/stories/components/Checkbox.tsx
+++ b/saleor/static/dashboard-next/storybook/stories/components/Checkbox.tsx
@@ -17,6 +17,7 @@ storiesOf("Generics / Checkbox", module)
.add("checked", () => <Checkbox {...props} checked={true} />)
.add("unchecked", () => <Checkbox {...props} />)
.add("undeterminate", () => <Checkbox {...props} indeterminate={true} />)
+ .add("disabled", () => <Checkbox {...props} disabled={true} />)
.add("interactive", () => (
<Form initial={{ data: false }}>
{({ change, data }) => (