@toptal/picasso-button 1.0.13-alpha-fx-5263-merge-feature-branch-d124b1f9a.10 → 1.0.13-alpha-fx-4594-migrate-griditem-4e798b92d.27
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/dist-package/src/Button/Button.d.ts.map +1 -1
- package/dist-package/src/Button/Button.js +47 -39
- package/dist-package/src/Button/Button.js.map +1 -1
- package/dist-package/src/Button/styles.d.ts +45 -19
- package/dist-package/src/Button/styles.d.ts.map +1 -1
- package/dist-package/src/Button/styles.js +178 -161
- package/dist-package/src/Button/styles.js.map +1 -1
- package/dist-package/src/ButtonAction/ButtonAction.d.ts.map +1 -1
- package/dist-package/src/ButtonAction/ButtonAction.js +28 -20
- package/dist-package/src/ButtonAction/ButtonAction.js.map +1 -1
- package/dist-package/src/ButtonAction/styles.d.ts +3 -11
- package/dist-package/src/ButtonAction/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonAction/styles.js +55 -36
- package/dist-package/src/ButtonAction/styles.js.map +1 -1
- package/dist-package/src/ButtonCircular/ButtonCircular.d.ts.map +1 -1
- package/dist-package/src/ButtonCircular/ButtonCircular.js +26 -12
- package/dist-package/src/ButtonCircular/ButtonCircular.js.map +1 -1
- package/dist-package/src/ButtonCircular/styles.d.ts +3 -15
- package/dist-package/src/ButtonCircular/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonCircular/styles.js +57 -92
- package/dist-package/src/ButtonCircular/styles.js.map +1 -1
- package/dist-package/src/ButtonCompound/index.d.ts +1 -1
- package/dist-package/src/ButtonControlLabel/ButtonControlLabel.d.ts.map +1 -1
- package/dist-package/src/ButtonControlLabel/ButtonControlLabel.js +13 -4
- package/dist-package/src/ButtonControlLabel/ButtonControlLabel.js.map +1 -1
- package/dist-package/src/ButtonControlLabel/styles.d.ts +2 -2
- package/dist-package/src/ButtonControlLabel/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonControlLabel/styles.js +25 -16
- package/dist-package/src/ButtonControlLabel/styles.js.map +1 -1
- package/dist-package/src/ButtonGroup/ButtonGroup.d.ts +1 -1
- package/dist-package/src/ButtonGroup/ButtonGroup.d.ts.map +1 -1
- package/dist-package/src/ButtonGroup/ButtonGroup.js +27 -5
- package/dist-package/src/ButtonGroup/ButtonGroup.js.map +1 -1
- package/dist-package/src/ButtonGroup/styles.d.ts +2 -1
- package/dist-package/src/ButtonGroup/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonGroup/styles.js +47 -20
- package/dist-package/src/ButtonGroup/styles.js.map +1 -1
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.d.ts +1 -1
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.d.ts.map +1 -1
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.js +12 -17
- package/dist-package/src/ButtonGroupItem/ButtonGroupItem.js.map +1 -1
- package/dist-package/src/ButtonGroupItem/styles.d.ts +3 -13
- package/dist-package/src/ButtonGroupItem/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonGroupItem/styles.js +17 -39
- package/dist-package/src/ButtonGroupItem/styles.js.map +1 -1
- package/dist-package/src/ButtonSplit/ButtonSplit.d.ts.map +1 -1
- package/dist-package/src/ButtonSplit/ButtonSplit.js +24 -28
- package/dist-package/src/ButtonSplit/ButtonSplit.js.map +1 -1
- package/dist-package/src/ButtonSplit/styles.d.ts +3 -9
- package/dist-package/src/ButtonSplit/styles.d.ts.map +1 -1
- package/dist-package/src/ButtonSplit/styles.js +50 -13
- package/dist-package/src/ButtonSplit/styles.js.map +1 -1
- package/package.json +15 -19
- package/src/Button/Button.tsx +100 -69
- package/src/Button/__snapshots__/test.tsx.snap +4 -8
- package/src/Button/styles.ts +221 -214
- package/src/Button/test.tsx +1 -3
- package/src/ButtonAction/ButtonAction.tsx +48 -36
- package/src/ButtonAction/styles.ts +57 -57
- package/src/ButtonCheckbox/__snapshots__/test.tsx.snap +3 -4
- package/src/ButtonCircular/ButtonCircular.tsx +37 -22
- package/src/ButtonCircular/styles.ts +75 -127
- package/src/ButtonControlLabel/ButtonControlLabel.tsx +16 -7
- package/src/ButtonControlLabel/styles.ts +26 -30
- package/src/ButtonGroup/ButtonGroup.tsx +44 -9
- package/src/ButtonGroup/__snapshots__/test.tsx.snap +7 -13
- package/src/ButtonGroup/styles.ts +63 -21
- package/src/ButtonGroupItem/ButtonGroupItem.tsx +15 -24
- package/src/ButtonGroupItem/styles.ts +28 -62
- package/src/ButtonRadio/__snapshots__/test.tsx.snap +3 -4
- package/src/ButtonSplit/ButtonSplit.tsx +42 -46
- package/src/ButtonSplit/__snapshots__/test.tsx.snap +9 -13
- package/src/ButtonSplit/styles.ts +56 -37
- package/dist-package/src/ButtonBase/ButtonBase.d.ts +0 -29
- package/dist-package/src/ButtonBase/ButtonBase.d.ts.map +0 -1
- package/dist-package/src/ButtonBase/ButtonBase.js +0 -78
- package/dist-package/src/ButtonBase/ButtonBase.js.map +0 -1
- package/dist-package/src/ButtonBase/index.d.ts +0 -5
- package/dist-package/src/ButtonBase/index.d.ts.map +0 -1
- package/dist-package/src/ButtonBase/index.js +0 -2
- package/dist-package/src/ButtonBase/index.js.map +0 -1
- package/dist-package/src/ButtonBase/styles.d.ts +0 -6
- package/dist-package/src/ButtonBase/styles.d.ts.map +0 -1
- package/dist-package/src/ButtonBase/styles.js +0 -29
- package/dist-package/src/ButtonBase/styles.js.map +0 -1
- package/src/ButtonBase/ButtonBase.tsx +0 -182
- package/src/ButtonBase/__snapshots__/test.tsx.snap +0 -262
- package/src/ButtonBase/index.ts +0 -5
- package/src/ButtonBase/styles.ts +0 -36
- package/src/ButtonBase/test.tsx +0 -212
package/src/Button/styles.ts
CHANGED
|
@@ -1,215 +1,222 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
|
|
3
|
-
import
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
1
|
+
import type { Theme } from '@material-ui/core/styles'
|
|
2
|
+
import { createStyles } from '@material-ui/core/styles'
|
|
3
|
+
import { alpha, outline, mix } from '@toptal/picasso-shared'
|
|
4
|
+
|
|
5
|
+
const ICON_SPACING = '0.5em'
|
|
6
|
+
|
|
7
|
+
export const createOutlineCommons = ({ palette }: Theme) => ({
|
|
8
|
+
color: palette.common.black,
|
|
9
|
+
backgroundColor: palette.common.white,
|
|
10
|
+
|
|
11
|
+
'&:hover, &$hovered': {
|
|
12
|
+
borderColor: palette.common.black,
|
|
13
|
+
},
|
|
14
|
+
|
|
15
|
+
// when we use <Button as={Link} />
|
|
16
|
+
'&&&:visited': {
|
|
17
|
+
color: palette.common.black,
|
|
18
|
+
},
|
|
19
|
+
|
|
20
|
+
'&$disabled': {
|
|
21
|
+
color: palette.grey.main,
|
|
22
|
+
borderColor: palette.grey.main,
|
|
23
|
+
backgroundColor: palette.common.white,
|
|
24
|
+
},
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
export const activeGroup = ({ palette }: Theme) => ({
|
|
28
|
+
backgroundColor: palette.grey.dark,
|
|
29
|
+
borderColor: palette.grey.dark,
|
|
30
|
+
color: palette.common.white,
|
|
31
|
+
})
|
|
32
|
+
|
|
33
|
+
export const disabledGroup = ({ palette }: Theme) => ({
|
|
34
|
+
color: palette.grey.main,
|
|
35
|
+
cursor: 'not-allowed',
|
|
36
|
+
pointerEvents: 'all',
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
export const createVariant = (mainColor: string, { palette }: Theme) => ({
|
|
40
|
+
border: 'none',
|
|
41
|
+
color: palette.common.white,
|
|
42
|
+
backgroundColor: mainColor,
|
|
43
|
+
|
|
44
|
+
'&:hover, &$hovered': {
|
|
45
|
+
backgroundColor: mix(mainColor, palette.common.white, 0.152),
|
|
46
|
+
},
|
|
47
|
+
|
|
48
|
+
'&:active, &$active': {
|
|
49
|
+
backgroundColor: mix(mainColor, palette.common.black, 0.172),
|
|
50
|
+
},
|
|
51
|
+
|
|
52
|
+
// when we use <Button as={Link} />
|
|
53
|
+
'&&&:visited': {
|
|
54
|
+
color: palette.common.white,
|
|
55
|
+
},
|
|
56
|
+
'&$disabled': {
|
|
57
|
+
backgroundColor: palette.grey.light2,
|
|
58
|
+
},
|
|
59
|
+
})
|
|
60
|
+
|
|
61
|
+
export default (theme: Theme) => {
|
|
62
|
+
const { palette, sizes, transitions, typography } = theme
|
|
63
|
+
|
|
64
|
+
return createStyles({
|
|
65
|
+
root: {
|
|
66
|
+
position: 'relative',
|
|
67
|
+
textTransform: 'none',
|
|
68
|
+
borderRadius: sizes.borderRadius.small,
|
|
69
|
+
border: `solid ${sizes.borderWidth} ${palette.grey.light2}`,
|
|
70
|
+
fontSize: '1rem',
|
|
71
|
+
transitionDuration: `${transitions.duration.short}ms`,
|
|
72
|
+
transitionTimingFunction: transitions.easing.easeOut,
|
|
73
|
+
transitionProperty: 'border, color, background',
|
|
74
|
+
boxShadow: 'none',
|
|
75
|
+
flexShrink: 0,
|
|
76
|
+
|
|
77
|
+
'&$focusVisible, &$focused': {
|
|
78
|
+
...outline(palette.primary.main),
|
|
79
|
+
},
|
|
80
|
+
|
|
81
|
+
'&+&': {
|
|
82
|
+
marginLeft: '1rem',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
content: {
|
|
86
|
+
lineHeight: '1.5em',
|
|
87
|
+
fontWeight: typography.fontWeights.semibold,
|
|
88
|
+
whiteSpace: 'nowrap',
|
|
89
|
+
},
|
|
90
|
+
loader: {
|
|
91
|
+
position: 'absolute',
|
|
92
|
+
left: '50%',
|
|
93
|
+
top: '50%',
|
|
94
|
+
transform: 'translate(-50%, -50%)',
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
// sizes
|
|
98
|
+
small: {
|
|
99
|
+
minWidth: '3.5em',
|
|
100
|
+
height: '1.5em',
|
|
101
|
+
padding: '0 0.75em',
|
|
102
|
+
|
|
103
|
+
'& $content': {
|
|
104
|
+
fontSize: typography.buttons.fontSizeSmall,
|
|
105
|
+
lineHeight: typography.buttons.lineHeightSmall,
|
|
106
|
+
},
|
|
107
|
+
|
|
108
|
+
'& $iconLeft': {
|
|
109
|
+
marginLeft: '-0.125em',
|
|
110
|
+
},
|
|
111
|
+
|
|
112
|
+
'& $iconRight': {
|
|
113
|
+
marginRight: '-0.125em',
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
medium: {
|
|
117
|
+
minWidth: '4em',
|
|
118
|
+
height: '2em',
|
|
119
|
+
padding: '0 1em',
|
|
120
|
+
|
|
121
|
+
'& $content': {
|
|
122
|
+
fontSize: typography.buttons.fontSizeMedium,
|
|
123
|
+
lineHeight: typography.buttons.lineHeightMedium,
|
|
124
|
+
},
|
|
125
|
+
|
|
126
|
+
'& $iconLeft': {
|
|
127
|
+
marginLeft: '-0.25em',
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
'& $iconRight': {
|
|
131
|
+
marginRight: '-0.25em',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
large: {
|
|
135
|
+
minWidth: '6em',
|
|
136
|
+
height: '3em',
|
|
137
|
+
padding: '0 2em',
|
|
138
|
+
|
|
139
|
+
'& $content': {
|
|
140
|
+
fontSize: typography.buttons.fontSizeLarge,
|
|
141
|
+
lineHeight: typography.buttons.lineHeightLarge,
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
'& $iconLeft': {
|
|
145
|
+
marginLeft: '-0.5em',
|
|
146
|
+
},
|
|
147
|
+
|
|
148
|
+
'& $iconRight': {
|
|
149
|
+
marginRight: '-0.5em',
|
|
150
|
+
},
|
|
151
|
+
},
|
|
152
|
+
|
|
153
|
+
// variants
|
|
154
|
+
primary: createVariant(palette.primary.main, theme),
|
|
155
|
+
negative: createVariant(palette.red.main, theme),
|
|
156
|
+
positive: createVariant(palette.green.main, theme),
|
|
157
|
+
|
|
158
|
+
secondary: {
|
|
159
|
+
...createOutlineCommons(theme),
|
|
160
|
+
'&:active, &$active': {
|
|
161
|
+
backgroundColor: palette.grey.lighter2,
|
|
162
|
+
borderColor: palette.common.black,
|
|
163
|
+
},
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
transparent: {
|
|
167
|
+
color: palette.common.white,
|
|
168
|
+
border: `solid ${sizes.borderWidth} ${alpha(palette.common.white, 0.32)}`,
|
|
169
|
+
|
|
170
|
+
// when we use <Button as={Link} />
|
|
171
|
+
'&&&:visited': {
|
|
172
|
+
color: palette.common.white,
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
'&$focusVisible, &$focused': {
|
|
176
|
+
...outline(palette.common.white),
|
|
177
|
+
},
|
|
178
|
+
|
|
179
|
+
'&:hover, &$hovered': {
|
|
180
|
+
borderColor: palette.common.white,
|
|
181
|
+
},
|
|
182
|
+
|
|
183
|
+
'&:active, &$active': {
|
|
184
|
+
backgroundColor: alpha(palette.common.white, 0.16),
|
|
185
|
+
borderColor: palette.common.white,
|
|
186
|
+
},
|
|
187
|
+
|
|
188
|
+
'&$disabled': {
|
|
189
|
+
color: alpha(palette.common.white, 0.32),
|
|
190
|
+
borderColor: alpha(palette.common.white, 0.32),
|
|
191
|
+
backgroundColor: 'initial',
|
|
192
|
+
},
|
|
193
|
+
},
|
|
194
|
+
|
|
195
|
+
// Other props
|
|
196
|
+
fullWidth: {
|
|
197
|
+
width: '100%',
|
|
198
|
+
},
|
|
199
|
+
hovered: {},
|
|
200
|
+
focused: {},
|
|
201
|
+
active: {
|
|
202
|
+
boxShadow: 'none',
|
|
203
|
+
},
|
|
204
|
+
disabled: {},
|
|
205
|
+
focusVisible: {},
|
|
206
|
+
|
|
207
|
+
// Child elements
|
|
208
|
+
icon: {
|
|
209
|
+
fontSize: '1.2em !important',
|
|
210
|
+
flex: '1 1 0%', // IE11 fix
|
|
211
|
+
},
|
|
212
|
+
iconLeft: {
|
|
213
|
+
marginRight: ICON_SPACING,
|
|
214
|
+
},
|
|
215
|
+
iconRight: {
|
|
216
|
+
marginLeft: ICON_SPACING,
|
|
217
|
+
},
|
|
218
|
+
hidden: {
|
|
219
|
+
opacity: 0,
|
|
220
|
+
},
|
|
221
|
+
})
|
|
215
222
|
}
|
package/src/Button/test.tsx
CHANGED
|
@@ -14,7 +14,7 @@ const renderButton = (
|
|
|
14
14
|
props: OmitInternalProps<Props>,
|
|
15
15
|
picassoConfig?: PicassoConfig
|
|
16
16
|
) => {
|
|
17
|
-
const { children, disabled, loading, onClick, titleCase, as
|
|
17
|
+
const { children, disabled, loading, onClick, titleCase, as } = props
|
|
18
18
|
|
|
19
19
|
return render(
|
|
20
20
|
<Button
|
|
@@ -23,7 +23,6 @@ const renderButton = (
|
|
|
23
23
|
onClick={onClick}
|
|
24
24
|
titleCase={titleCase}
|
|
25
25
|
as={as}
|
|
26
|
-
href={href}
|
|
27
26
|
>
|
|
28
27
|
{children}
|
|
29
28
|
</Button>,
|
|
@@ -120,7 +119,6 @@ describe('Button', () => {
|
|
|
120
119
|
children: 'Click me!',
|
|
121
120
|
disabled: true,
|
|
122
121
|
as: Link,
|
|
123
|
-
href: 'URL',
|
|
124
122
|
})
|
|
125
123
|
|
|
126
124
|
expect(container).toMatchSnapshot()
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import type { ReactElement, MouseEvent, ElementType
|
|
1
|
+
import type { ReactElement, MouseEvent, ElementType } from 'react'
|
|
2
2
|
import React, { forwardRef } from 'react'
|
|
3
3
|
import cx from 'classnames'
|
|
4
|
+
import type { Theme } from '@material-ui/core/styles'
|
|
5
|
+
import { makeStyles } from '@material-ui/core/styles'
|
|
4
6
|
import type {
|
|
5
7
|
BaseProps,
|
|
6
8
|
ButtonOrAnchorProps,
|
|
@@ -9,30 +11,8 @@ import type {
|
|
|
9
11
|
import { Loader } from '@toptal/picasso-loader'
|
|
10
12
|
|
|
11
13
|
import type { IconPositionType } from '../Button'
|
|
12
|
-
import {
|
|
13
|
-
import
|
|
14
|
-
|
|
15
|
-
const getIcon = ({
|
|
16
|
-
children,
|
|
17
|
-
icon,
|
|
18
|
-
iconPosition,
|
|
19
|
-
}: {
|
|
20
|
-
children: ReactNode
|
|
21
|
-
icon?: ReactElement
|
|
22
|
-
iconPosition?: IconPositionType
|
|
23
|
-
}) => {
|
|
24
|
-
if (!icon) {
|
|
25
|
-
return null
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const iconClassNames = createIconClassNames({
|
|
29
|
-
iconPosition: children && iconPosition ? iconPosition : undefined,
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
return React.cloneElement(icon, {
|
|
33
|
-
className: cx(iconClassNames, icon.props.className),
|
|
34
|
-
})
|
|
35
|
-
}
|
|
14
|
+
import { Button } from '../Button'
|
|
15
|
+
import styles from './styles'
|
|
36
16
|
|
|
37
17
|
export interface Props extends BaseProps, ButtonOrAnchorProps {
|
|
38
18
|
/** Show button in the active state (left mouse button down) */
|
|
@@ -57,6 +37,14 @@ export interface Props extends BaseProps, ButtonOrAnchorProps {
|
|
|
57
37
|
value?: string | number
|
|
58
38
|
}
|
|
59
39
|
|
|
40
|
+
// Using { index: -1 } to inject CSS link to the bottom of the head
|
|
41
|
+
// in order to prevent Button's styles to override ButtonAction's ones
|
|
42
|
+
// Related Jira issue: https://toptal-core.atlassian.net/browse/FX-1520
|
|
43
|
+
const useStyles = makeStyles<Theme>(styles, {
|
|
44
|
+
name: 'PicassoButtonAction',
|
|
45
|
+
index: -1,
|
|
46
|
+
})
|
|
47
|
+
|
|
60
48
|
const loaderIcon = <Loader size='small' variant='inherit' />
|
|
61
49
|
|
|
62
50
|
export const ButtonAction: OverridableComponent<Props> = forwardRef<
|
|
@@ -75,26 +63,50 @@ export const ButtonAction: OverridableComponent<Props> = forwardRef<
|
|
|
75
63
|
onClick,
|
|
76
64
|
...rest
|
|
77
65
|
} = props
|
|
66
|
+
const classes = useStyles()
|
|
67
|
+
|
|
68
|
+
const {
|
|
69
|
+
root: rootClass,
|
|
70
|
+
content,
|
|
71
|
+
icon: iconClassName,
|
|
72
|
+
iconLeft,
|
|
73
|
+
iconRight,
|
|
74
|
+
small,
|
|
75
|
+
} = classes
|
|
76
|
+
|
|
77
|
+
const rootClassName = cx(
|
|
78
|
+
{
|
|
79
|
+
[classes.active]: active,
|
|
80
|
+
[classes.focused]: focused,
|
|
81
|
+
[classes.hovered]: hovered,
|
|
82
|
+
[classes.disabled]: disabled,
|
|
83
|
+
[classes.loading]: loading,
|
|
84
|
+
[classes.iconless]: !icon,
|
|
85
|
+
},
|
|
86
|
+
rootClass
|
|
87
|
+
)
|
|
78
88
|
|
|
79
89
|
const usedIcon = loading ? loaderIcon : icon
|
|
80
90
|
const usedIconPosition = icon ? iconPosition : 'right'
|
|
81
91
|
|
|
82
|
-
const finalClassName = cx(createRootClassNames(props), className)
|
|
83
|
-
const finalIcon = getIcon({
|
|
84
|
-
children: rest.children,
|
|
85
|
-
icon: usedIcon,
|
|
86
|
-
iconPosition: usedIconPosition,
|
|
87
|
-
})
|
|
88
|
-
|
|
89
92
|
return (
|
|
90
|
-
<
|
|
93
|
+
<Button
|
|
91
94
|
{...rest}
|
|
92
95
|
ref={ref}
|
|
93
|
-
icon={
|
|
96
|
+
icon={usedIcon}
|
|
94
97
|
iconPosition={usedIconPosition}
|
|
95
98
|
onClick={loading ? undefined : onClick}
|
|
96
|
-
|
|
97
|
-
|
|
99
|
+
variant='secondary'
|
|
100
|
+
classes={{
|
|
101
|
+
root: rootClassName,
|
|
102
|
+
content,
|
|
103
|
+
icon: iconClassName,
|
|
104
|
+
iconLeft,
|
|
105
|
+
iconRight,
|
|
106
|
+
small,
|
|
107
|
+
}}
|
|
108
|
+
className={className}
|
|
109
|
+
size='small'
|
|
98
110
|
active={active}
|
|
99
111
|
hovered={hovered}
|
|
100
112
|
focused={focused}
|