@zohodesk/components 1.3.4 → 1.4.0

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.
Files changed (36) hide show
  1. package/.cli/config/variables/variableMapping.json +8 -1
  2. package/.cli/propValidation_report.html +1 -1
  3. package/README.md +9 -0
  4. package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +11 -0
  5. package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +11 -0
  6. package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +11 -0
  7. package/es/AppContainer/AppContainer.js +5 -4
  8. package/es/Provider/LibraryContext.js +7 -3
  9. package/es/deprecated/Switch/Switch.js +94 -0
  10. package/es/deprecated/Switch/props/defaultProps.js +11 -0
  11. package/es/deprecated/Switch/props/propTypes.js +28 -0
  12. package/es/v1/Switch/Switch.js +120 -78
  13. package/es/v1/Switch/__tests__/Switch.spec.js +30 -0
  14. package/es/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +137 -0
  15. package/es/v1/Switch/contants/index.js +18 -0
  16. package/es/v1/Switch/css/Switch_v1.module.css +133 -0
  17. package/es/v1/Switch/css/cssJSLogic.js +48 -0
  18. package/es/v1/Switch/props/defaultProps.js +10 -7
  19. package/es/v1/Switch/props/propTypes.js +30 -22
  20. package/es/v1/Switch/useSwitch.js +33 -0
  21. package/lib/AppContainer/AppContainer.js +7 -6
  22. package/lib/Provider/LibraryContext.js +7 -3
  23. package/lib/deprecated/Switch/Switch.js +108 -0
  24. package/lib/deprecated/Switch/props/defaultProps.js +18 -0
  25. package/lib/deprecated/Switch/props/propTypes.js +39 -0
  26. package/lib/v1/Switch/Switch.js +128 -79
  27. package/lib/v1/Switch/__tests__/Switch.spec.js +37 -0
  28. package/lib/v1/Switch/__tests__/__snapshots__/Switch.spec.js.snap +137 -0
  29. package/lib/v1/Switch/contants/index.js +27 -0
  30. package/lib/v1/Switch/css/Switch_v1.module.css +133 -0
  31. package/lib/v1/Switch/css/cssJSLogic.js +37 -0
  32. package/lib/v1/Switch/props/defaultProps.js +12 -9
  33. package/lib/v1/Switch/props/propTypes.js +32 -24
  34. package/lib/v1/Switch/useSwitch.js +56 -0
  35. package/package.json +6 -2
  36. package/result.json +1 -1
package/README.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
  Dot UI is a customizable React component library built to deliver a clean, accessible, and developer-friendly UI experience. It offers a growing set of reusable components designed to align with modern design systems and streamline application development across projects.
4
4
 
5
+ # 1.4.0
6
+
7
+ - **Switch(v1)** - Existing v1 Switch moved to depreacated folder and all New component Switch created with required accessibility and customization.
8
+ - Theme entry for component_v1 added.
9
+ - **LibraryContext** - `shouldIndicateSwitchState` key added for Switch component.
10
+
11
+ # 1.3.5
12
+
13
+ - **AppContainer** - Memory leak issue resolved.
5
14
 
6
15
  # 1.3.4
7
16
 
