@zohodesk/components 1.0.0-temp-260 → 1.0.0-temp-259.3
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/CHANGELOG.md +4 -0
- package/assets/Appearance/dark/mode/Component_v1_DarkMode.module.css +5 -20
- package/assets/Appearance/light/mode/Component_v1_LightMode.module.css +5 -20
- package/assets/Appearance/pureDark/mode/Component_v1_PureDarkMode.module.css +5 -20
- package/es/v1/Button/Button.js +160 -107
- package/es/v1/Button/README.md +106 -42
- package/es/v1/Button/__tests__/Button.spec.js +138 -47
- package/es/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1105 -332
- package/es/v1/Button/constants/index.js +26 -20
- package/es/v1/Button/constants/presets.js +149 -0
- package/es/v1/Button/css/Button_v1.module.css +33 -16
- package/es/v1/Button/css/cssJSLogic.js +56 -28
- package/es/v1/Button/props/defaultProps.js +2 -6
- package/es/v1/Button/props/propTypes.js +26 -8
- package/es/v1/helpers/colorHelpers/__tests__/colorHelper.spec.js +357 -0
- package/es/v1/helpers/colorHelpers/background/backgroundColor.module.css +40 -40
- package/es/v1/helpers/colorHelpers/border/borderColor.module.css +25 -25
- package/es/v1/helpers/colorHelpers/colorHelper.js +117 -139
- package/es/v1/helpers/colorHelpers/constants/index.js +45 -4
- package/es/v1/helpers/colorHelpers/index.js +0 -1
- package/es/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
- package/lib/v1/Button/Button.js +179 -119
- package/lib/v1/Button/README.md +106 -42
- package/lib/v1/Button/__tests__/Button.spec.js +194 -87
- package/lib/v1/Button/__tests__/__snapshots__/Button.spec.js.snap +1105 -332
- package/lib/v1/Button/constants/index.js +31 -28
- package/lib/v1/Button/constants/presets.js +167 -0
- package/lib/v1/Button/css/Button_v1.module.css +33 -16
- package/lib/v1/Button/css/cssJSLogic.js +42 -19
- package/lib/v1/Button/props/defaultProps.js +1 -5
- package/lib/v1/Button/props/propTypes.js +41 -7
- package/lib/v1/helpers/colorHelpers/__tests__/colorHelper.spec.js +363 -0
- package/lib/v1/helpers/colorHelpers/background/backgroundColor.module.css +40 -40
- package/lib/v1/helpers/colorHelpers/border/borderColor.module.css +25 -25
- package/lib/v1/helpers/colorHelpers/colorHelper.js +127 -153
- package/lib/v1/helpers/colorHelpers/constants/index.js +45 -4
- package/lib/v1/helpers/colorHelpers/index.js +2 -24
- package/lib/v1/helpers/colorHelpers/text/textColor.module.css +35 -35
- package/package.json +4 -4
- package/es/AdvancedPopup/AdvancedPopup.js +0 -105
- package/lib/AdvancedPopup/AdvancedPopup.js +0 -122
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
export const PALETTE = {
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
BRAND: 'brand',
|
|
3
|
+
BRAND_LIGHTER: 'brandLighter',
|
|
4
|
+
INFO: 'info',
|
|
5
|
+
INFO_LIGHTER: 'infoLighter',
|
|
4
6
|
SECONDARY: 'secondary',
|
|
7
|
+
SECONDARY_LIGHTER: 'secondaryLighter',
|
|
5
8
|
DANGER: 'danger',
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
NONE: 'none'
|
|
9
|
+
DANGER_LIGHTER: 'dangerLighter',
|
|
10
|
+
SUCCESS: 'success',
|
|
11
|
+
SUCCESS_LIGHTER: 'successLighter',
|
|
12
|
+
WARNING: 'warning',
|
|
13
|
+
WARNING_LIGHTER: 'warningLighter'
|
|
12
14
|
};
|
|
13
|
-
export const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
export const APPEARANCE = {
|
|
16
|
+
BORDER: 'border',
|
|
17
|
+
TEXT: 'text',
|
|
18
|
+
BG: 'bg'
|
|
17
19
|
};
|
|
18
20
|
export const VARIANT = {
|
|
19
21
|
TEXT: 'text',
|
|
@@ -40,10 +42,6 @@ export const ICON_PLACEMENT = {
|
|
|
40
42
|
LEFT: 'left',
|
|
41
43
|
RIGHT: 'right'
|
|
42
44
|
};
|
|
43
|
-
export const PALETTE_SHADE = {
|
|
44
|
-
DEFAULT: 'default',
|
|
45
|
-
LIGHTER: 'lighter'
|
|
46
|
-
};
|
|
47
45
|
export const SHAPE = {
|
|
48
46
|
PILL: 'pill',
|
|
49
47
|
RECTANGLE: 'rectangle',
|
|
@@ -67,16 +65,24 @@ export const TYPOGRAPHY_SIZE_MAP = {
|
|
|
67
65
|
};
|
|
68
66
|
/** Default values referenced by both defaultProps and cssJSLogic */
|
|
69
67
|
|
|
70
|
-
export const
|
|
71
|
-
|
|
72
|
-
|
|
68
|
+
export const DEFAULT_APPEARANCE = {
|
|
69
|
+
bg: true,
|
|
70
|
+
text: true
|
|
71
|
+
};
|
|
72
|
+
export const DEFAULT_HOVER_APPEARANCE = {
|
|
73
|
+
bg: true,
|
|
74
|
+
text: true
|
|
75
|
+
};
|
|
76
|
+
export const DEFAULT_SELECTED_APPEARANCE = {
|
|
77
|
+
bg: true,
|
|
78
|
+
text: true
|
|
79
|
+
};
|
|
73
80
|
export const DEFAULT_VARIANT = VARIANT.TEXT;
|
|
74
81
|
export const DEFAULT_SIZE = SIZE.MEDIUM;
|
|
75
82
|
export const DEFAULT_STATUS = STATUS.DEFAULT;
|
|
76
83
|
export const DEFAULT_LOADER_PLACEMENT = LOADER_PLACEMENT.OVERLAY;
|
|
77
84
|
export const DEFAULT_ICON_PLACEMENT = ICON_PLACEMENT.LEFT;
|
|
78
85
|
export const DEFAULT_ICON_SIZE = 16;
|
|
79
|
-
export const DEFAULT_PALETTE_SHADE = PALETTE_SHADE.DEFAULT;
|
|
80
86
|
export const DEFAULT_SHAPE = SHAPE.ROUNDED_RECTANGLE;
|
|
81
87
|
export const DEFAULT_DISABLED_APPEARANCE = DISABLED_APPEARANCE.DULL;
|
|
82
88
|
export const DEFAULT_BUTTON_TYPE = BUTTON_TYPE.BUTTON;
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/** Button appearance presets */
|
|
2
|
+
export const BRAND_GHOST = {
|
|
3
|
+
palette: 'brand',
|
|
4
|
+
appearance: {
|
|
5
|
+
bg: false,
|
|
6
|
+
border: true
|
|
7
|
+
},
|
|
8
|
+
hoverAppearance: {
|
|
9
|
+
bg: false,
|
|
10
|
+
border: true
|
|
11
|
+
},
|
|
12
|
+
selectedAppearance: {
|
|
13
|
+
bg: false,
|
|
14
|
+
border: true
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
export const BRAND_TEXT_ONLY = {
|
|
18
|
+
palette: 'brand',
|
|
19
|
+
appearance: {
|
|
20
|
+
bg: false
|
|
21
|
+
},
|
|
22
|
+
hoverAppearance: {
|
|
23
|
+
bg: false
|
|
24
|
+
},
|
|
25
|
+
selectedAppearance: {
|
|
26
|
+
bg: false
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
export const BRAND_TINTED_OUTLINE = {
|
|
30
|
+
palette: 'brandLighter',
|
|
31
|
+
appearance: {
|
|
32
|
+
border: true
|
|
33
|
+
},
|
|
34
|
+
hoverAppearance: {
|
|
35
|
+
border: true
|
|
36
|
+
},
|
|
37
|
+
selectedAppearance: {
|
|
38
|
+
border: true
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
export const SUCCESS_GHOST = {
|
|
42
|
+
palette: 'success',
|
|
43
|
+
appearance: {
|
|
44
|
+
bg: false,
|
|
45
|
+
border: true
|
|
46
|
+
},
|
|
47
|
+
hoverAppearance: {
|
|
48
|
+
bg: false,
|
|
49
|
+
border: true
|
|
50
|
+
},
|
|
51
|
+
selectedAppearance: {
|
|
52
|
+
bg: false,
|
|
53
|
+
border: true
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
export const SUCCESS_TEXT_ONLY = {
|
|
57
|
+
palette: 'success',
|
|
58
|
+
appearance: {
|
|
59
|
+
bg: false
|
|
60
|
+
},
|
|
61
|
+
hoverAppearance: {
|
|
62
|
+
bg: false
|
|
63
|
+
},
|
|
64
|
+
selectedAppearance: {
|
|
65
|
+
bg: false
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
export const SUCCESS_TINTED_OUTLINE = {
|
|
69
|
+
palette: 'successLighter',
|
|
70
|
+
appearance: {
|
|
71
|
+
border: true
|
|
72
|
+
},
|
|
73
|
+
hoverAppearance: {
|
|
74
|
+
border: true
|
|
75
|
+
},
|
|
76
|
+
selectedAppearance: {
|
|
77
|
+
border: true
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
export const SECONDARY_GHOST_BRAND_TINTED_ONSELECT = {
|
|
81
|
+
palette: 'secondary',
|
|
82
|
+
appearance: {
|
|
83
|
+
bg: false,
|
|
84
|
+
border: true,
|
|
85
|
+
text: 'black'
|
|
86
|
+
},
|
|
87
|
+
hoverAppearance: {
|
|
88
|
+
bg: false,
|
|
89
|
+
border: true,
|
|
90
|
+
text: 'black'
|
|
91
|
+
},
|
|
92
|
+
selectedAppearance: {
|
|
93
|
+
bg: 'brandLighter',
|
|
94
|
+
border: 'brandLighter',
|
|
95
|
+
text: 'black'
|
|
96
|
+
}
|
|
97
|
+
};
|
|
98
|
+
export const BLACK_TEXT_BRAND_ONHOVER = {
|
|
99
|
+
palette: 'brand',
|
|
100
|
+
appearance: {
|
|
101
|
+
bg: false,
|
|
102
|
+
text: 'black'
|
|
103
|
+
},
|
|
104
|
+
hoverAppearance: {
|
|
105
|
+
bg: false
|
|
106
|
+
},
|
|
107
|
+
selectedAppearance: {
|
|
108
|
+
bg: false
|
|
109
|
+
}
|
|
110
|
+
};
|
|
111
|
+
export const BRAND_BG_ONSELECT = {
|
|
112
|
+
palette: 'brand',
|
|
113
|
+
appearance: {
|
|
114
|
+
bg: false,
|
|
115
|
+
border: true
|
|
116
|
+
},
|
|
117
|
+
hoverAppearance: {
|
|
118
|
+
bg: false,
|
|
119
|
+
border: true
|
|
120
|
+
}
|
|
121
|
+
};
|
|
122
|
+
export const BRAND_TEXT_TINTED_HOVER = {
|
|
123
|
+
palette: 'brandLighter',
|
|
124
|
+
appearance: {
|
|
125
|
+
bg: false
|
|
126
|
+
},
|
|
127
|
+
hoverAppearance: {
|
|
128
|
+
bg: true
|
|
129
|
+
},
|
|
130
|
+
selectedAppearance: {
|
|
131
|
+
border: true,
|
|
132
|
+
bg: true
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
export const BRAND_TEXT_TINTED_DANGER_HOVER = {
|
|
136
|
+
palette: 'brandLighter',
|
|
137
|
+
appearance: {
|
|
138
|
+
bg: false
|
|
139
|
+
},
|
|
140
|
+
hoverAppearance: {
|
|
141
|
+
bg: 'dangerLighter',
|
|
142
|
+
text: 'danger'
|
|
143
|
+
},
|
|
144
|
+
selectedAppearance: {
|
|
145
|
+
border: 'dangerLighter',
|
|
146
|
+
text: 'danger',
|
|
147
|
+
bg: 'dangerLighter'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
@@ -5,13 +5,15 @@
|
|
|
5
5
|
--local-button-gap: var(--zd_size8);
|
|
6
6
|
--local-button-padding-block: var(--zd_size6);
|
|
7
7
|
--local-button-padding-inline: var(--zd_size15);
|
|
8
|
-
--local-button-font-size: var(--zd_font_size13);
|
|
9
8
|
--local-loader-size: 16px;
|
|
10
9
|
--local-tick-size: 16px;
|
|
11
10
|
--local-button-height: auto;
|
|
12
11
|
--local-button-width: auto;
|
|
13
|
-
--local-button-
|
|
14
|
-
--local-button-
|
|
12
|
+
--local-button-min-width: var(--zd_size90);
|
|
13
|
+
--local-button-overlay-opacity: 0.4;
|
|
14
|
+
--local-button-transition-duration: var(--zd_transition2);
|
|
15
|
+
--local-button-cursor: pointer;
|
|
16
|
+
--local-button-strike-color: currentColor;
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
.button {
|
|
@@ -19,19 +21,20 @@
|
|
|
19
21
|
composes: posrel pointer from '../../../common/common.module.css';
|
|
20
22
|
padding-block: var(--local-button-padding-block);
|
|
21
23
|
padding-inline: var(--local-button-padding-inline);
|
|
22
|
-
font-size: var(--local-button-font-size);
|
|
23
24
|
height: var(--local-button-height);
|
|
24
25
|
width: var(--local-button-width);
|
|
26
|
+
min-width: var(--local-button-min-width);
|
|
25
27
|
border-radius: var(--local-button-radius);
|
|
26
28
|
border-style: var(--local-button-border-style);
|
|
27
29
|
border-width: var(--local-button-border-width);
|
|
28
30
|
transition-duration: var(--local-button-transition-duration);
|
|
29
31
|
transition-timing-function: ease;
|
|
32
|
+
cursor: var(--local-button-cursor);
|
|
30
33
|
background-image: none;
|
|
31
34
|
}
|
|
32
35
|
|
|
33
36
|
.disabledPointer {
|
|
34
|
-
cursor: not-allowed;
|
|
37
|
+
--local-button-cursor: not-allowed;
|
|
35
38
|
}
|
|
36
39
|
|
|
37
40
|
.disabledOpac {
|
|
@@ -39,7 +42,16 @@
|
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
.loading {
|
|
42
|
-
cursor: progress;
|
|
45
|
+
--local-button-cursor: progress;
|
|
46
|
+
composes: disabledOpac;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
.variantIcon {
|
|
50
|
+
--local-button-min-width: var(--zd_size28);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
.variantIconWithText {
|
|
54
|
+
--local-button-min-width: var(--zd_size118);
|
|
43
55
|
}
|
|
44
56
|
|
|
45
57
|
.sizeSmall {
|
|
@@ -68,6 +80,14 @@
|
|
|
68
80
|
--local-button-width: 100%;
|
|
69
81
|
}
|
|
70
82
|
|
|
83
|
+
.sizeSmall.variantText {
|
|
84
|
+
--local-button-min-width: var(--zd_size50);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
.sizeSmall.variantIconWithText {
|
|
88
|
+
--local-button-min-width: var(--zd_size78);
|
|
89
|
+
}
|
|
90
|
+
|
|
71
91
|
.shapeRoundedRectangle {
|
|
72
92
|
--local-button-radius: 4px;
|
|
73
93
|
}
|
|
@@ -80,9 +100,11 @@
|
|
|
80
100
|
--local-button-radius: 0;
|
|
81
101
|
}
|
|
82
102
|
|
|
83
|
-
.
|
|
103
|
+
.strike::after,
|
|
104
|
+
.loaderOverlay,
|
|
105
|
+
.successOverlay {
|
|
84
106
|
inset: 0 ;
|
|
85
|
-
|
|
107
|
+
position: absolute;
|
|
86
108
|
}
|
|
87
109
|
|
|
88
110
|
.contentWrapper {
|
|
@@ -98,22 +120,17 @@
|
|
|
98
120
|
|
|
99
121
|
.strike::after {
|
|
100
122
|
content: '';
|
|
101
|
-
|
|
102
|
-
inset: 0 ;
|
|
123
|
+
opacity: var(--local-button-overlay-opacity);
|
|
103
124
|
pointer-events: none;
|
|
104
125
|
border-radius: var(--local-button-radius);
|
|
105
126
|
}
|
|
106
127
|
|
|
107
128
|
[dir=ltr] .strike::after {
|
|
108
|
-
background-image: repeating-linear-gradient(120deg,
|
|
129
|
+
background-image: repeating-linear-gradient(120deg, var(--local-button-strike-color) 0 1px, var(--zd-bg-transparent) 1px 8px);
|
|
109
130
|
}
|
|
110
131
|
|
|
111
132
|
[dir=rtl] .strike::after {
|
|
112
|
-
background-image: repeating-linear-gradient(-120deg,
|
|
133
|
+
background-image: repeating-linear-gradient(-120deg, var(--local-button-strike-color) 0 1px, var(--zd-bg-transparent) 1px 8px);
|
|
113
134
|
}
|
|
114
135
|
|
|
115
|
-
.successOverlay {
|
|
116
|
-
inset: 0 ;
|
|
117
|
-
composes: posab from '../../../common/common.module.css';
|
|
118
|
-
}
|
|
119
136
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import style from "./Button_v1.module.css";
|
|
2
1
|
import compileClassNames from '@zohodesk/utils/es/compileClassNames';
|
|
2
|
+
import { DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
3
|
+
import { DISABLED_APPEARANCE, LOADER_PLACEMENT, SHAPE, SIZE, STATUS, DEFAULT_APPEARANCE, DEFAULT_HOVER_APPEARANCE, DEFAULT_SELECTED_APPEARANCE } from "../constants";
|
|
3
4
|
import buttonResetStyle from "../../../semantic/Button/semanticButton.module.css";
|
|
4
5
|
import getPaletteClasses from "../../helpers/colorHelpers/colorHelper";
|
|
5
|
-
import
|
|
6
|
-
import { DISABLED_APPEARANCE, LOADER_PLACEMENT, SHAPE, SIZE, STATUS } from "../constants";
|
|
6
|
+
import style from "./Button_v1.module.css";
|
|
7
7
|
|
|
8
8
|
const capitalize = (value = '') => value.charAt(0).toUpperCase() + value.slice(1);
|
|
9
9
|
|
|
@@ -12,13 +12,13 @@ export default function cssJSLogic({
|
|
|
12
12
|
}) {
|
|
13
13
|
const {
|
|
14
14
|
palette,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
15
|
+
appearance,
|
|
16
|
+
hoverAppearance,
|
|
17
|
+
selectedAppearance,
|
|
18
18
|
size,
|
|
19
|
+
variant,
|
|
19
20
|
status,
|
|
20
21
|
isDisabled,
|
|
21
|
-
isReadOnly,
|
|
22
22
|
isSelected,
|
|
23
23
|
shape,
|
|
24
24
|
loaderPlacement,
|
|
@@ -28,54 +28,72 @@ export default function cssJSLogic({
|
|
|
28
28
|
const {
|
|
29
29
|
wrapper: wrapperClass = '',
|
|
30
30
|
text: textClassCustom = '',
|
|
31
|
-
icon: iconClassCustom = ''
|
|
31
|
+
icon: iconClassCustom = '',
|
|
32
|
+
loader: loaderClassCustom = '',
|
|
33
|
+
success: successClassCustom = ''
|
|
32
34
|
} = customClass;
|
|
33
35
|
const isLoading = status === STATUS.LOADING;
|
|
34
36
|
const isSuccess = status === STATUS.SUCCESS;
|
|
35
|
-
const isInteractive = !isDisabled && !
|
|
37
|
+
const isInteractive = !isDisabled && !isLoading;
|
|
36
38
|
const overlayActive = (isLoading || isSuccess) && loaderPlacement === LOADER_PLACEMENT.OVERLAY;
|
|
39
|
+
const mergedAppearance = { ...DEFAULT_APPEARANCE,
|
|
40
|
+
...(appearance || {})
|
|
41
|
+
};
|
|
42
|
+
const mergedHoverAppearance = { ...DEFAULT_HOVER_APPEARANCE,
|
|
43
|
+
...(hoverAppearance || {})
|
|
44
|
+
};
|
|
45
|
+
const mergedSelectedAppearance = { ...DEFAULT_SELECTED_APPEARANCE,
|
|
46
|
+
...(selectedAppearance || {})
|
|
47
|
+
};
|
|
37
48
|
const {
|
|
38
49
|
bg,
|
|
50
|
+
selectedBg,
|
|
39
51
|
hoverBg,
|
|
40
52
|
focusBg,
|
|
41
53
|
activeBg,
|
|
42
54
|
text,
|
|
55
|
+
selectedText,
|
|
43
56
|
hoverText,
|
|
44
57
|
focusText,
|
|
45
58
|
activeText,
|
|
46
59
|
border,
|
|
60
|
+
selectedBorder,
|
|
47
61
|
hoverBorder,
|
|
48
62
|
focusBorder,
|
|
49
63
|
activeBorder
|
|
50
64
|
} = getPaletteClasses({
|
|
51
65
|
palette,
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
isSelected
|
|
66
|
+
appearance: mergedAppearance,
|
|
67
|
+
hoverAppearance: mergedHoverAppearance,
|
|
68
|
+
selectedAppearance: mergedSelectedAppearance
|
|
56
69
|
});
|
|
57
70
|
const sizeClass = size ? style[`size${capitalize(size)}`] : '';
|
|
58
71
|
const shapeClass = shape ? style[`shape${capitalize(shape)}`] : '';
|
|
72
|
+
const variantClass = variant ? style[`variant${capitalize(variant)}`] : '';
|
|
59
73
|
const shouldStrike = disabledAppearance === DISABLED_APPEARANCE.STRIKE && isDisabled;
|
|
60
74
|
const buttonClassName = compileClassNames({
|
|
61
75
|
[buttonResetStyle.buttonReset]: true,
|
|
62
76
|
[style.button]: true,
|
|
63
|
-
[bg]: !!bg,
|
|
64
|
-
[
|
|
65
|
-
[
|
|
66
|
-
[
|
|
67
|
-
[
|
|
68
|
-
[
|
|
69
|
-
[
|
|
70
|
-
[
|
|
71
|
-
[
|
|
72
|
-
[
|
|
73
|
-
[
|
|
74
|
-
[
|
|
77
|
+
[bg]: !!bg && !(isSelected && !!selectedBg),
|
|
78
|
+
[selectedBg]: !!selectedBg && isSelected,
|
|
79
|
+
[hoverBg]: !!hoverBg && isInteractive && !isSelected,
|
|
80
|
+
[focusBg]: !!focusBg && isInteractive && !isSelected,
|
|
81
|
+
[activeBg]: !!activeBg && isInteractive && !isSelected,
|
|
82
|
+
[text]: !!text && !(isSelected && !!selectedText),
|
|
83
|
+
[selectedText]: !!selectedText && isSelected,
|
|
84
|
+
[hoverText]: !!hoverText && isInteractive && !isSelected,
|
|
85
|
+
[focusText]: !!focusText && isInteractive && !isSelected,
|
|
86
|
+
[activeText]: !!activeText && isInteractive && !isSelected,
|
|
87
|
+
[border]: !!border && !(isSelected && !!selectedBorder),
|
|
88
|
+
[selectedBorder]: !!selectedBorder && isSelected,
|
|
89
|
+
[hoverBorder]: !!hoverBorder && isInteractive && !isSelected,
|
|
90
|
+
[focusBorder]: !!focusBorder && isInteractive && !isSelected,
|
|
91
|
+
[activeBorder]: !!activeBorder && isInteractive && !isSelected,
|
|
75
92
|
[sizeClass]: !!sizeClass,
|
|
76
93
|
[shapeClass]: !!shapeClass,
|
|
77
|
-
[
|
|
78
|
-
[style.
|
|
94
|
+
[variantClass]: !!variantClass,
|
|
95
|
+
[style.disabledOpac]: isDisabled && disabledAppearance === DISABLED_APPEARANCE.DULL,
|
|
96
|
+
[style.disabledPointer]: isDisabled,
|
|
79
97
|
[style.loading]: isLoading,
|
|
80
98
|
[style.strike]: shouldStrike,
|
|
81
99
|
[wrapperClass]: !!wrapperClass
|
|
@@ -89,9 +107,19 @@ export default function cssJSLogic({
|
|
|
89
107
|
return {
|
|
90
108
|
buttonClassName,
|
|
91
109
|
textClassName,
|
|
110
|
+
iconClassName,
|
|
92
111
|
contentWrapperClass: overlayActive ? style.overlayHidden : style.contentWrapper,
|
|
93
112
|
loaderOverlayClass: style.loaderOverlay,
|
|
94
113
|
successOverlayClass: style.successOverlay,
|
|
95
|
-
|
|
114
|
+
loaderClassName: {
|
|
115
|
+
wrapper: compileClassNames({
|
|
116
|
+
[loaderClassCustom]: !!loaderClassCustom
|
|
117
|
+
})
|
|
118
|
+
},
|
|
119
|
+
successClassName: {
|
|
120
|
+
wrapper: compileClassNames({
|
|
121
|
+
[successClassCustom]: !!successClassCustom
|
|
122
|
+
})
|
|
123
|
+
}
|
|
96
124
|
};
|
|
97
125
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
import { DUMMY_FUNCTION, DUMMY_OBJECT } from '@zohodesk/dotkit/es/utils/constants';
|
|
2
|
-
import {
|
|
2
|
+
import { DEFAULT_VARIANT, DEFAULT_SIZE, DEFAULT_STATUS, DEFAULT_LOADER_PLACEMENT, DEFAULT_ICON_PLACEMENT, DEFAULT_ICON_SIZE, DEFAULT_SHAPE, DEFAULT_DISABLED_APPEARANCE, DEFAULT_BUTTON_TYPE } from "../constants";
|
|
3
3
|
const defaultProps = {
|
|
4
|
-
palette:
|
|
5
|
-
bgAppearance: DEFAULT_BG_APPEARANCE,
|
|
6
|
-
borderAppearance: DEFAULT_BORDER_APPEARANCE,
|
|
4
|
+
palette: '',
|
|
7
5
|
variant: DEFAULT_VARIANT,
|
|
8
6
|
size: DEFAULT_SIZE,
|
|
9
7
|
status: DEFAULT_STATUS,
|
|
10
8
|
loaderPlacement: DEFAULT_LOADER_PLACEMENT,
|
|
11
9
|
iconPlacement: DEFAULT_ICON_PLACEMENT,
|
|
12
10
|
iconSize: DEFAULT_ICON_SIZE,
|
|
13
|
-
paletteShade: DEFAULT_PALETTE_SHADE,
|
|
14
11
|
disabledAppearance: DEFAULT_DISABLED_APPEARANCE,
|
|
15
12
|
isDisabled: false,
|
|
16
|
-
isReadOnly: false,
|
|
17
13
|
isSelected: false,
|
|
18
14
|
shape: DEFAULT_SHAPE,
|
|
19
15
|
type: DEFAULT_BUTTON_TYPE,
|
|
@@ -1,10 +1,19 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
|
-
import { PALETTE,
|
|
2
|
+
import { PALETTE, VARIANT, SIZE, STATUS, LOADER_PLACEMENT, ICON_PLACEMENT, SHAPE, DISABLED_APPEARANCE, BUTTON_TYPE } from "../constants";
|
|
3
3
|
const renderSlotType = PropTypes.oneOfType([PropTypes.node, PropTypes.func]);
|
|
4
|
+
const paletteNames = Object.values(PALETTE);
|
|
5
|
+
const bgBorderValueType = PropTypes.oneOfType([PropTypes.oneOf([...paletteNames, 'transparent']), PropTypes.bool]);
|
|
6
|
+
const textValueType = PropTypes.oneOfType([PropTypes.oneOf([...paletteNames, 'black', 'white']), PropTypes.bool]);
|
|
7
|
+
const appearanceType = PropTypes.shape({
|
|
8
|
+
bg: bgBorderValueType,
|
|
9
|
+
border: bgBorderValueType,
|
|
10
|
+
text: textValueType
|
|
11
|
+
});
|
|
4
12
|
const propTypes = {
|
|
5
13
|
palette: PropTypes.oneOf(Object.values(PALETTE)),
|
|
6
|
-
|
|
7
|
-
|
|
14
|
+
appearance: appearanceType,
|
|
15
|
+
hoverAppearance: appearanceType,
|
|
16
|
+
selectedAppearance: appearanceType,
|
|
8
17
|
variant: PropTypes.oneOf(Object.values(VARIANT)),
|
|
9
18
|
size: PropTypes.oneOf(Object.values(SIZE)),
|
|
10
19
|
status: PropTypes.oneOf(Object.values(STATUS)),
|
|
@@ -12,7 +21,6 @@ const propTypes = {
|
|
|
12
21
|
iconName: PropTypes.string,
|
|
13
22
|
iconSize: PropTypes.number,
|
|
14
23
|
iconPlacement: PropTypes.oneOf(Object.values(ICON_PLACEMENT)),
|
|
15
|
-
paletteShade: PropTypes.oneOf(Object.values(PALETTE_SHADE)),
|
|
16
24
|
disabledAppearance: PropTypes.oneOf(Object.values(DISABLED_APPEARANCE)),
|
|
17
25
|
renderIcon: renderSlotType,
|
|
18
26
|
renderBefore: renderSlotType,
|
|
@@ -23,21 +31,31 @@ const propTypes = {
|
|
|
23
31
|
type: PropTypes.oneOf(Object.values(BUTTON_TYPE)),
|
|
24
32
|
onClick: PropTypes.func,
|
|
25
33
|
isDisabled: PropTypes.bool,
|
|
26
|
-
isReadOnly: PropTypes.bool,
|
|
27
34
|
isSelected: PropTypes.bool,
|
|
28
35
|
shape: PropTypes.oneOf(Object.values(SHAPE)),
|
|
29
36
|
title: PropTypes.string,
|
|
30
37
|
customClass: PropTypes.shape({
|
|
31
38
|
wrapper: PropTypes.string,
|
|
32
|
-
text: PropTypes.string
|
|
39
|
+
text: PropTypes.string,
|
|
40
|
+
icon: PropTypes.string,
|
|
41
|
+
loader: PropTypes.string,
|
|
42
|
+
success: PropTypes.string
|
|
33
43
|
}),
|
|
34
44
|
customProps: PropTypes.shape({
|
|
35
45
|
text: PropTypes.object,
|
|
36
46
|
icon: PropTypes.object
|
|
37
47
|
}),
|
|
38
|
-
customAttributes: PropTypes.
|
|
48
|
+
customAttributes: PropTypes.shape({
|
|
49
|
+
button: PropTypes.object,
|
|
50
|
+
contentWrapper: PropTypes.object,
|
|
51
|
+
loader: PropTypes.object,
|
|
52
|
+
success: PropTypes.object,
|
|
53
|
+
icon: PropTypes.object,
|
|
54
|
+
text: PropTypes.object
|
|
55
|
+
}),
|
|
39
56
|
a11yAttributes: PropTypes.object,
|
|
40
57
|
customId: PropTypes.string,
|
|
41
|
-
testId: PropTypes.string
|
|
58
|
+
testId: PropTypes.string,
|
|
59
|
+
dataSelectorId: PropTypes.string
|
|
42
60
|
};
|
|
43
61
|
export default propTypes;
|