@atlaskit/button 18.1.0 → 18.3.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.
- package/CHANGELOG.md +23 -0
- package/dist/cjs/new-button/containers/split-button/split-button.js +33 -15
- package/dist/cjs/new-button/variants/shared/use-button-base.js +9 -3
- package/dist/cjs/old-button/shared/button-base.js +1 -1
- package/dist/cjs/old-button/shared/css.js +130 -12
- package/dist/es2019/new-button/containers/split-button/split-button.js +33 -16
- package/dist/es2019/new-button/variants/shared/use-button-base.js +10 -4
- package/dist/es2019/old-button/shared/button-base.js +1 -1
- package/dist/es2019/old-button/shared/css.js +193 -61
- package/dist/esm/new-button/containers/split-button/split-button.js +34 -16
- package/dist/esm/new-button/variants/shared/use-button-base.js +10 -4
- package/dist/esm/old-button/shared/button-base.js +1 -1
- package/dist/esm/old-button/shared/css.js +130 -12
- package/dist/types/new-button/containers/split-button/split-button.d.ts +9 -3
- package/dist/types-ts4.5/new-button/containers/split-button/split-button.d.ts +9 -3
- package/package.json +4 -4
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
2
2
|
import { css } from '@emotion/react';
|
|
3
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
3
4
|
import {
|
|
4
5
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
5
6
|
gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
6
7
|
import colors from './colors';
|
|
7
8
|
const gridSize = getGridSize();
|
|
9
|
+
const HAS_DISABLED_BACKGROUND = ['default', 'primary', 'danger', 'warning'];
|
|
8
10
|
|
|
9
11
|
// ## Button layout
|
|
10
12
|
//
|
|
@@ -50,6 +52,110 @@ const innerMargin = {
|
|
|
50
52
|
content: `0 ${gridSize / 4}px`,
|
|
51
53
|
icon: `0 ${gridSize / 4}px`
|
|
52
54
|
};
|
|
55
|
+
const defaultAfterStyles = {
|
|
56
|
+
borderRadius: 'inherit',
|
|
57
|
+
inset: "var(--ds-space-0, 0px)",
|
|
58
|
+
borderStyle: 'solid',
|
|
59
|
+
borderWidth: "var(--ds-border-width, 1px)",
|
|
60
|
+
pointerEvents: 'none',
|
|
61
|
+
position: 'absolute'
|
|
62
|
+
};
|
|
63
|
+
const defaultStyles = {
|
|
64
|
+
background: "var(--ds-background-neutral-subtle, #00000000)",
|
|
65
|
+
color: "var(--ds-text, #172B4D)",
|
|
66
|
+
'&:not([disabled])::after': {
|
|
67
|
+
...defaultAfterStyles,
|
|
68
|
+
content: '""',
|
|
69
|
+
borderColor: "var(--ds-border, #091E4224)"
|
|
70
|
+
},
|
|
71
|
+
'&:hover': {
|
|
72
|
+
background: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
73
|
+
},
|
|
74
|
+
'&:active': {
|
|
75
|
+
background: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const primaryStyles = {
|
|
79
|
+
background: "var(--ds-background-brand-bold, #0C66E4)",
|
|
80
|
+
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
81
|
+
'&:hover': {
|
|
82
|
+
background: "var(--ds-background-brand-bold-hovered, #0055CC)"
|
|
83
|
+
},
|
|
84
|
+
'&:active': {
|
|
85
|
+
background: "var(--ds-background-brand-bold-pressed, #09326C)"
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
const linkStyles = {
|
|
89
|
+
background: 'transparent',
|
|
90
|
+
color: "var(--ds-link, #0C66E4)",
|
|
91
|
+
'&:hover': {
|
|
92
|
+
color: "var(--ds-link, #0C66E4)",
|
|
93
|
+
textDecoration: 'underline'
|
|
94
|
+
},
|
|
95
|
+
'&:active': {
|
|
96
|
+
color: "var(--ds-link-pressed, #0055CC)",
|
|
97
|
+
textDecoration: 'underline'
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
const subtleStyles = {
|
|
101
|
+
background: 'transparent',
|
|
102
|
+
color: "var(--ds-text-subtle, #44546F)",
|
|
103
|
+
'&:hover': {
|
|
104
|
+
background: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
105
|
+
},
|
|
106
|
+
'&:active': {
|
|
107
|
+
background: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
const subtleLinkStyles = {
|
|
111
|
+
background: 'transparent',
|
|
112
|
+
color: "var(--ds-text-subtle, #44546F)",
|
|
113
|
+
'&:hover': {
|
|
114
|
+
background: 'transparent',
|
|
115
|
+
color: "var(--ds-text-subtle, #44546F)",
|
|
116
|
+
textDecoration: 'underline'
|
|
117
|
+
},
|
|
118
|
+
'&:active': {
|
|
119
|
+
background: 'transparent',
|
|
120
|
+
color: "var(--ds-text, #172B4D)",
|
|
121
|
+
textDecoration: 'underline'
|
|
122
|
+
}
|
|
123
|
+
};
|
|
124
|
+
const warningStyles = {
|
|
125
|
+
background: "var(--ds-background-warning-bold, #F5CD47)",
|
|
126
|
+
color: "var(--ds-text-warning-inverse, #172B4D)",
|
|
127
|
+
'&:hover': {
|
|
128
|
+
background: "var(--ds-background-warning-bold-hovered, #E2B203)"
|
|
129
|
+
},
|
|
130
|
+
'&:active': {
|
|
131
|
+
background: "var(--ds-background-warning-bold-pressed, #CF9F02)"
|
|
132
|
+
}
|
|
133
|
+
};
|
|
134
|
+
const dangerStyles = {
|
|
135
|
+
background: "var(--ds-background-danger-bold, #C9372C)",
|
|
136
|
+
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
137
|
+
'&:hover': {
|
|
138
|
+
background: "var(--ds-background-danger-bold-hovered, #AE2E24)"
|
|
139
|
+
},
|
|
140
|
+
'&:active': {
|
|
141
|
+
background: "var(--ds-background-danger-bold-pressed, #5D1F1A)"
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
const selectedStyles = {
|
|
145
|
+
background: "var(--ds-background-selected, #E9F2FF)",
|
|
146
|
+
color: "var(--ds-text-selected, #0C66E4)",
|
|
147
|
+
'&:not([disabled])::after': {
|
|
148
|
+
...defaultAfterStyles,
|
|
149
|
+
content: '""',
|
|
150
|
+
borderColor: "var(--ds-border-selected, #0C66E4)"
|
|
151
|
+
}
|
|
152
|
+
};
|
|
153
|
+
const hasOverlayStyles = {
|
|
154
|
+
'&[data-has-overlay="true"]': {
|
|
155
|
+
cursor: 'default',
|
|
156
|
+
textDecoration: 'none'
|
|
157
|
+
}
|
|
158
|
+
};
|
|
53
159
|
function getColor({
|
|
54
160
|
group,
|
|
55
161
|
key,
|
|
@@ -111,7 +217,7 @@ export function getCss({
|
|
|
111
217
|
transition: 'background 0.1s ease-out, box-shadow 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38)',
|
|
112
218
|
whiteSpace: 'nowrap',
|
|
113
219
|
// dynamic styles
|
|
114
|
-
...baseColors,
|
|
220
|
+
...(!fg('platform.design-system-team.component-visual-refresh_t8zbo') && baseColors),
|
|
115
221
|
cursor: 'pointer',
|
|
116
222
|
height: heights[spacing],
|
|
117
223
|
lineHeight: lineHeights[spacing],
|
|
@@ -123,66 +229,92 @@ export function getCss({
|
|
|
123
229
|
// Note: we cannot disable pointer events when there is an overlay.
|
|
124
230
|
// That would be easy for styling, but it would start letting events through on disabled buttons
|
|
125
231
|
|
|
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
|
-
|
|
232
|
+
...(!fg('platform.design-system-team.component-visual-refresh_t8zbo') && {
|
|
233
|
+
// Disabling visited styles (just using the base colors)
|
|
234
|
+
'&:visited': {
|
|
235
|
+
...baseColors
|
|
236
|
+
},
|
|
237
|
+
'&:hover': {
|
|
238
|
+
...getColors({
|
|
239
|
+
appearance,
|
|
240
|
+
key: isSelected ? 'selected' : 'hover',
|
|
241
|
+
mode
|
|
242
|
+
}),
|
|
243
|
+
textDecoration: !isSelected && (appearance === 'link' || appearance === 'subtle-link') ? 'underline' : 'inherit',
|
|
244
|
+
// background, box-shadow
|
|
245
|
+
transitionDuration: '0s, 0.15s'
|
|
246
|
+
},
|
|
247
|
+
// giving active styles preference by listing them after focus
|
|
248
|
+
'&:active': {
|
|
249
|
+
...getColors({
|
|
250
|
+
appearance,
|
|
251
|
+
key: isSelected ? 'selected' : 'active',
|
|
252
|
+
mode
|
|
253
|
+
}),
|
|
254
|
+
// background, box-shadow
|
|
255
|
+
transitionDuration: '0s, 0s'
|
|
256
|
+
},
|
|
257
|
+
// preventDefault prevents regular active styles from applying in Firefox
|
|
258
|
+
'&[data-firefox-is-active="true"]': {
|
|
259
|
+
...getColors({
|
|
260
|
+
appearance,
|
|
261
|
+
key: isSelected ? 'selected' : 'active',
|
|
262
|
+
mode
|
|
263
|
+
}),
|
|
264
|
+
// background, box-shadow
|
|
265
|
+
transitionDuration: '0s, 0s'
|
|
266
|
+
},
|
|
267
|
+
// Giving disabled styles preference over active by listing them after.
|
|
268
|
+
// Not using '&:disabled' because :disabled is not a valid state for all element types
|
|
269
|
+
// so we are targeting the attribute
|
|
270
|
+
// Attributes have the same specificity a pseudo classes so we are overriding :disabled here
|
|
271
|
+
'&[disabled]': {
|
|
272
|
+
// always using 'disabled' even when selected
|
|
273
|
+
...getColors({
|
|
274
|
+
appearance,
|
|
275
|
+
key: 'disabled',
|
|
276
|
+
mode
|
|
277
|
+
}),
|
|
278
|
+
cursor: 'not-allowed',
|
|
279
|
+
textDecoration: 'none'
|
|
280
|
+
},
|
|
281
|
+
...hasOverlayStyles,
|
|
282
|
+
// disabling hover and active color changes when there is an overlay, but the button is not disabled
|
|
283
|
+
'&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': {
|
|
284
|
+
...getColors({
|
|
285
|
+
appearance,
|
|
286
|
+
key: isSelected ? 'selected' : 'default',
|
|
287
|
+
mode
|
|
288
|
+
})
|
|
289
|
+
}
|
|
290
|
+
}),
|
|
291
|
+
// dynamic colours for visual refresh:
|
|
292
|
+
...(fg('platform.design-system-team.component-visual-refresh_t8zbo') && (isSelected ? selectedStyles : {
|
|
293
|
+
...(appearance === 'default' && defaultStyles),
|
|
294
|
+
...(appearance === 'primary' && primaryStyles),
|
|
295
|
+
...(appearance === 'link' && linkStyles),
|
|
296
|
+
...(appearance === 'subtle' && subtleStyles),
|
|
297
|
+
...(appearance === 'subtle-link' && subtleLinkStyles),
|
|
298
|
+
...(appearance === 'warning' && warningStyles),
|
|
299
|
+
...(appearance === 'danger' && dangerStyles),
|
|
300
|
+
'&[disabled]': {
|
|
301
|
+
color: "var(--ds-text-disabled, #091E424F)",
|
|
302
|
+
backgroundColor: HAS_DISABLED_BACKGROUND.includes(appearance) ? "var(--ds-background-disabled, #091E4208)" : 'transparent',
|
|
303
|
+
cursor: 'not-allowed',
|
|
304
|
+
textDecoration: 'none',
|
|
305
|
+
'&:hovered': {
|
|
306
|
+
backgroundColor: HAS_DISABLED_BACKGROUND.includes(appearance) ? "var(--ds-background-disabled, #091E4208)" : 'transparent'
|
|
307
|
+
},
|
|
308
|
+
'&:active': {
|
|
309
|
+
backgroundColor: HAS_DISABLED_BACKGROUND.includes(appearance) ? "var(--ds-background-disabled, #091E4208)" : 'transparent'
|
|
310
|
+
}
|
|
311
|
+
},
|
|
312
|
+
...hasOverlayStyles,
|
|
313
|
+
// disabling hover and active color changes when there is an overlay, but the button is not disabled
|
|
314
|
+
'&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': {
|
|
315
|
+
background: 'inherit'
|
|
316
|
+
}
|
|
317
|
+
})),
|
|
186
318
|
'&::-moz-focus-inner': {
|
|
187
319
|
border: 0,
|
|
188
320
|
margin: 0,
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
|
|
6
6
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
7
7
|
import { css, jsx } from '@emotion/react';
|
|
8
|
-
import {
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
var heights = {
|
|
10
10
|
default: "".concat(32 / 14, "em"),
|
|
11
11
|
compact: "".concat(24 / 14, "em"),
|
|
@@ -14,10 +14,12 @@ var heights = {
|
|
|
14
14
|
import { SplitButtonContext } from './split-button-context';
|
|
15
15
|
import { getActions } from './utils';
|
|
16
16
|
var baseDividerStyles = css({
|
|
17
|
-
display: 'inline-flex',
|
|
18
17
|
width: "var(--ds-border-width, 1px)",
|
|
19
18
|
position: 'relative',
|
|
20
|
-
|
|
19
|
+
// This is 1 so it appears above buttons by default.
|
|
20
|
+
// When buttons are selected they have a zIndex of 2 applied.
|
|
21
|
+
// See use-button-base.tsx.
|
|
22
|
+
zIndex: 1
|
|
21
23
|
});
|
|
22
24
|
var defaultDividerStyles = css({
|
|
23
25
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
|
|
@@ -29,13 +31,12 @@ var compactDividerStyles = css({
|
|
|
29
31
|
});
|
|
30
32
|
var dividerDisabledStyles = css({
|
|
31
33
|
backgroundColor: "var(--ds-text-disabled, #091E4224)",
|
|
32
|
-
cursor: 'not-allowed'
|
|
34
|
+
cursor: 'not-allowed',
|
|
35
|
+
opacity: 0.51
|
|
33
36
|
});
|
|
34
|
-
var
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
backgroundColor: "var(--ds-text-subtle, #0052cc)",
|
|
38
|
-
opacity: 0.62
|
|
37
|
+
var dividerDisabledRefreshedStyles = css({
|
|
38
|
+
backgroundColor: "var(--ds-border-disabled, #091E4224)",
|
|
39
|
+
cursor: 'not-allowed'
|
|
39
40
|
});
|
|
40
41
|
var dividerAppearance = {
|
|
41
42
|
default: css({
|
|
@@ -46,7 +47,12 @@ var dividerAppearance = {
|
|
|
46
47
|
backgroundColor: "var(--ds-text-inverse, #FFF)",
|
|
47
48
|
opacity: 0.64
|
|
48
49
|
}),
|
|
49
|
-
navigation:
|
|
50
|
+
navigation: css({
|
|
51
|
+
height: '16px',
|
|
52
|
+
margin: "var(--ds-space-100, 8px)".concat(" -0.5px"),
|
|
53
|
+
backgroundColor: "var(--ds-text-subtle, #0052cc)",
|
|
54
|
+
opacity: 0.62
|
|
55
|
+
})
|
|
50
56
|
};
|
|
51
57
|
var dividerRefreshedOffsetStyles = css({
|
|
52
58
|
marginInline: "calc(0px - ".concat("var(--ds-border-width, 1px)", ")")
|
|
@@ -66,7 +72,7 @@ export var Divider = function Divider(_ref) {
|
|
|
66
72
|
return (
|
|
67
73
|
// I find it funny to provide a div for Divider
|
|
68
74
|
jsx("div", {
|
|
69
|
-
css: [baseDividerStyles, dividerHeight[spacing],
|
|
75
|
+
css: [baseDividerStyles, dividerHeight[spacing], isDisabled && (fg('platform.design-system-team.component-visual-refresh_t8zbo') ? dividerDisabledRefreshedStyles : dividerDisabledStyles), !isDisabled && dividerAppearance[appearance], fg('platform.design-system-team.component-visual-refresh_t8zbo') && dividerRefreshedOffsetStyles]
|
|
70
76
|
})
|
|
71
77
|
);
|
|
72
78
|
};
|
|
@@ -103,9 +109,11 @@ var defaultAppearanceContainerStyles = css({
|
|
|
103
109
|
*/
|
|
104
110
|
export var SplitButtonContainer = function SplitButtonContainer(_ref2) {
|
|
105
111
|
var appearance = _ref2.appearance,
|
|
106
|
-
children = _ref2.children
|
|
112
|
+
children = _ref2.children,
|
|
113
|
+
_ref2$isDisabled = _ref2.isDisabled,
|
|
114
|
+
isDisabled = _ref2$isDisabled === void 0 ? false : _ref2$isDisabled;
|
|
107
115
|
return jsx("div", {
|
|
108
|
-
css: [
|
|
116
|
+
css: [appearance === 'default' && !isDisabled && fg('platform.design-system-team.component-visual-refresh_t8zbo') && defaultAppearanceContainerStyles, splitButtonStyles]
|
|
109
117
|
}, children);
|
|
110
118
|
};
|
|
111
119
|
|
|
@@ -130,7 +138,8 @@ export var SplitButton = function SplitButton(_ref3) {
|
|
|
130
138
|
PrimaryAction = _getActions.PrimaryAction,
|
|
131
139
|
SecondaryAction = _getActions.SecondaryAction;
|
|
132
140
|
return jsx(SplitButtonContainer, {
|
|
133
|
-
appearance: appearance
|
|
141
|
+
appearance: appearance,
|
|
142
|
+
isDisabled: isDisabled
|
|
134
143
|
}, jsx(SplitButtonContext.Provider, {
|
|
135
144
|
value: {
|
|
136
145
|
appearance: appearance,
|
|
@@ -147,8 +156,16 @@ export var SplitButton = function SplitButton(_ref3) {
|
|
|
147
156
|
css: secondaryButtonStyles
|
|
148
157
|
}, SecondaryAction)));
|
|
149
158
|
};
|
|
159
|
+
// TODO: Fill in the component {description} and ensure links point to the correct {packageName} location.
|
|
160
|
+
// Remove links that the component does not have (such as usage). If there are no links remove them all.
|
|
150
161
|
/**
|
|
151
|
-
*
|
|
162
|
+
* __Split button with slots__
|
|
163
|
+
*
|
|
164
|
+
* A split button with slots {description}.
|
|
165
|
+
*
|
|
166
|
+
* - [Examples](https://atlassian.design/components/{packageName}/examples)
|
|
167
|
+
* - [Code](https://atlassian.design/components/{packageName}/code)
|
|
168
|
+
* - [Usage](https://atlassian.design/components/{packageName}/usage)
|
|
152
169
|
*/
|
|
153
170
|
export var SplitButtonWithSlots = function SplitButtonWithSlots(_ref4) {
|
|
154
171
|
var primaryAction = _ref4.primaryAction,
|
|
@@ -160,7 +177,8 @@ export var SplitButtonWithSlots = function SplitButtonWithSlots(_ref4) {
|
|
|
160
177
|
_ref4$isDisabled = _ref4.isDisabled,
|
|
161
178
|
isDisabled = _ref4$isDisabled === void 0 ? false : _ref4$isDisabled;
|
|
162
179
|
return jsx(SplitButtonContainer, {
|
|
163
|
-
appearance: appearance
|
|
180
|
+
appearance: appearance,
|
|
181
|
+
isDisabled: isDisabled
|
|
164
182
|
}, jsx(SplitButtonContext.Provider, {
|
|
165
183
|
value: {
|
|
166
184
|
appearance: appearance,
|
|
@@ -5,7 +5,7 @@ import React, { Fragment, useRef } from 'react';
|
|
|
5
5
|
import { uid } from 'react-uid';
|
|
6
6
|
import mergeRefs from '@atlaskit/ds-lib/merge-refs';
|
|
7
7
|
import useAutoFocus from '@atlaskit/ds-lib/use-auto-focus';
|
|
8
|
-
import {
|
|
8
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
9
9
|
import { Box, xcss } from '@atlaskit/primitives';
|
|
10
10
|
import * as colors from '@atlaskit/theme/colors';
|
|
11
11
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
@@ -329,6 +329,12 @@ var selectedRefreshedStyles = xcss({
|
|
|
329
329
|
color: 'color.text.selected'
|
|
330
330
|
}
|
|
331
331
|
});
|
|
332
|
+
var selectedInsideSplitButtonStyles = xcss({
|
|
333
|
+
// This is 2 so it appears above the split button divider when selected.
|
|
334
|
+
// See split-button.tsx.
|
|
335
|
+
// @ts-expect-error — We need a local zindex just for button.
|
|
336
|
+
zIndex: 2
|
|
337
|
+
});
|
|
332
338
|
var selectedInteractiveStyles = xcss({
|
|
333
339
|
':hover': {
|
|
334
340
|
// @ts-expect-error
|
|
@@ -543,7 +549,7 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
543
549
|
var isSplitButton = Boolean(splitButtonContext);
|
|
544
550
|
var isNavigationSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isNavigationSplitButton) || false;
|
|
545
551
|
var isDefaultAppearanceSplitButton = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) === 'default';
|
|
546
|
-
var appearance =
|
|
552
|
+
var appearance = isDefaultAppearanceSplitButton && fg('platform.design-system-team.component-visual-refresh_t8zbo') ? 'subtle' : (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.appearance) || propAppearance;
|
|
547
553
|
var spacing = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.spacing) || propSpacing;
|
|
548
554
|
var isDisabled = (splitButtonContext === null || splitButtonContext === void 0 ? void 0 : splitButtonContext.isDisabled) || propIsDisabled;
|
|
549
555
|
var isInteractive = !isDisabled && !isLoading;
|
|
@@ -553,13 +559,13 @@ var useButtonBase = function useButtonBase(_ref) {
|
|
|
553
559
|
useAutoFocus(localRef, autoFocus);
|
|
554
560
|
return _objectSpread({
|
|
555
561
|
ref: mergeRefs([localRef, ref]),
|
|
556
|
-
xcss: [
|
|
562
|
+
xcss: [fg('platform.design-system-team.button-tokenised-typography-styles') ? tokenizedButtonStyles : hardCodedButtonStyles, buttonStyles, appearance === 'default' && (fg('platform.design-system-team.component-visual-refresh_t8zbo') ? defaultRefreshedStyles : defaultStyles), appearance === 'default' && isInteractive && (fg('platform.design-system-team.component-visual-refresh_t8zbo') ? defaultInteractiveRefreshedStyles : defaultInteractiveStyles), appearance === 'primary' && primaryStyles, appearance === 'primary' && isInteractive && primaryInteractiveStyles, appearance === 'warning' && warningStyles, appearance === 'warning' && isInteractive && warningInteractiveStyles, appearance === 'danger' && dangerStyles, appearance === 'danger' && isInteractive && dangerInteractiveStyles, appearance === 'discovery' && discoveryStyles, appearance === 'discovery' && isInteractive && discoveryInteractiveStyles, appearance === 'subtle' && (fg('platform.design-system-team.component-visual-refresh_t8zbo') ? subtleRefreshedStyles : subtleStyles), appearance === 'subtle' && isInteractive && (fg('platform.design-system-team.component-visual-refresh_t8zbo') ? subtleInteractiveRefreshedStyles : subtleInteractiveStyles), appearance === 'link' && linkStyles, appearance === 'subtle-link' && subtleLinkStyles, !isSelected && (appearance === 'link' || appearance === 'subtle-link') ? linkDecorationStyles : linkDecorationUnsetStyles, isSelected && (fg('platform.design-system-team.component-visual-refresh_t8zbo') ? selectedRefreshedStyles : selectedStyles), isSelected && isSplitButton && selectedInsideSplitButtonStyles, isSelected && isInteractive && selectedInteractiveStyles,
|
|
557
563
|
// TODO: remove me once we kill color fallbacks
|
|
558
564
|
isSelected && appearance === 'danger' && selectedDangerStyles,
|
|
559
565
|
// TODO: remove me once we kill color fallbacks
|
|
560
566
|
isSelected && appearance === 'warning' && selectedWarningStyles,
|
|
561
567
|
// TODO: remove me once we kill color fallbacks
|
|
562
|
-
isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, spacing === 'compact' && (
|
|
568
|
+
isSelected && appearance === 'discovery' && selectedDiscoveryStyles, isDisabled && disabledStyles, isCircle && !isSplitButton && circleStyles, spacing === 'compact' && spacingCompactStyles, spacing === 'compact' && (fg('platform.design-system-team.button-tokenised-typography-styles') ? tokenizedSpacingCompactStyles : baseSpacingCompactStyles), spacing === 'none' && spacingNoneStyles, spacing === 'none' && fg('platform.design-system-team.button-tokenised-typography-styles') && tokenizedSpacingNoneStyles, spacing !== 'none' && hasIconBefore && buttonIconBeforeStyles, spacing !== 'none' && hasIconAfter && buttonIconAfterStyles, isIconButton && iconButtonStyles, isIconButton && spacing === 'compact' && iconButtonCompactStyles, shouldFitContainer && fullWidthStyles, isLoading && loadingStyles, isSplitButton && splitButtonStyles, isNavigationSplitButton && navigationSplitButtonStyles],
|
|
563
569
|
isDisabled: isEffectivelyDisabled,
|
|
564
570
|
children: /*#__PURE__*/React.createElement(Fragment, null, children, isLoading ? /*#__PURE__*/React.createElement(Box, {
|
|
565
571
|
as: "span",
|
|
@@ -125,7 +125,7 @@ export default /*#__PURE__*/React.forwardRef(function ButtonBase(props, ref) {
|
|
|
125
125
|
action: 'clicked',
|
|
126
126
|
componentName: 'button',
|
|
127
127
|
packageName: "@atlaskit/button",
|
|
128
|
-
packageVersion: "18.
|
|
128
|
+
packageVersion: "18.3.0",
|
|
129
129
|
analyticsData: analyticsContext
|
|
130
130
|
});
|
|
131
131
|
|
|
@@ -3,11 +3,13 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
|
|
|
3
3
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
4
4
|
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
|
|
5
5
|
import { css } from '@emotion/react';
|
|
6
|
+
import { fg } from '@atlaskit/platform-feature-flags';
|
|
6
7
|
import {
|
|
7
8
|
// eslint-disable-next-line @atlaskit/design-system/no-deprecated-imports
|
|
8
9
|
gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
9
10
|
import colors from './colors';
|
|
10
11
|
var gridSize = getGridSize();
|
|
12
|
+
var HAS_DISABLED_BACKGROUND = ['default', 'primary', 'danger', 'warning'];
|
|
11
13
|
|
|
12
14
|
// ## Button layout
|
|
13
15
|
//
|
|
@@ -53,6 +55,108 @@ var innerMargin = {
|
|
|
53
55
|
content: "0 ".concat(gridSize / 4, "px"),
|
|
54
56
|
icon: "0 ".concat(gridSize / 4, "px")
|
|
55
57
|
};
|
|
58
|
+
var defaultAfterStyles = {
|
|
59
|
+
borderRadius: 'inherit',
|
|
60
|
+
inset: "var(--ds-space-0, 0px)",
|
|
61
|
+
borderStyle: 'solid',
|
|
62
|
+
borderWidth: "var(--ds-border-width, 1px)",
|
|
63
|
+
pointerEvents: 'none',
|
|
64
|
+
position: 'absolute'
|
|
65
|
+
};
|
|
66
|
+
var defaultStyles = {
|
|
67
|
+
background: "var(--ds-background-neutral-subtle, #00000000)",
|
|
68
|
+
color: "var(--ds-text, #172B4D)",
|
|
69
|
+
'&:not([disabled])::after': _objectSpread(_objectSpread({}, defaultAfterStyles), {}, {
|
|
70
|
+
content: '""',
|
|
71
|
+
borderColor: "var(--ds-border, #091E4224)"
|
|
72
|
+
}),
|
|
73
|
+
'&:hover': {
|
|
74
|
+
background: "var(--ds-background-neutral-hovered, #091E4224)"
|
|
75
|
+
},
|
|
76
|
+
'&:active': {
|
|
77
|
+
background: "var(--ds-background-neutral-pressed, #091E424F)"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
var primaryStyles = {
|
|
81
|
+
background: "var(--ds-background-brand-bold, #0C66E4)",
|
|
82
|
+
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
83
|
+
'&:hover': {
|
|
84
|
+
background: "var(--ds-background-brand-bold-hovered, #0055CC)"
|
|
85
|
+
},
|
|
86
|
+
'&:active': {
|
|
87
|
+
background: "var(--ds-background-brand-bold-pressed, #09326C)"
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
var linkStyles = {
|
|
91
|
+
background: 'transparent',
|
|
92
|
+
color: "var(--ds-link, #0C66E4)",
|
|
93
|
+
'&:hover': {
|
|
94
|
+
color: "var(--ds-link, #0C66E4)",
|
|
95
|
+
textDecoration: 'underline'
|
|
96
|
+
},
|
|
97
|
+
'&:active': {
|
|
98
|
+
color: "var(--ds-link-pressed, #0055CC)",
|
|
99
|
+
textDecoration: 'underline'
|
|
100
|
+
}
|
|
101
|
+
};
|
|
102
|
+
var subtleStyles = {
|
|
103
|
+
background: 'transparent',
|
|
104
|
+
color: "var(--ds-text-subtle, #44546F)",
|
|
105
|
+
'&:hover': {
|
|
106
|
+
background: "var(--ds-background-neutral-subtle-hovered, #091E420F)"
|
|
107
|
+
},
|
|
108
|
+
'&:active': {
|
|
109
|
+
background: "var(--ds-background-neutral-subtle-pressed, #091E4224)"
|
|
110
|
+
}
|
|
111
|
+
};
|
|
112
|
+
var subtleLinkStyles = {
|
|
113
|
+
background: 'transparent',
|
|
114
|
+
color: "var(--ds-text-subtle, #44546F)",
|
|
115
|
+
'&:hover': {
|
|
116
|
+
background: 'transparent',
|
|
117
|
+
color: "var(--ds-text-subtle, #44546F)",
|
|
118
|
+
textDecoration: 'underline'
|
|
119
|
+
},
|
|
120
|
+
'&:active': {
|
|
121
|
+
background: 'transparent',
|
|
122
|
+
color: "var(--ds-text, #172B4D)",
|
|
123
|
+
textDecoration: 'underline'
|
|
124
|
+
}
|
|
125
|
+
};
|
|
126
|
+
var warningStyles = {
|
|
127
|
+
background: "var(--ds-background-warning-bold, #F5CD47)",
|
|
128
|
+
color: "var(--ds-text-warning-inverse, #172B4D)",
|
|
129
|
+
'&:hover': {
|
|
130
|
+
background: "var(--ds-background-warning-bold-hovered, #E2B203)"
|
|
131
|
+
},
|
|
132
|
+
'&:active': {
|
|
133
|
+
background: "var(--ds-background-warning-bold-pressed, #CF9F02)"
|
|
134
|
+
}
|
|
135
|
+
};
|
|
136
|
+
var dangerStyles = {
|
|
137
|
+
background: "var(--ds-background-danger-bold, #C9372C)",
|
|
138
|
+
color: "var(--ds-text-inverse, #FFFFFF)",
|
|
139
|
+
'&:hover': {
|
|
140
|
+
background: "var(--ds-background-danger-bold-hovered, #AE2E24)"
|
|
141
|
+
},
|
|
142
|
+
'&:active': {
|
|
143
|
+
background: "var(--ds-background-danger-bold-pressed, #5D1F1A)"
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
var selectedStyles = {
|
|
147
|
+
background: "var(--ds-background-selected, #E9F2FF)",
|
|
148
|
+
color: "var(--ds-text-selected, #0C66E4)",
|
|
149
|
+
'&:not([disabled])::after': _objectSpread(_objectSpread({}, defaultAfterStyles), {}, {
|
|
150
|
+
content: '""',
|
|
151
|
+
borderColor: "var(--ds-border-selected, #0C66E4)"
|
|
152
|
+
})
|
|
153
|
+
};
|
|
154
|
+
var hasOverlayStyles = {
|
|
155
|
+
'&[data-has-overlay="true"]': {
|
|
156
|
+
cursor: 'default',
|
|
157
|
+
textDecoration: 'none'
|
|
158
|
+
}
|
|
159
|
+
};
|
|
56
160
|
function getColor(_ref) {
|
|
57
161
|
var group = _ref.group,
|
|
58
162
|
key = _ref.key,
|
|
@@ -90,7 +194,7 @@ export function getCss(_ref3) {
|
|
|
90
194
|
key: isSelected ? 'selected' : 'default',
|
|
91
195
|
mode: mode
|
|
92
196
|
});
|
|
93
|
-
return _objectSpread(_objectSpread({
|
|
197
|
+
return _objectSpread(_objectSpread(_objectSpread(_objectSpread({
|
|
94
198
|
// 0px margin added to css-reset
|
|
95
199
|
alignItems: 'baseline',
|
|
96
200
|
borderWidth: 0,
|
|
@@ -110,7 +214,7 @@ export function getCss(_ref3) {
|
|
|
110
214
|
textDecoration: 'none',
|
|
111
215
|
transition: 'background 0.1s ease-out, box-shadow 0.15s cubic-bezier(0.47, 0.03, 0.49, 1.38)',
|
|
112
216
|
whiteSpace: 'nowrap'
|
|
113
|
-
}, baseColors), {}, {
|
|
217
|
+
}, !fg('platform.design-system-team.component-visual-refresh_t8zbo') && baseColors), {}, {
|
|
114
218
|
cursor: 'pointer',
|
|
115
219
|
height: heights[spacing],
|
|
116
220
|
lineHeight: lineHeights[spacing],
|
|
@@ -118,10 +222,8 @@ export function getCss(_ref3) {
|
|
|
118
222
|
verticalAlign: verticalAlign[spacing],
|
|
119
223
|
width: shouldFitContainer ? '100%' : 'auto',
|
|
120
224
|
// justifyContent required for shouldFitContainer buttons with an icon inside
|
|
121
|
-
justifyContent: 'center'
|
|
122
|
-
|
|
123
|
-
// That would be easy for styling, but it would start letting events through on disabled buttons
|
|
124
|
-
|
|
225
|
+
justifyContent: 'center'
|
|
226
|
+
}, !fg('platform.design-system-team.component-visual-refresh_t8zbo') && _objectSpread(_objectSpread({
|
|
125
227
|
// Disabling visited styles (just using the base colors)
|
|
126
228
|
'&:visited': _objectSpread({}, baseColors),
|
|
127
229
|
'&:hover': _objectSpread(_objectSpread({}, getColors({
|
|
@@ -162,17 +264,33 @@ export function getCss(_ref3) {
|
|
|
162
264
|
})), {}, {
|
|
163
265
|
cursor: 'not-allowed',
|
|
164
266
|
textDecoration: 'none'
|
|
165
|
-
})
|
|
166
|
-
|
|
167
|
-
cursor: 'default',
|
|
168
|
-
textDecoration: 'none'
|
|
169
|
-
},
|
|
267
|
+
})
|
|
268
|
+
}, hasOverlayStyles), {}, {
|
|
170
269
|
// disabling hover and active color changes when there is an overlay, but the button is not disabled
|
|
171
270
|
'&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': _objectSpread({}, getColors({
|
|
172
271
|
appearance: appearance,
|
|
173
272
|
key: isSelected ? 'selected' : 'default',
|
|
174
273
|
mode: mode
|
|
175
|
-
}))
|
|
274
|
+
}))
|
|
275
|
+
})), fg('platform.design-system-team.component-visual-refresh_t8zbo') && (isSelected ? selectedStyles : _objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread(_objectSpread({}, appearance === 'default' && defaultStyles), appearance === 'primary' && primaryStyles), appearance === 'link' && linkStyles), appearance === 'subtle' && subtleStyles), appearance === 'subtle-link' && subtleLinkStyles), appearance === 'warning' && warningStyles), appearance === 'danger' && dangerStyles), {}, {
|
|
276
|
+
'&[disabled]': {
|
|
277
|
+
color: "var(--ds-text-disabled, #091E424F)",
|
|
278
|
+
backgroundColor: HAS_DISABLED_BACKGROUND.includes(appearance) ? "var(--ds-background-disabled, #091E4208)" : 'transparent',
|
|
279
|
+
cursor: 'not-allowed',
|
|
280
|
+
textDecoration: 'none',
|
|
281
|
+
'&:hovered': {
|
|
282
|
+
backgroundColor: HAS_DISABLED_BACKGROUND.includes(appearance) ? "var(--ds-background-disabled, #091E4208)" : 'transparent'
|
|
283
|
+
},
|
|
284
|
+
'&:active': {
|
|
285
|
+
backgroundColor: HAS_DISABLED_BACKGROUND.includes(appearance) ? "var(--ds-background-disabled, #091E4208)" : 'transparent'
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
}, hasOverlayStyles), {}, {
|
|
289
|
+
// disabling hover and active color changes when there is an overlay, but the button is not disabled
|
|
290
|
+
'&[data-has-overlay="true"]:not([disabled]):hover, &[data-has-overlay="true"]:not([disabled]):active': {
|
|
291
|
+
background: 'inherit'
|
|
292
|
+
}
|
|
293
|
+
}))), {}, {
|
|
176
294
|
'&::-moz-focus-inner': {
|
|
177
295
|
border: 0,
|
|
178
296
|
margin: 0,
|