@@ -0,0 +1,11 @@
1
+ [data-mode='dark'] {
2
+ /* switch */
3
+ --zdt_v1_switch_track_on_bg: hsla(133, 48.36%, calc(52.16% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
+ --zdt_v1_switch_track_off_bg: hsla(223, 21.68%, calc(28.04% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
+ --zdt_v1_switch_track_on_hover_bg: hsla(134, 67.66%, calc(32.75% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
6
+ --zdt_v1_switch_track_off_hover_bg: hsla(216, 22.98%, calc(31.57% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
7
+ --zdt_v1_switch_thumb_bg: hsla(217, 23.08%, calc(17.84% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
+ --zdt_v1_switch_onLabel: hsla(217, 23.08%, calc(17.84% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
+ --zdt_v1_switch_offLabel: hsla(217, 13.73%, calc(70.00% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
+ --zdt_v1_switch_offLabel_hover: hsla(210, 7.41%, calc(89.41% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
11
+ }
@@ -0,0 +1,11 @@
1
+ [data-mode='light'] {
2
+ /* switch */
3
+ --zdt_v1_switch_track_on_bg: hsla(133, 63.29%, calc(40.59% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
+ --zdt_v1_switch_track_off_bg: hsla(213, 27.27%, calc(87.06% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
+ --zdt_v1_switch_track_on_hover_bg: hsla(134, 78.63%, calc(25.69% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
6
+ --zdt_v1_switch_track_off_hover_bg: hsla(231, 22.22%, calc(82.35% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
7
+ --zdt_v1_switch_thumb_bg: hsla(0, 0.00%, calc(100.00% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
+ --zdt_v1_switch_onLabel: hsla(0, 0.00%, calc(100.00% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
+ --zdt_v1_switch_offLabel: hsla(220, 10.45%, calc(39.41% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
+ --zdt_v1_switch_offLabel_hover: hsla(0, 0.00%, calc(0.00% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
11
+ }
@@ -0,0 +1,11 @@
1
+ [data-mode='pureDark'] {
2
+ /* switch */
3
+ --zdt_v1_switch_track_on_bg: hsla(133, 48.36%, calc(52.16% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
4
+ --zdt_v1_switch_track_off_bg: hsla(0, 0.00%, calc(20.00% + var(--zdc_default_inverse_low)), calc(1 + var(--zdc_alpha_low)));
5
+ --zdt_v1_switch_track_on_hover_bg: hsla(134, 67.66%, calc(32.75% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
6
+ --zdt_v1_switch_track_off_hover_bg: hsla(0, 0.00%, calc(34.51% + var(--zdc_default_inverse_lower)), calc(1 + var(--zdc_alpha_low)));
7
+ --zdt_v1_switch_thumb_bg: hsla(0, 0.00%, calc(12.94% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
8
+ --zdt_v1_switch_onLabel: hsla(0, 0.00%, calc(12.94% + var(--zdc_default)), calc(1 + var(--zdc_alpha_high)));
9
+ --zdt_v1_switch_offLabel: hsla(0, 0.00%, calc(60.00% + var(--zdc_default_inverse_medium)), calc(1 + var(--zdc_alpha_low)));
10
+ --zdt_v1_switch_offLabel_hover: hsla(210, 7.41%, calc(89.41% + var(--zdc_default_inverse)), calc(1 + var(--zdc_alpha_high)));
11
+ }
@@ -81,12 +81,13 @@ export default class AppContainer extends React.Component {
81
81
 
82
82
  if (this.containerElement && needTooltip) {
83
83
  this.containerElement.removeEventListener('mouseover', this.handleOver, false);
84
- this.containerElement.addEventListener('mouseout', this.removeTimeout, false);
84
+ this.containerElement.removeEventListener('mouseout', this.removeTimeout, false);
85
85
  this.tooltipRef.unObserveElement();
86
- setLibraryConfig({
87
- getTooltipContainer: () => null
88
- });
89
86
  }
87
+
88
+ setLibraryConfig({
89
+ getTooltipContainer: () => null
90
+ });
90
91
  }
91
92
 
92
93
  render() {
@@ -9,13 +9,15 @@ const LibraryContextProvider = _ref => {
9
9
  direction,
10
10
  coloredTagVariant,
11
11
  hasTagColorInheritedToText,
12
+ shouldIndicateSwitchState,
12
13
  children
13
14
  } = _ref;
14
15
  const [value, setValue] = useState({
15
16
  isReducedMotion,
16
17
  direction,
17
18
  coloredTagVariant,
18
- hasTagColorInheritedToText
19
+ hasTagColorInheritedToText,
20
+ shouldIndicateSwitchState
19
21
  });
20
22
 
21
23
  function setGlobalContext(key, data) {
@@ -38,12 +40,14 @@ LibraryContextProvider.propTypes = {
38
40
  isReducedMotion: PropTypes.bool,
39
41
  coloredTagVariant: PropTypes.oneOf(['bold', 'subtle', 'minimal']),
40
42
  hasTagColorInheritedToText: PropTypes.bool,
41
- direction: PropTypes.string
43
+ direction: PropTypes.string,
44
+ shouldIndicateSwitchState: PropTypes.bool
42
45
  };
43
46
  LibraryContextProvider.defaultProps = {
44
47
  isReducedMotion: getLibraryConfig('isReducedMotion'),
45
48
  direction: getLibraryConfig('direction'),
46
49
  coloredTagVariant: 'bold',
47
- hasTagColorInheritedToText: true
50
+ hasTagColorInheritedToText: true,
51
+ shouldIndicateSwitchState: false
48
52
  };
49
53
  export default LibraryContextProvider;
@@ -0,0 +1,94 @@
1
+ import React from 'react';
2
+ import { defaultProps } from "./props/defaultProps";
3
+ import { propTypes } from "./props/propTypes";
4
+ import { Container, Box } from "../../v1/Layout";
5
+ import Label from "../../v1/Label/Label";
6
+ import style from "../../Switch/Switch.module.css";
7
+
8
+ const Switch = props => {
9
+ let {
10
+ id,
11
+ name,
12
+ value,
13
+ checked,
14
+ disabled,
15
+ isReadOnly,
16
+ size,
17
+ text,
18
+ labelSize,
19
+ labelPalette,
20
+ title,
21
+ disableTitle,
22
+ dataId,
23
+ dataSelectorId,
24
+ customClass,
25
+ customProps
26
+ } = props;
27
+
28
+ function onChange(e) {
29
+ const {
30
+ onChange
31
+ } = props;
32
+ onChange && onChange(!checked, e);
33
+ }
34
+
35
+ let {
36
+ SwitchProps = {},
37
+ LabelProps = {}
38
+ } = customProps;
39
+ let {
40
+ customSwitchWrap = '',
41
+ customSwitch = '',
42
+ customSwitchSize = '',
43
+ customLabel = ''
44
+ } = customClass;
45
+ size !== 'small' ? size = 'switch_medium' : size = 'switch_small';
46
+ return /*#__PURE__*/React.createElement(Container, {
47
+ align: "vertical",
48
+ isCover: false,
49
+ alignBox: "row",
50
+ isInline: true,
51
+ className: `${style.container} ${customSwitchWrap} ${disabled ? style.disabled : isReadOnly ? style.readonly : style.effect}`,
52
+ "data-title": disabled ? disableTitle : title,
53
+ "aria-checked": checked,
54
+ role: "switch",
55
+ dataSelectorId: dataSelectorId,
56
+ ...SwitchProps
57
+ }, /*#__PURE__*/React.createElement(Box, {
58
+ className: `${style[size]} ${customSwitchSize}`
59
+ }, /*#__PURE__*/React.createElement("input", {
60
+ type: "checkbox",
61
+ id: id,
62
+ className: `${style.input} ${checked ? style.checked : ''}`,
63
+ name: name,
64
+ value: value,
65
+ checked: checked,
66
+ disabled: disabled,
67
+ readOnly: isReadOnly,
68
+ onClick: !disabled || !isReadOnly ? onChange : null
69
+ }), /*#__PURE__*/React.createElement("label", {
70
+ htmlFor: id,
71
+ "data-id": dataId,
72
+ "data-test-id": dataId,
73
+ className: `${style.label} ${style[`${size}Label`]} ${customSwitch}`,
74
+ tabIndex: isReadOnly || disabled ? '-1' : '0'
75
+ })), text && /*#__PURE__*/React.createElement(Label, {
76
+ text: text,
77
+ palette: labelPalette,
78
+ id: id,
79
+ size: labelSize,
80
+ type: "subtitle",
81
+ onClick: !disabled || !isReadOnly ? onChange : null,
82
+ customClass: customLabel,
83
+ ...LabelProps
84
+ }));
85
+ };
86
+
87
+ Switch.defaultProps = defaultProps;
88
+ Switch.propTypes = propTypes;
89
+ export default Switch; // if (__DOCS__) {
90
+ // Switch.docs = {
91
+ // componentGroup: 'Form Elements',
92
+ // folderName: 'Style Guide'
93
+ // };
94
+ // }
@@ -0,0 +1,11 @@
1
+ export const defaultProps = {
2
+ checked: false,
3
+ disabled: false,
4
+ labelPalette: 'primary',
5
+ labelSize: 'medium',
6
+ size: 'medium',
7
+ isReadOnly: false,
8
+ customClass: {},
9
+ customProps: {},
10
+ dataSelectorId: 'switch'
11
+ };
@@ -0,0 +1,28 @@
1
+ import PropTypes from 'prop-types';
2
+ export const propTypes = {
3
+ checked: PropTypes.bool,
4
+ dataId: PropTypes.string,
5
+ dataSelectorId: PropTypes.string,
6
+ disableTitle: PropTypes.string,
7
+ disabled: PropTypes.bool,
8
+ id: PropTypes.string.isRequired,
9
+ isReadOnly: PropTypes.bool,
10
+ labelPalette: PropTypes.oneOf(['default', 'primary', 'secondary', 'danger', 'mandatory']),
11
+ labelSize: PropTypes.oneOf(['small', 'medium', 'large']),
12
+ name: PropTypes.string,
13
+ onChange: PropTypes.func,
14
+ size: PropTypes.oneOf(['small', 'medium']),
15
+ text: PropTypes.string,
16
+ title: PropTypes.string,
17
+ value: PropTypes.bool,
18
+ customClass: PropTypes.shape({
19
+ customSwitchWrap: PropTypes.string,
20
+ customSwitch: PropTypes.string,
21
+ customSwitchSize: PropTypes.string,
22
+ customLabel: PropTypes.string
23
+ }),
24
+ customProps: PropTypes.shape({
25
+ SwitchProps: PropTypes.object,
26
+ LabelProps: PropTypes.object
27
+ })
28
+ };
@@ -1,94 +1,136 @@
1
- import React from 'react';
2
- import { defaultProps } from "./props/defaultProps";
3
- import { propTypes } from "./props/propTypes";
4
- import { Container, Box } from "../Layout";
5
- import Label from "../Label/Label";
6
- import style from "../../Switch/Switch.module.css";
1
+ import React from 'react'; // props
2
+
3
+ import defaultProps from "./props/defaultProps";
4
+ import propTypes from "./props/propTypes"; // methods
5
+
6
+ import cssJSLogic from "./css/cssJSLogic";
7
+ import { mergeStyle } from '@zohodesk/utils'; // hooks
8
+
9
+ import useSwitch from "./useSwitch"; // constants
10
+
11
+ import { LABEL_PLACEMENT, OFF_LABEL_RADIUS, THUMB_RADIUS } from "./contants"; // components
12
+
13
+ import Flex from '@zohodesk/layout/es/Flex/Flex';
14
+ import Label from "../../Label/Label"; // css
15
+
16
+ import defaultStyle from "./css/Switch_v1.module.css";
7
17
 
8
18
  const Switch = props => {
9
- let {
10
- id,
19
+ const {
11
20
  name,
12
21
  value,
13
- checked,
14
- disabled,
15
- isReadOnly,
22
+ id,
16
23
  size,
17
- text,
24
+ isDisabled,
25
+ isReadOnly,
26
+ hasStateIndication,
27
+ label,
28
+ labelPlacement,
18
29
  labelSize,
19
- labelPalette,
20
30
  title,
21
- disableTitle,
22
- dataId,
23
- dataSelectorId,
24
- customClass,
25
- customProps
31
+ customProps,
32
+ tagAttributes,
33
+ a11yAttributes,
34
+ i18nKeys,
35
+ customId,
36
+ testId,
37
+ customStyle
26
38
  } = props;
27
-
28
- function onChange(e) {
29
- const {
30
- onChange
31
- } = props;
32
- onChange && onChange(!checked, e);
33
- }
34
-
35
- let {
36
- SwitchProps = {},
37
- LabelProps = {}
39
+ const {
40
+ container: customProps_container,
41
+ label: customProps_label
38
42
  } = customProps;
39
- let {
40
- customSwitchWrap = '',
41
- customSwitch = '',
42
- customSwitchSize = '',
43
- customLabel = ''
44
- } = customClass;
45
- size !== 'small' ? size = 'switch_medium' : size = 'switch_small';
46
- return /*#__PURE__*/React.createElement(Container, {
47
- align: "vertical",
48
- isCover: false,
49
- alignBox: "row",
50
- isInline: true,
51
- className: `${style.container} ${customSwitchWrap} ${disabled ? style.disabled : isReadOnly ? style.readonly : style.effect}`,
52
- "data-title": disabled ? disableTitle : title,
53
- "aria-checked": checked,
54
- role: "switch",
55
- dataSelectorId: dataSelectorId,
56
- ...SwitchProps
57
- }, /*#__PURE__*/React.createElement(Box, {
58
- className: `${style[size]} ${customSwitchSize}`
59
- }, /*#__PURE__*/React.createElement("input", {
43
+ const {
44
+ container: tagAttributes_container,
45
+ switch: tagAttributes_switch
46
+ } = tagAttributes;
47
+ const {
48
+ container: a11yAttributes_container,
49
+ switch: a11yAttributes_switch = {},
50
+ label: a11yAttributes_label
51
+ } = a11yAttributes;
52
+ const {
53
+ ariaDisabled = isDisabled,
54
+ ariaLabel,
55
+ ...restA11yAttributes_switch
56
+ } = a11yAttributes_switch;
57
+ const {
58
+ readOnlyAriaLabel: i18n_readOnlyAriaLabel = 'Read Only'
59
+ } = i18nKeys;
60
+ const readOnlyAriaLabel = label ? `${label}, ${i18n_readOnlyAriaLabel}` : i18n_readOnlyAriaLabel;
61
+ const {
62
+ isChecked,
63
+ handleChange
64
+ } = useSwitch(props);
65
+ const style = mergeStyle(defaultStyle, customStyle);
66
+ const {
67
+ containerClass,
68
+ labelClass,
69
+ trackClass,
70
+ trackWrapperClass,
71
+ thumbClass,
72
+ labelIndicationClass
73
+ } = cssJSLogic({
74
+ props: { ...props,
75
+ isChecked
76
+ },
77
+ style
78
+ });
79
+ return /*#__PURE__*/React.createElement(Flex, { ...customProps_container,
80
+ $ui_displayMode: "inline",
81
+ $ui_direction: LABEL_PLACEMENT[labelPlacement],
82
+ $ui_alignItems: "center",
83
+ $tagAttributes_container: { ...tagAttributes_container,
84
+ 'data-selector-id': customId
85
+ },
86
+ testId: testId,
87
+ customId: customId,
88
+ $ui_className: containerClass,
89
+ $a11yAttributes_container: a11yAttributes_container
90
+ }, label && /*#__PURE__*/React.createElement(Label, { ...customProps_label,
91
+ text: label,
92
+ palette: isDisabled ? 'primary' : 'default',
93
+ size: labelSize,
94
+ htmlFor: id,
95
+ customClass: labelClass,
96
+ a11y: a11yAttributes_label
97
+ }), /*#__PURE__*/React.createElement(Flex, {
98
+ $flag_shrink: false,
99
+ $ui_className: trackWrapperClass
100
+ }, /*#__PURE__*/React.createElement("input", { ...tagAttributes_switch,
101
+ ...restA11yAttributes_switch,
60
102
  type: "checkbox",
61
103
  id: id,
62
- className: `${style.input} ${checked ? style.checked : ''}`,
63
104
  name: name,
64
105
  value: value,
65
- checked: checked,
66
- disabled: disabled,
67
- readOnly: isReadOnly,
68
- onClick: !disabled || !isReadOnly ? onChange : null
69
- }), /*#__PURE__*/React.createElement("label", {
70
- htmlFor: id,
71
- "data-id": dataId,
72
- "data-test-id": dataId,
73
- className: `${style.label} ${style[`${size}Label`]} ${customSwitch}`,
74
- tabIndex: isReadOnly || disabled ? '-1' : '0'
75
- })), text && /*#__PURE__*/React.createElement(Label, {
76
- text: text,
77
- palette: labelPalette,
78
- id: id,
79
- size: labelSize,
80
- type: "subtitle",
81
- onClick: !disabled || !isReadOnly ? onChange : null,
82
- customClass: customLabel,
83
- ...LabelProps
84
- }));
106
+ checked: isChecked,
107
+ onChange: handleChange,
108
+ className: trackClass,
109
+ "data-title": title,
110
+ role: "switch",
111
+ "aria-disabled": ariaDisabled,
112
+ "aria-label": isReadOnly ? readOnlyAriaLabel : ariaLabel
113
+ }), /*#__PURE__*/React.createElement("svg", {
114
+ className: thumbClass,
115
+ xmlns: "http://www.w3.org/2000/svg"
116
+ }, /*#__PURE__*/React.createElement("circle", {
117
+ cx: "50%",
118
+ cy: "50%",
119
+ r: THUMB_RADIUS[size]
120
+ })), hasStateIndication ? /*#__PURE__*/React.createElement("svg", {
121
+ className: labelIndicationClass,
122
+ xmlns: "http://www.w3.org/2000/svg"
123
+ }, isChecked ? /*#__PURE__*/React.createElement("rect", {
124
+ width: "100%",
125
+ height: "100%",
126
+ rx: "50%"
127
+ }) : /*#__PURE__*/React.createElement("circle", {
128
+ cx: "50%",
129
+ cy: "50%",
130
+ r: OFF_LABEL_RADIUS[size]
131
+ })) : null));
85
132
  };
86
133
 
134
+ export default Switch;
87
135
  Switch.defaultProps = defaultProps;
88
- Switch.propTypes = propTypes;
89
- export default Switch; // if (__DOCS__) {
90
- // Switch.docs = {
91
- // componentGroup: 'Form Elements',
92
- // folderName: 'Style Guide'
93
- // };
94
- // }
136
+ Switch.propTypes = propTypes;
@@ -0,0 +1,30 @@
1
+ import React from 'react';
2
+ import { render } from '@testing-library/react';
3
+ import Switch from "../Switch";
4
+ describe('Switch', () => {
5
+ test('rendering the defult props', () => {
6
+ const {
7
+ asFragment
8
+ } = render( /*#__PURE__*/React.createElement(Switch, null));
9
+ expect(asFragment()).toMatchSnapshot();
10
+ });
11
+ test('rendering the Switch with Checked', () => {
12
+ const {
13
+ asFragment
14
+ } = render( /*#__PURE__*/React.createElement(Switch, {
15
+ id: "switch",
16
+ isChecked: true
17
+ }));
18
+ expect(asFragment()).toMatchSnapshot();
19
+ });
20
+ test('rendering the Switch with Disabled', () => {
21
+ const {
22
+ asFragment
23
+ } = render( /*#__PURE__*/React.createElement(Switch, {
24
+ id: "switch",
25
+ isChecked: true,
26
+ isDisabled: true
27
+ }));
28
+ expect(asFragment()).toMatchSnapshot();
29
+ });
30
+ });
@@ -0,0 +1,137 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`Switch rendering the Switch with Checked 1`] = `
4
+ <DocumentFragment>
5
+ <div
6
+ class="inlineFlex row alignItems_center container medium checked enabled"
7
+ data-id="flex"
8
+ data-test-id="flex"
9
+ >
10
+ <div
11
+ class="noShrink trackWrapper"
12
+ data-id="flex"
13
+ data-test-id="flex"
14
+ >
15
+ <input
16
+ aria-disabled="false"
17
+ checked=""
18
+ class="track"
19
+ id="switch"
20
+ role="switch"
21
+ type="checkbox"
22
+ value=""
23
+ />
24
+ <svg
25
+ class="thumb commonSvg"
26
+ xmlns="http://www.w3.org/2000/svg"
27
+ >
28
+ <circle
29
+ cx="50%"
30
+ cy="50%"
31
+ r="42.85%"
32
+ />
33
+ </svg>
34
+ <svg
35
+ class="onLabel commonSvg"
36
+ xmlns="http://www.w3.org/2000/svg"
37
+ >
38
+ <rect
39
+ height="100%"
40
+ rx="50%"
41
+ width="100%"
42
+ />
43
+ </svg>
44
+ </div>
45
+ </div>
46
+ </DocumentFragment>
47
+ `;
48
+
49
+ exports[`Switch rendering the Switch with Disabled 1`] = `
50
+ <DocumentFragment>
51
+ <div
52
+ class="inlineFlex row alignItems_center container medium checked disabled"
53
+ data-id="flex"
54
+ data-test-id="flex"
55
+ >
56
+ <div
57
+ class="noShrink trackWrapper"
58
+ data-id="flex"
59
+ data-test-id="flex"
60
+ >
61
+ <input
62
+ aria-disabled="true"
63
+ checked=""
64
+ class="track"
65
+ id="switch"
66
+ role="switch"
67
+ type="checkbox"
68
+ value=""
69
+ />
70
+ <svg
71
+ class="thumb commonSvg"
72
+ xmlns="http://www.w3.org/2000/svg"
73
+ >
74
+ <circle
75
+ cx="50%"
76
+ cy="50%"
77
+ r="42.85%"
78
+ />
79
+ </svg>
80
+ <svg
81
+ class="onLabel commonSvg"
82
+ xmlns="http://www.w3.org/2000/svg"
83
+ >
84
+ <rect
85
+ height="100%"
86
+ rx="50%"
87
+ width="100%"
88
+ />
89
+ </svg>
90
+ </div>
91
+ </div>
92
+ </DocumentFragment>
93
+ `;
94
+
95
+ exports[`Switch rendering the defult props 1`] = `
96
+ <DocumentFragment>
97
+ <div
98
+ class="inlineFlex row alignItems_center container medium unChecked enabled"
99
+ data-id="flex"
100
+ data-test-id="flex"
101
+ >
102
+ <div
103
+ class="noShrink trackWrapper"
104
+ data-id="flex"
105
+ data-test-id="flex"
106
+ >
107
+ <input
108
+ aria-disabled="false"
109
+ class="track"
110
+ role="switch"
111
+ type="checkbox"
112
+ value=""
113
+ />
114
+ <svg
115
+ class="thumb commonSvg"
116
+ xmlns="http://www.w3.org/2000/svg"
117
+ >
118
+ <circle
119
+ cx="50%"
120
+ cy="50%"
121
+ r="42.85%"
122
+ />
123
+ </svg>
124
+ <svg
125
+ class="offLabel commonSvg"
126
+ xmlns="http://www.w3.org/2000/svg"
127
+ >
128
+ <circle
129
+ cx="50%"
130
+ cy="50%"
131
+ r="37.5%"
132
+ />
133
+ </svg>
134
+ </div>
135
+ </div>
136
+ </DocumentFragment>
137
+ `;
@@ -0,0 +1,18 @@
1
+ export const OFF_LABEL_RADIUS = {
2
+ small: '35.7%',
3
+ medium: '37.5%',
4
+ large: '38.9%',
5
+ xlarge: '40%'
6
+ };
7
+ export const THUMB_RADIUS = {
8
+ small: '40%',
9
+ medium: '42.85%',
10
+ large: '44.45%',
11
+ xlarge: '45.45%'
12
+ };
13
+ export const LABEL_PLACEMENT = {
14
+ start: 'row',
15
+ end: 'rowReverse',
16
+ top: 'column',
17
+ bottom: 'columnReverse'
18
+ };