@zohodesk/components 1.0.0-temp-242.6 → 1.0.0-temp-252
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.
- package/README.md +74 -14
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +68 -0
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +68 -0
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +68 -0
- package/es/Avatar/Avatar.module.css +8 -8
- package/es/AvatarTeam/AvatarTeam.module.css +30 -30
- package/es/Button/css/Button.module.css +19 -19
- package/es/Buttongroup/Buttongroup.module.css +13 -35
- package/es/Card/Card.module.css +6 -4
- package/es/CheckBox/CheckBox.module.css +3 -10
- package/es/ColorSelect/_shared/ColorIndicator/ColorIndicator.module.css +4 -2
- package/es/DateTime/DateTime.module.css +22 -35
- package/es/DateTime/DateWidget.module.css +1 -1
- package/es/DateTime/YearView.module.css +8 -10
- package/es/DropBox/DropBoxElement/css/DropBoxElement.module.css +5 -4
- package/es/DropDown/DropDown.module.css +2 -1
- package/es/DropDown/DropDownHeading.module.css +4 -4
- package/es/DropDown/DropDownItem.module.css +5 -12
- package/es/DropDown/DropDownSearch.module.css +3 -3
- package/es/DropDown/DropDownSeparator.module.css +2 -1
- package/es/Label/Label.module.css +5 -5
- package/es/ListItem/ListItem.js +6 -4
- package/es/ListItem/ListItem.module.css +62 -66
- package/es/ListItem/ListItemWithAvatar.js +7 -5
- package/es/ListItem/ListItemWithCheckBox.js +9 -5
- package/es/ListItem/ListItemWithIcon.js +10 -7
- package/es/ListItem/ListItemWithRadio.js +9 -6
- package/es/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +4 -4
- package/es/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +131 -82
- package/es/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +432 -390
- package/es/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +141 -92
- package/es/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +432 -390
- package/es/ListItem/props/defaultProps.js +2 -1
- package/es/ListItem/props/propTypes.js +4 -2
- package/es/MultiSelect/AdvancedGroupMultiSelect.js +14 -3
- package/es/MultiSelect/AdvancedMultiSelect.js +2 -0
- package/es/MultiSelect/EmptyState.js +16 -2
- package/es/MultiSelect/MobileHeader/MobileHeader.module.css +4 -3
- package/es/MultiSelect/MultiSelect.js +4 -2
- package/es/MultiSelect/MultiSelect.module.css +21 -34
- package/es/MultiSelect/MultiSelectWithAvatar.js +2 -0
- package/es/MultiSelect/SelectedOptions.module.css +6 -10
- package/es/MultiSelect/Suggestions.js +7 -2
- package/es/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +10 -10
- package/es/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +34 -28
- package/es/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +20 -20
- package/es/MultiSelect/props/defaultProps.js +2 -0
- package/es/MultiSelect/props/propTypes.js +14 -3
- package/es/Popup/Popup.js +13 -12
- package/es/Radio/Radio.module.css +11 -12
- package/es/ResponsiveDropBox/ResponsiveDropBox.module.css +1 -1
- package/es/Ribbon/Ribbon.module.css +23 -29
- package/es/RippleEffect/RippleEffect.module.css +55 -17
- package/es/Select/GroupSelect.js +14 -4
- package/es/Select/Select.js +94 -72
- package/es/Select/Select.module.css +50 -17
- package/es/Select/SelectWithAvatar.js +14 -4
- package/es/Select/SelectWithIcon.js +14 -4
- package/es/Select/__tests__/__snapshots__/Select.spec.js.snap +88 -88
- package/es/Select/props/defaultProps.js +10 -4
- package/es/Select/props/propTypes.js +30 -5
- package/es/Stencils/Stencils.module.css +30 -14
- package/es/Switch/Switch.module.css +1 -8
- package/es/Tab/Tab.module.css +8 -15
- package/es/Tab/Tabs.module.css +12 -22
- package/es/Tag/Tag.module.css +21 -21
- package/es/TextBox/TextBox.module.css +9 -9
- package/es/TextBoxIcon/TextBoxIcon.module.css +1 -1
- package/es/Textarea/Textarea.module.css +18 -18
- package/es/Tooltip/Tooltip.module.css +5 -4
- package/es/Typography/Typography.js +18 -8
- package/es/Typography/__tests__/Typography.spec.js +198 -6
- package/es/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1235 -2
- package/es/Typography/css/Typography.module.css +4 -0
- package/es/Typography/css/cssJSLogic.js +53 -21
- package/es/Typography/props/defaultProps.js +4 -3
- package/es/Typography/props/propTypes.js +68 -26
- package/es/Typography/utils/textHighlighter.js +4 -2
- package/es/common/avatarsizes.module.css +16 -16
- package/es/common/common.module.css +1 -1
- package/es/shared/ArrowIcon/ArrowIcon.module.css +3 -2
- package/es/shared/InputFieldLine/InputFieldLine.module.css +2 -2
- package/es/v1/Button/Button.js +201 -0
- package/es/v1/Button/README.md +110 -0
- package/es/v1/Button/__tests__/Button.spec.js +272 -0
- package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1160 -0
- package/es/v1/Button/_shared/Loader/Loader.js +33 -0
- package/es/v1/Button/_shared/Loader/Loader_v1.module.css +42 -0
- package/es/v1/Button/_shared/Loader/__tests__/Loader.spec.js +21 -0
- package/es/v1/Button/_shared/Loader/__tests__/__snapshots__/Loader.spec.js.snap +49 -0
- package/es/v1/Button/_shared/Loader/props/defaultProps.js +4 -0
- package/es/v1/Button/_shared/Loader/props/propTypes.js +7 -0
- package/es/v1/Button/_shared/SuccessTick/SuccessTick.js +25 -0
- package/es/v1/Button/_shared/SuccessTick/SuccessTick_v1.module.css +21 -0
- package/es/v1/Button/_shared/SuccessTick/__tests__/SuccessTick.spec.js +21 -0
- package/es/v1/Button/_shared/SuccessTick/__tests__/__snapshots__/SuccessTick.spec.js.snap +31 -0
- package/es/v1/Button/_shared/SuccessTick/props/defaultProps.js +4 -0
- package/es/v1/Button/_shared/SuccessTick/props/propTypes.js +7 -0
- package/es/v1/Button/constants/index.js +82 -0
- package/es/v1/Button/css/Button_v1.module.css +119 -0
- package/es/v1/Button/css/cssJSLogic.js +96 -0
- package/es/v1/Button/index.js +2 -0
- package/es/v1/Button/props/defaultProps.js +26 -0
- package/es/v1/Button/props/propTypes.js +43 -0
- package/es/v1/Label/__tests__/__snapshots__/Label.spec.js.snap +40 -34
- package/es/v1/Switch/css/Switch_v1.module.css +28 -28
- package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +629 -0
- package/es/v1/helpers/colorHelpers/border/borderColor.module.css +489 -0
- package/es/v1/helpers/colorHelpers/colorHelper.js +176 -0
- package/es/v1/helpers/colorHelpers/constants/index.js +79 -0
- package/es/v1/helpers/colorHelpers/index.js +4 -0
- package/es/v1/helpers/colorHelpers/paletteUtilities.README.md +415 -0
- package/es/v1/helpers/colorHelpers/text/textColor.module.css +368 -0
- package/lib/Avatar/Avatar.module.css +8 -8
- package/lib/AvatarTeam/AvatarTeam.module.css +30 -30
- package/lib/Button/css/Button.module.css +19 -19
- package/lib/Buttongroup/Buttongroup.module.css +13 -35
- package/lib/Card/Card.module.css +6 -4
- package/lib/CheckBox/CheckBox.module.css +3 -10
- package/lib/ColorSelect/_shared/ColorIndicator/ColorIndicator.module.css +4 -2
- package/lib/DateTime/DateTime.module.css +22 -35
- package/lib/DateTime/DateWidget.module.css +1 -1
- package/lib/DateTime/YearView.module.css +8 -10
- package/lib/DropBox/DropBoxElement/css/DropBoxElement.module.css +5 -4
- package/lib/DropDown/DropDown.module.css +2 -1
- package/lib/DropDown/DropDownHeading.module.css +4 -4
- package/lib/DropDown/DropDownItem.module.css +5 -12
- package/lib/DropDown/DropDownSearch.module.css +3 -3
- package/lib/DropDown/DropDownSeparator.module.css +2 -1
- package/lib/Label/Label.module.css +5 -5
- package/lib/ListItem/ListItem.js +7 -4
- package/lib/ListItem/ListItem.module.css +62 -66
- package/lib/ListItem/ListItemWithAvatar.js +7 -5
- package/lib/ListItem/ListItemWithCheckBox.js +9 -5
- package/lib/ListItem/ListItemWithIcon.js +10 -7
- package/lib/ListItem/ListItemWithRadio.js +9 -6
- package/lib/ListItem/__tests__/__snapshots__/ListItem.spec.js.snap +4 -4
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithAvatar.spec.js.snap +131 -82
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithCheckBox.spec.js.snap +432 -390
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithIcon.spec.js.snap +141 -92
- package/lib/ListItem/__tests__/__snapshots__/ListItemWithRadio.spec.js.snap +432 -390
- package/lib/ListItem/props/defaultProps.js +2 -1
- package/lib/ListItem/props/propTypes.js +4 -2
- package/lib/MultiSelect/AdvancedGroupMultiSelect.js +25 -16
- package/lib/MultiSelect/AdvancedMultiSelect.js +2 -0
- package/lib/MultiSelect/EmptyState.js +17 -2
- package/lib/MultiSelect/MobileHeader/MobileHeader.module.css +4 -3
- package/lib/MultiSelect/MultiSelect.js +4 -2
- package/lib/MultiSelect/MultiSelect.module.css +21 -34
- package/lib/MultiSelect/MultiSelectWithAvatar.js +2 -0
- package/lib/MultiSelect/SelectedOptions.module.css +6 -10
- package/lib/MultiSelect/Suggestions.js +6 -2
- package/lib/MultiSelect/__tests__/__snapshots__/AdvancedMultiSelect.spec.js.snap +10 -10
- package/lib/MultiSelect/__tests__/__snapshots__/MultiSelectHeader.spec.js.snap +34 -28
- package/lib/MultiSelect/__tests__/__snapshots__/Suggestions.spec.js.snap +20 -20
- package/lib/MultiSelect/props/defaultProps.js +2 -0
- package/lib/MultiSelect/props/propTypes.js +16 -5
- package/lib/Popup/Popup.js +13 -15
- package/lib/Radio/Radio.module.css +11 -12
- package/lib/ResponsiveDropBox/ResponsiveDropBox.module.css +1 -1
- package/lib/Ribbon/Ribbon.module.css +23 -29
- package/lib/RippleEffect/RippleEffect.module.css +55 -17
- package/lib/Select/GroupSelect.js +15 -4
- package/lib/Select/Select.js +94 -72
- package/lib/Select/Select.module.css +50 -17
- package/lib/Select/SelectWithAvatar.js +15 -4
- package/lib/Select/SelectWithIcon.js +15 -4
- package/lib/Select/__tests__/__snapshots__/Select.spec.js.snap +88 -88
- package/lib/Select/props/defaultProps.js +9 -6
- package/lib/Select/props/propTypes.js +30 -5
- package/lib/Stencils/Stencils.module.css +30 -14
- package/lib/Switch/Switch.module.css +1 -8
- package/lib/Tab/Tab.module.css +8 -15
- package/lib/Tab/Tabs.module.css +12 -22
- package/lib/Tag/Tag.module.css +21 -21
- package/lib/TextBox/TextBox.module.css +9 -9
- package/lib/TextBoxIcon/TextBoxIcon.module.css +1 -1
- package/lib/Textarea/Textarea.module.css +18 -18
- package/lib/Tooltip/Tooltip.module.css +5 -4
- package/lib/Typography/Typography.js +15 -5
- package/lib/Typography/__tests__/Typography.spec.js +284 -92
- package/lib/Typography/__tests__/__snapshots__/Typography.spec.js.snap +1235 -2
- package/lib/Typography/css/Typography.module.css +4 -0
- package/lib/Typography/css/cssJSLogic.js +38 -6
- package/lib/Typography/props/defaultProps.js +6 -3
- package/lib/Typography/props/propTypes.js +67 -23
- package/lib/Typography/utils/textHighlighter.js +6 -3
- package/lib/common/avatarsizes.module.css +16 -16
- package/lib/common/common.module.css +1 -1
- package/lib/shared/ArrowIcon/ArrowIcon.module.css +3 -2
- package/lib/shared/InputFieldLine/InputFieldLine.module.css +2 -2
- package/lib/v1/Button/Button.js +239 -0
- package/lib/v1/Button/README.md +110 -0
- package/lib/v1/Button/__tests__/Button.spec.js +293 -0
- package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1160 -0
- package/lib/v1/Button/_shared/Loader/Loader.js +43 -0
- package/lib/v1/Button/_shared/Loader/Loader_v1.module.css +42 -0
- package/lib/v1/Button/_shared/Loader/__tests__/Loader.spec.js +28 -0
- package/lib/v1/Button/_shared/Loader/__tests__/__snapshots__/Loader.spec.js.snap +49 -0
- package/lib/v1/Button/_shared/Loader/props/defaultProps.js +11 -0
- package/lib/v1/Button/_shared/Loader/props/propTypes.js +18 -0
- package/lib/v1/Button/_shared/SuccessTick/SuccessTick.js +35 -0
- package/lib/v1/Button/_shared/SuccessTick/SuccessTick_v1.module.css +21 -0
- package/lib/v1/Button/_shared/SuccessTick/__tests__/SuccessTick.spec.js +28 -0
- package/lib/v1/Button/_shared/SuccessTick/__tests__/__snapshots__/SuccessTick.spec.js.snap +31 -0
- package/lib/v1/Button/_shared/SuccessTick/props/defaultProps.js +11 -0
- package/lib/v1/Button/_shared/SuccessTick/props/propTypes.js +18 -0
- package/lib/v1/Button/constants/index.js +114 -0
- package/lib/v1/Button/css/Button_v1.module.css +119 -0
- package/lib/v1/Button/css/cssJSLogic.js +88 -0
- package/lib/v1/Button/index.js +21 -0
- package/lib/v1/Button/props/defaultProps.js +36 -0
- package/lib/v1/Button/props/propTypes.js +56 -0
- package/lib/v1/Label/__tests__/__snapshots__/Label.spec.js.snap +40 -34
- package/lib/v1/Switch/css/Switch_v1.module.css +28 -28
- package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +629 -0
- package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +489 -0
- package/lib/v1/helpers/colorHelpers/colorHelper.js +190 -0
- package/lib/v1/helpers/colorHelpers/constants/index.js +87 -0
- package/lib/v1/helpers/colorHelpers/index.js +57 -0
- package/lib/v1/helpers/colorHelpers/paletteUtilities.README.md +415 -0
- package/lib/v1/helpers/colorHelpers/text/textColor.module.css +368 -0
- package/package.json +27 -23
- package/_react-cli.config.js +0 -24
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkModifyCategory.module.css +0 -467
- package/assets/Appearance/dark/themes/blue/blue_CTA_DarkTheme.module.css +0 -36
- package/assets/Appearance/dark/themes/green/green_CTA_DarkModifyCategory.module.css +0 -467
- package/assets/Appearance/dark/themes/green/green_CTA_DarkTheme.module.css +0 -36
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkModifyCategory.module.css +0 -467
- package/assets/Appearance/dark/themes/orange/orange_CTA_DarkTheme.module.css +0 -36
- package/assets/Appearance/dark/themes/red/red_CTA_DarkModifyCategory.module.css +0 -467
- package/assets/Appearance/dark/themes/red/red_CTA_DarkTheme.module.css +0 -36
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkModifyCategory.module.css +0 -467
- package/assets/Appearance/dark/themes/yellow/yellow_CTA_DarkTheme.module.css +0 -36
- package/assets/Appearance/light/themes/blue/blue_CTA_LightModifyCategory.module.css +0 -467
- package/assets/Appearance/light/themes/blue/blue_CTA_LightTheme.module.css +0 -36
- package/assets/Appearance/light/themes/green/green_CTA_LightModifyCategory.module.css +0 -467
- package/assets/Appearance/light/themes/green/green_CTA_LightTheme.module.css +0 -36
- package/assets/Appearance/light/themes/orange/orange_CTA_LightModifyCategory.module.css +0 -467
- package/assets/Appearance/light/themes/orange/orange_CTA_LightTheme.module.css +0 -36
- package/assets/Appearance/light/themes/red/red_CTA_LightModifyCategory.module.css +0 -467
- package/assets/Appearance/light/themes/red/red_CTA_LightTheme.module.css +0 -36
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightModifyCategory.module.css +0 -467
- package/assets/Appearance/light/themes/yellow/yellow_CTA_LightTheme.module.css +0 -36
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkModifyCategory.module.css +0 -467
- package/assets/Appearance/pureDark/themes/blue/blue_CTA_PureDarkTheme.module.css +0 -36
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkModifyCategory.module.css +0 -467
- package/assets/Appearance/pureDark/themes/green/green_CTA_PureDarkTheme.module.css +0 -36
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkModifyCategory.module.css +0 -467
- package/assets/Appearance/pureDark/themes/orange/orange_CTA_PureDarkTheme.module.css +0 -36
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkModifyCategory.module.css +0 -467
- package/assets/Appearance/pureDark/themes/red/red_CTA_PureDarkTheme.module.css +0 -36
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkModifyCategory.module.css +0 -467
- package/assets/Appearance/pureDark/themes/yellow/yellow_CTA_PureDarkTheme.module.css +0 -36
- package/assets/Contrast/darkContrastLightness.module.css +0 -39
- package/assets/Contrast/lightContrastLightness.module.css +0 -39
- package/assets/Contrast/pureDarkContrastLightness.module.css +0 -39
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
# Button
|
|
2
|
+
|
|
3
|
+
A composable button component with palette-based theming, loading/success status states, and flexible icon/content slots.
|
|
4
|
+
|
|
5
|
+
## Import
|
|
6
|
+
|
|
7
|
+
```jsx
|
|
8
|
+
import Button from '@zohodesk/components/es/v1/Button/Button';
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
### Default
|
|
14
|
+
|
|
15
|
+
```jsx
|
|
16
|
+
<Button customId="saveBtn" testId="saveBtn">
|
|
17
|
+
Save changes
|
|
18
|
+
</Button>
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
### With Palette Variants
|
|
22
|
+
|
|
23
|
+
```jsx
|
|
24
|
+
<Button palette="primary">Save</Button>
|
|
25
|
+
<Button palette="danger">Delete</Button>
|
|
26
|
+
<Button palette="success">Confirm</Button>
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
### With Icon
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
<Button variant="icon" iconName="ZD-plus" iconSize={20} />
|
|
33
|
+
|
|
34
|
+
<Button variant="iconWithText" iconName="ZD-plus" iconPlacement="left">
|
|
35
|
+
Add Item
|
|
36
|
+
</Button>
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
### Loading State
|
|
40
|
+
|
|
41
|
+
```jsx
|
|
42
|
+
<Button status="loading" loaderPlacement="overlay">
|
|
43
|
+
Saving...
|
|
44
|
+
</Button>
|
|
45
|
+
|
|
46
|
+
<Button status="loading" loaderPlacement="start">
|
|
47
|
+
Loading
|
|
48
|
+
</Button>
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### Disabled / Read Only
|
|
52
|
+
|
|
53
|
+
```jsx
|
|
54
|
+
<Button isDisabled>Disabled</Button>
|
|
55
|
+
<Button isReadOnly>Read Only</Button>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## Props
|
|
59
|
+
|
|
60
|
+
| Prop | Type | Default | Description |
|
|
61
|
+
|---|---|---|---|
|
|
62
|
+
| `customId` | `string` | — | `data-id` attribute for automation |
|
|
63
|
+
| `testId` | `string` | — | `data-test-id` attribute for testing |
|
|
64
|
+
| `palette` | `oneOf: default, primary, secondary, danger, success` | `default` | Color palette |
|
|
65
|
+
| `bgAppearance` | `oneOf: filled, onHover, none` | `filled` | Background behavior |
|
|
66
|
+
| `borderAppearance` | `oneOf: default, onHover, none` | `default` | Border behavior |
|
|
67
|
+
| `variant` | `oneOf: text, icon, iconWithText` | `text` | Display variant |
|
|
68
|
+
| `size` | `oneOf: small, medium, large, full` | `medium` | Size variant |
|
|
69
|
+
| `status` | `oneOf: default, loading, success` | `default` | Status state |
|
|
70
|
+
| `loaderPlacement` | `oneOf: start, end, overlay` | `overlay` | Where loader appears |
|
|
71
|
+
| `iconName` | `string` | — | Icon name from `@zohodesk/icons` |
|
|
72
|
+
| `iconSize` | `number` | `16` | Icon size in pixels |
|
|
73
|
+
| `iconPlacement` | `oneOf: left, right` | `left` | Icon position relative to text |
|
|
74
|
+
| `paletteShade` | `oneOf: default, lighter` | `default` | Shade variant |
|
|
75
|
+
| `disabledAppearance` | `oneOf: none, dull, strike` | `dull` | Disabled visual style |
|
|
76
|
+
| `renderIcon` | `node \| func` | — | Custom icon render slot |
|
|
77
|
+
| `renderBefore` | `node \| func` | — | Slot before main content |
|
|
78
|
+
| `renderAfter` | `node \| func` | — | Slot after main content |
|
|
79
|
+
| `renderLoader` | `node \| func` | — | Custom loader render slot |
|
|
80
|
+
| `renderSuccess` | `node \| func` | — | Custom success render slot |
|
|
81
|
+
| `children` | `node` | — | Button text content |
|
|
82
|
+
| `type` | `oneOf: button, submit, reset` | `button` | HTML button type |
|
|
83
|
+
| `onClick` | `func` | — | Click event handler |
|
|
84
|
+
| `isDisabled` | `bool` | `false` | Disables the button |
|
|
85
|
+
| `isReadOnly` | `bool` | `false` | Read-only state |
|
|
86
|
+
| `isSelected` | `bool` | `false` | Selected/pressed state |
|
|
87
|
+
| `isRounded` | `bool` | `false` | Rounded border radius |
|
|
88
|
+
| `title` | `string` | — | Title/tooltip text |
|
|
89
|
+
|
|
90
|
+
## Customization
|
|
91
|
+
|
|
92
|
+
### Parts
|
|
93
|
+
|
|
94
|
+
| Part | Element | Description |
|
|
95
|
+
|---|---|---|
|
|
96
|
+
| `wrapper` | `<button>` root | The outermost button element |
|
|
97
|
+
| `text` | Typography | The text label |
|
|
98
|
+
|
|
99
|
+
### CSS Custom Properties
|
|
100
|
+
|
|
101
|
+
The `.varClass` block in `Button.module.css` defines local custom properties that size variants override:
|
|
102
|
+
|
|
103
|
+
| Property | Default | Description |
|
|
104
|
+
|---|---|---|
|
|
105
|
+
| `--local-Button-radius` | `4px` | Border radius |
|
|
106
|
+
| `--local-Button-gap` | `8px` | Content gap |
|
|
107
|
+
| `--local-Button-padding-block` | `6px` | Block padding |
|
|
108
|
+
| `--local-Button-padding-inline` | `15px` | Inline padding |
|
|
109
|
+
| `--local-Button-min-width` | `90px` | Minimum width |
|
|
110
|
+
| `--local-Button-spinner-size` | `16px` | Spinner/tick size |
|
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _react = _interopRequireDefault(require("react"));
|
|
4
|
+
|
|
5
|
+
var _react2 = require("@testing-library/react");
|
|
6
|
+
|
|
7
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
8
|
+
|
|
9
|
+
var _Button = _interopRequireDefault(require("../Button"));
|
|
10
|
+
|
|
11
|
+
require("@testing-library/jest-dom");
|
|
12
|
+
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
+
|
|
15
|
+
afterEach(function () {
|
|
16
|
+
(0, _react2.cleanup)();
|
|
17
|
+
});
|
|
18
|
+
describe('Button - Component', function () {
|
|
19
|
+
test('Should render with the basic set of default props', function () {
|
|
20
|
+
var _render = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], null)),
|
|
21
|
+
asFragment = _render.asFragment;
|
|
22
|
+
|
|
23
|
+
expect(asFragment()).toMatchSnapshot();
|
|
24
|
+
});
|
|
25
|
+
test('Should render with children', function () {
|
|
26
|
+
var _render2 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], null, "Click Me")),
|
|
27
|
+
asFragment = _render2.asFragment;
|
|
28
|
+
|
|
29
|
+
expect(asFragment()).toMatchSnapshot();
|
|
30
|
+
});
|
|
31
|
+
var palette = ['default', 'primary', 'secondary', 'danger', 'success'];
|
|
32
|
+
test.each(palette)('Should render palette of buttons - %s', function (palette) {
|
|
33
|
+
var _render3 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
34
|
+
palette: palette
|
|
35
|
+
})),
|
|
36
|
+
asFragment = _render3.asFragment;
|
|
37
|
+
|
|
38
|
+
expect(asFragment()).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
var bgAppearance = ['default', 'onHover', 'none'];
|
|
41
|
+
test.each(bgAppearance)('Should render bgAppearance of buttons - %s', function (bg) {
|
|
42
|
+
var _render4 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
43
|
+
bgAppearance: bg
|
|
44
|
+
})),
|
|
45
|
+
asFragment = _render4.asFragment;
|
|
46
|
+
|
|
47
|
+
expect(asFragment()).toMatchSnapshot();
|
|
48
|
+
});
|
|
49
|
+
var borderAppearance = ['default', 'onHover', 'none'];
|
|
50
|
+
test.each(borderAppearance)('Should render borderAppearance of buttons - %s', function (border) {
|
|
51
|
+
var _render5 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
52
|
+
borderAppearance: border
|
|
53
|
+
})),
|
|
54
|
+
asFragment = _render5.asFragment;
|
|
55
|
+
|
|
56
|
+
expect(asFragment()).toMatchSnapshot();
|
|
57
|
+
});
|
|
58
|
+
var variant = ['text', 'icon', 'iconWithText'];
|
|
59
|
+
test.each(variant)('Should render variant of buttons - %s', function (variant) {
|
|
60
|
+
var _render6 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
61
|
+
variant: variant
|
|
62
|
+
})),
|
|
63
|
+
asFragment = _render6.asFragment;
|
|
64
|
+
|
|
65
|
+
expect(asFragment()).toMatchSnapshot();
|
|
66
|
+
});
|
|
67
|
+
var size = ['small', 'medium', 'large', 'full'];
|
|
68
|
+
test.each(size)('Should render Sizes of buttons - %s', function (size) {
|
|
69
|
+
var _render7 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
70
|
+
size: size
|
|
71
|
+
})),
|
|
72
|
+
asFragment = _render7.asFragment;
|
|
73
|
+
|
|
74
|
+
expect(asFragment()).toMatchSnapshot();
|
|
75
|
+
});
|
|
76
|
+
var status = ['default', 'loading', 'success'];
|
|
77
|
+
test.each(status)('Should render Status of buttons - %s', function (status) {
|
|
78
|
+
var _render8 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
79
|
+
status: status
|
|
80
|
+
})),
|
|
81
|
+
asFragment = _render8.asFragment;
|
|
82
|
+
|
|
83
|
+
expect(asFragment()).toMatchSnapshot();
|
|
84
|
+
});
|
|
85
|
+
var loaderPlacement = ['start', 'end', 'overlay'];
|
|
86
|
+
test.each(loaderPlacement)('Should render loaderPlacement of buttons - %s', function (loaderPlacement) {
|
|
87
|
+
var _render9 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
88
|
+
status: "loading",
|
|
89
|
+
loaderPlacement: loaderPlacement
|
|
90
|
+
})),
|
|
91
|
+
asFragment = _render9.asFragment;
|
|
92
|
+
|
|
93
|
+
expect(asFragment()).toMatchSnapshot();
|
|
94
|
+
});
|
|
95
|
+
test('Should render with iconName and iconSize ', function () {
|
|
96
|
+
var _render10 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
97
|
+
variant: "icon",
|
|
98
|
+
iconName: "ZD-plus",
|
|
99
|
+
iconSize: 20
|
|
100
|
+
})),
|
|
101
|
+
asFragment = _render10.asFragment;
|
|
102
|
+
|
|
103
|
+
expect(asFragment()).toMatchSnapshot();
|
|
104
|
+
});
|
|
105
|
+
test('Should render with iconPlacement ', function () {
|
|
106
|
+
var _render11 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
107
|
+
variant: "iconWithText",
|
|
108
|
+
iconName: "ZD-plus",
|
|
109
|
+
iconPlacement: "right"
|
|
110
|
+
}, "Button")),
|
|
111
|
+
asFragment = _render11.asFragment;
|
|
112
|
+
|
|
113
|
+
expect(asFragment()).toMatchSnapshot();
|
|
114
|
+
});
|
|
115
|
+
test('Should render with renderIcon', function () {
|
|
116
|
+
var _render12 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
117
|
+
variant: "icon",
|
|
118
|
+
renderIcon: function renderIcon() {
|
|
119
|
+
return /*#__PURE__*/_react["default"].createElement("span", null, "CustomIcon");
|
|
120
|
+
}
|
|
121
|
+
})),
|
|
122
|
+
asFragment = _render12.asFragment;
|
|
123
|
+
|
|
124
|
+
expect(asFragment()).toMatchSnapshot();
|
|
125
|
+
});
|
|
126
|
+
test('Should render with renderBefore and renderAfter', function () {
|
|
127
|
+
var _render13 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
128
|
+
renderBefore: function renderBefore() {
|
|
129
|
+
return /*#__PURE__*/_react["default"].createElement("span", null, "Before");
|
|
130
|
+
},
|
|
131
|
+
renderAfter: function renderAfter() {
|
|
132
|
+
return /*#__PURE__*/_react["default"].createElement("span", null, "After");
|
|
133
|
+
}
|
|
134
|
+
}, "Button")),
|
|
135
|
+
asFragment = _render13.asFragment;
|
|
136
|
+
|
|
137
|
+
expect(asFragment()).toMatchSnapshot();
|
|
138
|
+
});
|
|
139
|
+
test('Should render with renderLoader', function () {
|
|
140
|
+
var _render14 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
141
|
+
status: "loading",
|
|
142
|
+
renderLoader: function renderLoader() {
|
|
143
|
+
return /*#__PURE__*/_react["default"].createElement("span", null, "Loading...");
|
|
144
|
+
}
|
|
145
|
+
})),
|
|
146
|
+
asFragment = _render14.asFragment;
|
|
147
|
+
|
|
148
|
+
expect(asFragment()).toMatchSnapshot();
|
|
149
|
+
});
|
|
150
|
+
test('Should render with renderSuccess', function () {
|
|
151
|
+
var _render15 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
152
|
+
status: "success",
|
|
153
|
+
renderSuccess: function renderSuccess() {
|
|
154
|
+
return /*#__PURE__*/_react["default"].createElement("span", null, "Success!");
|
|
155
|
+
}
|
|
156
|
+
})),
|
|
157
|
+
asFragment = _render15.asFragment;
|
|
158
|
+
|
|
159
|
+
expect(asFragment()).toMatchSnapshot();
|
|
160
|
+
});
|
|
161
|
+
var type = ['button', 'submit', 'reset'];
|
|
162
|
+
test.each(type)('Should render type of buttons - %s', function (type) {
|
|
163
|
+
var _render16 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
164
|
+
type: type
|
|
165
|
+
})),
|
|
166
|
+
asFragment = _render16.asFragment;
|
|
167
|
+
|
|
168
|
+
expect(asFragment()).toMatchSnapshot();
|
|
169
|
+
});
|
|
170
|
+
test('Should trigger onClick function', function () {
|
|
171
|
+
var onClick = jest.fn();
|
|
172
|
+
|
|
173
|
+
var _render17 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
174
|
+
onClick: onClick
|
|
175
|
+
})),
|
|
176
|
+
getByRole = _render17.getByRole;
|
|
177
|
+
|
|
178
|
+
_userEvent["default"].click(getByRole('button'));
|
|
179
|
+
|
|
180
|
+
expect(onClick).toHaveBeenCalled();
|
|
181
|
+
});
|
|
182
|
+
test('Should be disabled when isDisabled prop is true', function () {
|
|
183
|
+
var _render18 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
184
|
+
isDisabled: true
|
|
185
|
+
})),
|
|
186
|
+
asFragment = _render18.asFragment;
|
|
187
|
+
|
|
188
|
+
expect(asFragment()).toMatchSnapshot();
|
|
189
|
+
});
|
|
190
|
+
test('Should render with readOnly style when isReadOnly prop is true', function () {
|
|
191
|
+
var _render19 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
192
|
+
isReadOnly: true
|
|
193
|
+
})),
|
|
194
|
+
asFragment = _render19.asFragment;
|
|
195
|
+
|
|
196
|
+
expect(asFragment()).toMatchSnapshot();
|
|
197
|
+
});
|
|
198
|
+
test('Should render with selected style when isSelected prop is true', function () {
|
|
199
|
+
var _render20 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
200
|
+
isSelected: true
|
|
201
|
+
})),
|
|
202
|
+
asFragment = _render20.asFragment;
|
|
203
|
+
|
|
204
|
+
expect(asFragment()).toMatchSnapshot();
|
|
205
|
+
});
|
|
206
|
+
var shape = ['pill', 'rectangle', 'roundedRectangle'];
|
|
207
|
+
test.each(shape)('Should render shape of buttons - %s', function (shape) {
|
|
208
|
+
var _render21 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
209
|
+
shape: shape
|
|
210
|
+
})),
|
|
211
|
+
asFragment = _render21.asFragment;
|
|
212
|
+
|
|
213
|
+
expect(asFragment()).toMatchSnapshot();
|
|
214
|
+
});
|
|
215
|
+
var paletteShade = ['default', 'lighter'];
|
|
216
|
+
test.each(paletteShade)('Should render paletteShade of buttons - %s', function (shade) {
|
|
217
|
+
var _render22 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
218
|
+
paletteShade: shade
|
|
219
|
+
})),
|
|
220
|
+
asFragment = _render22.asFragment;
|
|
221
|
+
|
|
222
|
+
expect(asFragment()).toMatchSnapshot();
|
|
223
|
+
});
|
|
224
|
+
var disabledAppearance = ['none', 'dull', 'strike'];
|
|
225
|
+
test.each(disabledAppearance)('Should render disabledAppearance of buttons - %s', function (style) {
|
|
226
|
+
var _render23 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
227
|
+
isDisabled: true,
|
|
228
|
+
disabledAppearance: style
|
|
229
|
+
})),
|
|
230
|
+
asFragment = _render23.asFragment;
|
|
231
|
+
|
|
232
|
+
expect(asFragment()).toMatchSnapshot();
|
|
233
|
+
});
|
|
234
|
+
test('Should render with title attribute', function () {
|
|
235
|
+
var _render24 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
236
|
+
title: "Button test title"
|
|
237
|
+
})),
|
|
238
|
+
asFragment = _render24.asFragment;
|
|
239
|
+
|
|
240
|
+
expect(asFragment()).toMatchSnapshot();
|
|
241
|
+
});
|
|
242
|
+
test('Should apply customClass to wrapper and text', function () {
|
|
243
|
+
var _render25 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
244
|
+
customClass: {
|
|
245
|
+
wrapper: 'customButtonClass',
|
|
246
|
+
text: 'customTextClass'
|
|
247
|
+
}
|
|
248
|
+
}, "Button")),
|
|
249
|
+
asFragment = _render25.asFragment;
|
|
250
|
+
|
|
251
|
+
expect(asFragment()).toMatchSnapshot();
|
|
252
|
+
});
|
|
253
|
+
test('Should apply customProps to wrapper, text and icon', function () {
|
|
254
|
+
var _render26 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
255
|
+
variant: "iconWithText",
|
|
256
|
+
iconName: "check",
|
|
257
|
+
customProps: {
|
|
258
|
+
wrapper: {
|
|
259
|
+
'data-wrapper': 'wrapperProps'
|
|
260
|
+
},
|
|
261
|
+
text: {
|
|
262
|
+
'data-text': 'textProps'
|
|
263
|
+
},
|
|
264
|
+
icon: {
|
|
265
|
+
'data-icon': 'iconProps'
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
}, "Button")),
|
|
269
|
+
asFragment = _render26.asFragment;
|
|
270
|
+
|
|
271
|
+
expect(asFragment()).toMatchSnapshot();
|
|
272
|
+
});
|
|
273
|
+
test('Should render with customId and testId', function () {
|
|
274
|
+
var _render27 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
275
|
+
customId: "customIdValue",
|
|
276
|
+
testId: "testIdValue"
|
|
277
|
+
})),
|
|
278
|
+
asFragment = _render27.asFragment;
|
|
279
|
+
|
|
280
|
+
expect(asFragment()).toMatchSnapshot();
|
|
281
|
+
});
|
|
282
|
+
test('Should apply a11yAttributes to the button', function () {
|
|
283
|
+
var _render28 = (0, _react2.render)( /*#__PURE__*/_react["default"].createElement(_Button["default"], {
|
|
284
|
+
a11yAttributes: {
|
|
285
|
+
'aria-label': 'Smart Button',
|
|
286
|
+
'aria-describedby': 'button-description'
|
|
287
|
+
}
|
|
288
|
+
}, "Button")),
|
|
289
|
+
asFragment = _render28.asFragment;
|
|
290
|
+
|
|
291
|
+
expect(asFragment()).toMatchSnapshot();
|
|
292
|
+
});
|
|
293
|
+
});
|