@kaizen/components 1.70.16 → 1.70.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -10,6 +10,6 @@ export type ToggleSwitchProps = {
10
10
  reversed?: boolean;
11
11
  } & OverrideClassName<Omit<InputHTMLAttributes<HTMLInputElement>, 'onChange' | 'onToggle'>>;
12
12
  export declare const ToggleSwitch: {
13
- ({ toggledStatus, onToggle, reversed, ...restProps }: ToggleSwitchProps): JSX.Element;
13
+ ({ toggledStatus, onToggle, reversed, disabled, ...restProps }: ToggleSwitchProps): JSX.Element;
14
14
  displayName: string;
15
15
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kaizen/components",
3
- "version": "1.70.16",
3
+ "version": "1.70.18",
4
4
  "description": "Kaizen component library",
5
5
  "author": "Geoffrey Chong <geoff.chong@cultureamp.com>",
6
6
  "homepage": "https://cultureamp.design",
@@ -27,19 +27,20 @@ $focus-ring-offset: 1px;
27
27
 
28
28
  /* TODO: Fix */
29
29
  /* stylelint-disable no-descending-specificity */
30
- .checkbox:focus + &,
31
- .checkbox:hover:focus + & {
30
+ .checkbox:not(.disabled):focus + &,
31
+ .checkbox:not(.disabled):hover:focus + & {
32
32
  border-color: transparent;
33
33
  outline: 2px solid $color-blue-500;
34
34
  outline-offset: $focus-ring-offset;
35
35
  background-color: $color-gray-600;
36
36
  }
37
37
 
38
- .checkbox + &:hover,
39
- label:hover .checkbox + & {
38
+ .checkbox:not(.disabled) + &:hover,
39
+ label:hover .checkbox:not(.disabled) + & {
40
40
  background-color: $color-purple-500;
41
41
  background-color: $color-gray-600;
42
42
  }
43
+
43
44
  /* stylelint-enable no-descending-specificity */
44
45
  }
45
46
 
@@ -54,6 +55,7 @@ $focus-ring-offset: 1px;
54
55
  transition:
55
56
  left $animation-timing,
56
57
  right $animation-timing;
58
+ cursor: default;
57
59
  }
58
60
 
59
61
  .checkIcon {
@@ -71,7 +73,7 @@ $focus-ring-offset: 1px;
71
73
 
72
74
  .checkbox:focus + .track {
73
75
  border-color: transparent;
74
- background-color: $color-green-500;
76
+ background-color: $color-green-600;
75
77
  }
76
78
 
77
79
  .thumb {
@@ -86,8 +88,8 @@ $focus-ring-offset: 1px;
86
88
  transition-duration: $animation-duration-fast;
87
89
  }
88
90
 
89
- .checkbox + .track:hover,
90
- label:hover & .checkbox + .track {
91
+ .checkbox:not(.disabled) + .track:hover,
92
+ label:hover & .checkbox:not(.disabled) + .track {
91
93
  background-color: $color-green-600;
92
94
  }
93
95
  }
@@ -116,10 +118,20 @@ $focus-ring-offset: 1px;
116
118
  background-color: rgba($color-white-rgb, 0.65);
117
119
  }
118
120
 
119
- .checkbox + .track:hover,
120
- label:hover & .checkbox + .track {
121
+ .checkbox:not(.disabled) + .track:hover,
122
+ label:hover & .checkbox:not(.disabled) + .track {
121
123
  background-color: rgba($color-white-rgb, 0.65);
122
124
  }
123
125
  }
124
126
  }
127
+
128
+ // When the ToggleSwitch is used as part of the ToggleSwitchField, the disabled state opacity is set on the Label component
129
+ label .disabled.track {
130
+ opacity: 100%;
131
+ }
132
+
133
+ .disabled.track {
134
+ opacity: 30%;
135
+ }
136
+
125
137
  /* stylelint-enable no-descending-specificity */
@@ -19,6 +19,7 @@ export const ToggleSwitch = ({
19
19
  toggledStatus,
20
20
  onToggle,
21
21
  reversed,
22
+ disabled,
22
23
  ...restProps
23
24
  }: ToggleSwitchProps): JSX.Element => {
24
25
  const isOn = toggledStatus === 'on'
@@ -27,12 +28,13 @@ export const ToggleSwitch = ({
27
28
  <span className={classnames(isOn ? styles.on : styles.off, reversed && styles.reversed)}>
28
29
  <input
29
30
  type="checkbox"
30
- className={styles.checkbox}
31
+ className={classnames(styles.checkbox, disabled && styles.disabled)}
31
32
  checked={isOn ? true : false}
32
33
  onChange={onToggle}
34
+ disabled={disabled}
33
35
  {...restProps}
34
36
  />
35
- <span className={styles.track}>
37
+ <span className={classnames(styles.track, disabled && styles.disabled)}>
36
38
  <span className={styles.thumb}>
37
39
  <Icon name="check" isPresentational className={styles.checkIcon} />
38
40
  </span>