@atlaskit/flag 14.7.3 → 15.0.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 +20 -0
- package/dist/cjs/auto-dismiss-flag.js +1 -1
- package/dist/cjs/flag-actions.js +18 -37
- package/dist/cjs/flag-group.js +15 -9
- package/dist/cjs/flag.js +63 -73
- package/dist/cjs/internal/dismiss-button.js +25 -38
- package/dist/cjs/internal/expander.js +25 -26
- package/dist/cjs/internal/index.js +0 -16
- package/dist/cjs/theme.js +50 -169
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/auto-dismiss-flag.js +1 -1
- package/dist/es2019/flag-actions.js +18 -38
- package/dist/es2019/flag-group.js +14 -8
- package/dist/es2019/flag.js +63 -72
- package/dist/es2019/internal/dismiss-button.js +26 -36
- package/dist/es2019/internal/expander.js +20 -23
- package/dist/es2019/internal/index.js +0 -2
- package/dist/es2019/theme.js +47 -141
- package/dist/es2019/version.json +1 -1
- package/dist/esm/auto-dismiss-flag.js +1 -1
- package/dist/esm/flag-actions.js +18 -38
- package/dist/esm/flag-group.js +14 -8
- package/dist/esm/flag.js +63 -73
- package/dist/esm/internal/dismiss-button.js +26 -37
- package/dist/esm/internal/expander.js +21 -24
- package/dist/esm/internal/index.js +0 -2
- package/dist/esm/theme.js +49 -155
- package/dist/esm/version.json +1 -1
- package/dist/types/flag-actions.d.ts +2 -5
- package/dist/types/flag.d.ts +3 -2
- package/dist/types/internal/expander.d.ts +2 -3
- package/dist/types/internal/index.d.ts +0 -2
- package/dist/types/theme.d.ts +14 -9
- package/package.json +6 -4
- package/report.api.md +16 -8
- package/dist/cjs/internal/description.js +0 -34
- package/dist/cjs/internal/title.js +0 -30
- package/dist/es2019/internal/description.js +0 -24
- package/dist/es2019/internal/title.js +0 -20
- package/dist/esm/internal/description.js +0 -25
- package/dist/esm/internal/title.js +0 -21
- package/dist/types/internal/description.d.ts +0 -8
- package/dist/types/internal/title.d.ts +0 -6
package/dist/cjs/theme.js
CHANGED
|
@@ -3,187 +3,68 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.flagTextColorToken = exports.flagTextColor = exports.flagIconColor = exports.flagFocusRingColor = exports.flagBackgroundColor = exports.actionTextColor = exports.actionBackgroundColor = void 0;
|
|
7
7
|
|
|
8
8
|
var _colors = require("@atlaskit/theme/colors");
|
|
9
9
|
|
|
10
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
10
11
|
var flagBackgroundColor = {
|
|
11
|
-
error:
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
light: "var(--ds-background-neutral-bold, ".concat(_colors.N500, ")"),
|
|
17
|
-
dark: "var(--ds-background-neutral-bold, ".concat(_colors.N500, ")")
|
|
18
|
-
},
|
|
19
|
-
normal: {
|
|
20
|
-
light: "var(--ds-surface-overlay, ".concat(_colors.N0, ")"),
|
|
21
|
-
dark: "var(--ds-surface-overlay, ".concat(_colors.DN50, ")")
|
|
22
|
-
},
|
|
23
|
-
success: {
|
|
24
|
-
light: "var(--ds-background-success-bold, ".concat(_colors.G400, ")"),
|
|
25
|
-
dark: "var(--ds-background-success-bold, ".concat(_colors.G300, ")")
|
|
26
|
-
},
|
|
27
|
-
warning: {
|
|
28
|
-
light: "var(--ds-background-warning-bold, ".concat(_colors.Y200, ")"),
|
|
29
|
-
dark: "var(--ds-background-warning-bold, ".concat(_colors.Y300, ")")
|
|
30
|
-
}
|
|
12
|
+
error: 'danger.bold',
|
|
13
|
+
info: 'neutral.bold',
|
|
14
|
+
normal: 'elevation.surface.overlay',
|
|
15
|
+
success: 'success.bold',
|
|
16
|
+
warning: 'warning.bold'
|
|
31
17
|
};
|
|
32
|
-
|
|
33
|
-
var getFlagBackgroundColor = function getFlagBackgroundColor(appearance, mode) {
|
|
34
|
-
return flagBackgroundColor[appearance][mode];
|
|
35
|
-
}; // token set in flag.tsx instead
|
|
36
|
-
|
|
37
|
-
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
exports.getFlagBackgroundColor = getFlagBackgroundColor;
|
|
41
|
-
var flagBorderColor = _colors.N60A;
|
|
42
|
-
exports.flagBorderColor = flagBorderColor;
|
|
43
|
-
var flagShadowColor = _colors.N50A;
|
|
44
|
-
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
45
|
-
|
|
46
|
-
exports.flagShadowColor = flagShadowColor;
|
|
18
|
+
exports.flagBackgroundColor = flagBackgroundColor;
|
|
47
19
|
var flagIconColor = {
|
|
48
|
-
error:
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
light: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
|
|
54
|
-
dark: "var(--ds-icon-inverse, ".concat(_colors.DN600, ")")
|
|
55
|
-
},
|
|
56
|
-
normal: {
|
|
57
|
-
light: "var(--ds-icon-subtle, ".concat(_colors.N500, ")"),
|
|
58
|
-
dark: "var(--ds-icon-subtle, ".concat(_colors.DN600, ")")
|
|
59
|
-
},
|
|
60
|
-
success: {
|
|
61
|
-
light: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
|
|
62
|
-
dark: "var(--ds-icon-inverse, ".concat(_colors.DN40, ")")
|
|
63
|
-
},
|
|
64
|
-
warning: {
|
|
65
|
-
light: "var(--ds-icon-warning-inverse, ".concat(_colors.N700, ")"),
|
|
66
|
-
dark: "var(--ds-icon-warning-inverse, ".concat(_colors.DN40, ")")
|
|
67
|
-
}
|
|
68
|
-
};
|
|
69
|
-
var flagTextColor = {
|
|
70
|
-
error: {
|
|
71
|
-
light: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
72
|
-
dark: "var(--ds-text-inverse, ".concat(_colors.DN40, ")")
|
|
73
|
-
},
|
|
74
|
-
info: {
|
|
75
|
-
light: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
76
|
-
dark: "var(--ds-text-inverse, ".concat(_colors.DN600, ")")
|
|
77
|
-
},
|
|
78
|
-
normal: {
|
|
79
|
-
light: "var(--ds-text-subtle, ".concat(_colors.N500, ")"),
|
|
80
|
-
dark: "var(--ds-text-subtle, ".concat(_colors.DN600, ")")
|
|
81
|
-
},
|
|
82
|
-
success: {
|
|
83
|
-
light: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
84
|
-
dark: "var(--ds-text-inverse, ".concat(_colors.DN40, ")")
|
|
85
|
-
},
|
|
86
|
-
warning: {
|
|
87
|
-
light: "var(--ds-text-warning-inverse, ".concat(_colors.N700, ")"),
|
|
88
|
-
dark: "var(--ds-text-warning-inverse, ".concat(_colors.DN40, ")")
|
|
89
|
-
}
|
|
20
|
+
error: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
|
|
21
|
+
info: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
|
|
22
|
+
normal: "var(--ds-icon-subtle, ".concat(_colors.N500, ")"),
|
|
23
|
+
success: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
|
|
24
|
+
warning: "var(--ds-icon-warning-inverse, ".concat(_colors.N700, ")")
|
|
90
25
|
};
|
|
26
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
91
27
|
|
|
92
|
-
|
|
93
|
-
|
|
28
|
+
exports.flagIconColor = flagIconColor;
|
|
29
|
+
var flagTextColor = {
|
|
30
|
+
error: 'inverse',
|
|
31
|
+
info: 'inverse',
|
|
32
|
+
normal: 'subtle',
|
|
33
|
+
success: 'inverse',
|
|
34
|
+
warning: 'warning.inverse'
|
|
94
35
|
};
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
var
|
|
99
|
-
|
|
36
|
+
exports.flagTextColor = flagTextColor;
|
|
37
|
+
var flagTextColorToken = {
|
|
38
|
+
error: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
39
|
+
info: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
40
|
+
normal: "var(--ds-text-subtle, ".concat(_colors.N500, ")"),
|
|
41
|
+
success: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
42
|
+
warning: "var(--ds-text-warning-inverse, ".concat(_colors.N700, ")")
|
|
100
43
|
};
|
|
101
|
-
|
|
102
|
-
exports.getFlagIconColor = getFlagIconColor;
|
|
44
|
+
exports.flagTextColorToken = flagTextColorToken;
|
|
103
45
|
var flagFocusRingColor = {
|
|
104
|
-
error:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
dark: "var(--ds-border-focused, ".concat(_colors.N40, ")")
|
|
111
|
-
},
|
|
112
|
-
normal: {
|
|
113
|
-
light: "var(--ds-border-focused, ".concat(_colors.B100, ")"),
|
|
114
|
-
dark: "var(--ds-border-focused, ".concat(_colors.B100, ")")
|
|
115
|
-
},
|
|
116
|
-
success: {
|
|
117
|
-
light: "var(--ds-border-focused, ".concat(_colors.N40, ")"),
|
|
118
|
-
dark: "var(--ds-border-focused, ".concat(_colors.N40, ")")
|
|
119
|
-
},
|
|
120
|
-
warning: {
|
|
121
|
-
light: "var(--ds-border-focused, ".concat(_colors.N200, ")"),
|
|
122
|
-
dark: "var(--ds-border-focused, ".concat(_colors.N200, ")")
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var getFlagFocusRingColor = function getFlagFocusRingColor(appearance, mode) {
|
|
127
|
-
return flagFocusRingColor[appearance][mode];
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
exports.getFlagFocusRingColor = getFlagFocusRingColor;
|
|
131
|
-
var lightButtonBackground = 'rgba(255, 255, 255, 0.08)'; // TODO: DSP-2519 Interaction tokens should be used for hovered and pressed states
|
|
46
|
+
error: "var(--ds-border-focused, ".concat(_colors.N40, ")"),
|
|
47
|
+
info: "var(--ds-border-focused, ".concat(_colors.N40, ")"),
|
|
48
|
+
normal: "var(--ds-border-focused, ".concat(_colors.B100, ")"),
|
|
49
|
+
success: "var(--ds-border-focused, ".concat(_colors.N40, ")"),
|
|
50
|
+
warning: "var(--ds-border-focused, ".concat(_colors.N200, ")")
|
|
51
|
+
}; // TODO: DSP-2519 Interaction tokens should be used for hovered and pressed states
|
|
132
52
|
// https://product-fabric.atlassian.net/browse/DSP-2519
|
|
133
53
|
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
dark: "var(--ds-background-neutral, ".concat(lightButtonBackground, ")")
|
|
142
|
-
},
|
|
143
|
-
error: {
|
|
144
|
-
light: "var(--ds-background-neutral, ".concat(lightButtonBackground, ")"),
|
|
145
|
-
dark: "var(--ds-background-neutral, ".concat(_colors.N30A, ")")
|
|
146
|
-
},
|
|
147
|
-
warning: {
|
|
148
|
-
light: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
149
|
-
dark: "var(--ds-background-neutral, ".concat(_colors.N30A, ")")
|
|
150
|
-
},
|
|
151
|
-
normal: {
|
|
152
|
-
light: 'none',
|
|
153
|
-
dark: 'none'
|
|
154
|
-
}
|
|
54
|
+
exports.flagFocusRingColor = flagFocusRingColor;
|
|
55
|
+
var actionBackgroundColor = {
|
|
56
|
+
success: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
57
|
+
info: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
58
|
+
error: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
59
|
+
warning: "var(--ds-background-neutral, ".concat(_colors.N30A, ")"),
|
|
60
|
+
normal: 'none'
|
|
155
61
|
};
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
dark: "var(--ds-text-inverse, ".concat(_colors.DN600, ")")
|
|
164
|
-
},
|
|
165
|
-
error: {
|
|
166
|
-
light: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
167
|
-
dark: "var(--ds-text-inverse, ".concat(_colors.DN600, ")")
|
|
168
|
-
},
|
|
169
|
-
warning: {
|
|
170
|
-
light: "var(--ds-text-warning-inverse, ".concat(_colors.N700, ")"),
|
|
171
|
-
dark: "var(--ds-text-warning-inverse, ".concat(_colors.DN40, ")")
|
|
172
|
-
},
|
|
173
|
-
normal: {
|
|
174
|
-
light: "var(--ds-link, ".concat(_colors.B400, ")"),
|
|
175
|
-
dark: "var(--ds-link, ".concat(_colors.B100, ")")
|
|
176
|
-
}
|
|
62
|
+
exports.actionBackgroundColor = actionBackgroundColor;
|
|
63
|
+
var actionTextColor = {
|
|
64
|
+
success: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
65
|
+
info: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
66
|
+
error: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
|
|
67
|
+
warning: "var(--ds-text-warning-inverse, ".concat(_colors.N700, ")"),
|
|
68
|
+
normal: "var(--ds-link, ".concat(_colors.B400, ")")
|
|
177
69
|
};
|
|
178
|
-
|
|
179
|
-
var getActionBackground = function getActionBackground(appearance, mode) {
|
|
180
|
-
return actionBackground[appearance][mode];
|
|
181
|
-
};
|
|
182
|
-
|
|
183
|
-
exports.getActionBackground = getActionBackground;
|
|
184
|
-
|
|
185
|
-
var getActionColor = function getActionColor(appearance, mode) {
|
|
186
|
-
return actionColor[appearance][mode];
|
|
187
|
-
};
|
|
188
|
-
|
|
189
|
-
exports.getActionColor = getActionColor;
|
|
70
|
+
exports.actionTextColor = actionTextColor;
|
package/dist/cjs/version.json
CHANGED
|
@@ -5,7 +5,7 @@ import noop from '@atlaskit/ds-lib/noop';
|
|
|
5
5
|
import Flag from './flag';
|
|
6
6
|
import { useFlagGroup } from './flag-group';
|
|
7
7
|
const packageName = "@atlaskit/flag";
|
|
8
|
-
const packageVersion = "
|
|
8
|
+
const packageVersion = "15.0.0";
|
|
9
9
|
export const AUTO_DISMISS_SECONDS = 8;
|
|
10
10
|
/**
|
|
11
11
|
* __Auto dismiss flag__
|
|
@@ -3,30 +3,13 @@
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { css, jsx } from '@emotion/react';
|
|
5
5
|
import Button from '@atlaskit/button/custom-theme-button';
|
|
6
|
+
import { UNSAFE_Inline as Inline } from '@atlaskit/ds-explorations';
|
|
6
7
|
import { gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
7
8
|
import { DEFAULT_APPEARANCE } from './constants';
|
|
8
|
-
import {
|
|
9
|
+
import { flagFocusRingColor, actionBackgroundColor, actionTextColor } from './theme';
|
|
9
10
|
const gridSize = getGridSize();
|
|
10
|
-
const separatorWidth = gridSize * 2;
|
|
11
|
-
const defaultAppearanceTranslate = gridSize / 4;
|
|
12
|
-
const separatorStyles = css({
|
|
13
|
-
display: 'inline-block',
|
|
14
|
-
width: separatorWidth,
|
|
15
|
-
textAlign: 'center'
|
|
16
|
-
});
|
|
17
|
-
const actionContainerStyles = css({
|
|
18
|
-
display: 'flex',
|
|
19
|
-
paddingTop: gridSize,
|
|
20
|
-
alignItems: 'center',
|
|
21
|
-
flexWrap: 'wrap',
|
|
22
|
-
transform: `translateX(-${defaultAppearanceTranslate}px)`
|
|
23
|
-
});
|
|
24
|
-
const boldActionContainerStyles = css({
|
|
25
|
-
transform: 0
|
|
26
|
-
});
|
|
27
11
|
const buttonStyles = css({
|
|
28
12
|
'&&, a&&': {
|
|
29
|
-
marginLeft: 0,
|
|
30
13
|
padding: `0 ${gridSize}px !important`,
|
|
31
14
|
background: `var(--bg-color)`,
|
|
32
15
|
color: `var(--color) !important`,
|
|
@@ -39,23 +22,17 @@ const buttonStyles = css({
|
|
|
39
22
|
textDecoration: 'underline'
|
|
40
23
|
}
|
|
41
24
|
});
|
|
42
|
-
const
|
|
25
|
+
const appearanceNormalButtonStyles = css({
|
|
43
26
|
'&&, a&&': {
|
|
44
27
|
padding: '0 !important'
|
|
45
28
|
}
|
|
46
29
|
});
|
|
47
|
-
const isBoldButtonStyles = css({
|
|
48
|
-
'&&, a&&': {
|
|
49
|
-
marginRight: gridSize
|
|
50
|
-
}
|
|
51
|
-
});
|
|
52
30
|
|
|
53
31
|
const FlagActions = props => {
|
|
54
32
|
const {
|
|
55
33
|
appearance = DEFAULT_APPEARANCE,
|
|
56
34
|
actions = [],
|
|
57
35
|
linkComponent,
|
|
58
|
-
mode,
|
|
59
36
|
testId
|
|
60
37
|
} = props;
|
|
61
38
|
|
|
@@ -64,13 +41,16 @@ const FlagActions = props => {
|
|
|
64
41
|
}
|
|
65
42
|
|
|
66
43
|
const isBold = appearance !== DEFAULT_APPEARANCE;
|
|
67
|
-
return jsx(
|
|
68
|
-
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
44
|
+
return jsx(Inline, {
|
|
45
|
+
gap: "scale.100",
|
|
46
|
+
flexWrap: "wrap",
|
|
47
|
+
alignItems: "center",
|
|
48
|
+
divider: isBold ? null : '·',
|
|
49
|
+
UNSAFE_style: isBold ? undefined : {
|
|
50
|
+
transform: `translateX(-2px)`
|
|
51
|
+
},
|
|
52
|
+
testId: testId && `${testId}-actions`
|
|
53
|
+
}, actions.map((action, index) => jsx(Button, {
|
|
74
54
|
onClick: action.onClick,
|
|
75
55
|
href: action.href,
|
|
76
56
|
target: action.target,
|
|
@@ -80,12 +60,12 @@ const FlagActions = props => {
|
|
|
80
60
|
testId: action.testId,
|
|
81
61
|
key: index,
|
|
82
62
|
style: {
|
|
83
|
-
'--color':
|
|
84
|
-
'--bg-color':
|
|
85
|
-
'--focus-color':
|
|
63
|
+
'--color': actionTextColor[appearance],
|
|
64
|
+
'--bg-color': actionBackgroundColor[appearance],
|
|
65
|
+
'--focus-color': flagFocusRingColor[appearance]
|
|
86
66
|
},
|
|
87
|
-
css: [buttonStyles,
|
|
88
|
-
}, action.content)
|
|
67
|
+
css: [buttonStyles, appearance === 'normal' && appearanceNormalButtonStyles]
|
|
68
|
+
}, action.content)));
|
|
89
69
|
}; // eslint-disable-next-line @repo/internal/react/require-jsdoc
|
|
90
70
|
|
|
91
71
|
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
|
|
3
1
|
/** @jsx jsx */
|
|
4
2
|
import { Children, createContext, useContext, useMemo } from 'react';
|
|
5
3
|
import { css, jsx } from '@emotion/react';
|
|
4
|
+
import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
|
|
6
5
|
import { easeIn, ExitingPersistence, SlideIn } from '@atlaskit/motion';
|
|
7
6
|
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
8
7
|
import noop from '@atlaskit/ds-lib/noop';
|
|
@@ -27,7 +26,6 @@ export function useFlagGroup() {
|
|
|
27
26
|
|
|
28
27
|
const baseStyles = css({
|
|
29
28
|
width: flagWidth,
|
|
30
|
-
position: 'absolute',
|
|
31
29
|
bottom: 0,
|
|
32
30
|
transition: `transform ${flagAnimationTime}ms ease-in-out`,
|
|
33
31
|
'@media (max-width: 560px)': {
|
|
@@ -61,7 +59,6 @@ const dismissAllowedStyles = css({
|
|
|
61
59
|
}
|
|
62
60
|
});
|
|
63
61
|
const flagGroupContainerStyles = css({
|
|
64
|
-
position: 'fixed',
|
|
65
62
|
zIndex: layers.flag(),
|
|
66
63
|
bottom: flagBottom,
|
|
67
64
|
left: flagLeft,
|
|
@@ -101,9 +98,16 @@ const FlagGroup = props => {
|
|
|
101
98
|
fade: "inout",
|
|
102
99
|
duration: flagAnimationTime,
|
|
103
100
|
animationTimingFunction: () => easeIn
|
|
104
|
-
},
|
|
105
|
-
|
|
106
|
-
|
|
101
|
+
}, ({
|
|
102
|
+
className,
|
|
103
|
+
ref
|
|
104
|
+
}) => jsx(Box, {
|
|
105
|
+
display: "block",
|
|
106
|
+
position: "absolute",
|
|
107
|
+
css: [baseStyles, isDismissAllowed && dismissAllowedStyles],
|
|
108
|
+
className: className,
|
|
109
|
+
ref: ref
|
|
110
|
+
}, jsx(FlagGroupContext.Provider, {
|
|
107
111
|
value: // Only the first flag should be able to be dismissed.
|
|
108
112
|
isDismissAllowed ? dismissFlagContext : defaultFlagGroupContext
|
|
109
113
|
}, flag)));
|
|
@@ -112,7 +116,9 @@ const FlagGroup = props => {
|
|
|
112
116
|
|
|
113
117
|
return jsx(Portal, {
|
|
114
118
|
zIndex: layers.flag()
|
|
115
|
-
}, jsx(
|
|
119
|
+
}, jsx(Box, {
|
|
120
|
+
display: "block",
|
|
121
|
+
position: "fixed",
|
|
116
122
|
id: id,
|
|
117
123
|
css: flagGroupContainerStyles
|
|
118
124
|
}, hasFlags ? jsx(VisuallyHidden, null, jsx(LabelTag, null, label)) : null, jsx(ExitingPersistence, {
|
package/dist/es2019/flag.js
CHANGED
|
@@ -2,50 +2,21 @@ import _extends from "@babel/runtime/helpers/extends";
|
|
|
2
2
|
|
|
3
3
|
/** @jsx jsx */
|
|
4
4
|
import { useCallback, useEffect, useState } from 'react';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import { borderRadius, //gridSize as getGridSize,
|
|
8
|
-
layers } from '@atlaskit/theme/constants';
|
|
5
|
+
import { jsx } from '@emotion/react';
|
|
6
|
+
import { UNSAFE_Box as Box, UNSAFE_Inline as Inline, UNSAFE_Stack as Stack, UNSAFE_Text as Text } from '@atlaskit/ds-explorations';
|
|
9
7
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
10
8
|
import noop from '@atlaskit/ds-lib/noop';
|
|
11
9
|
import FocusRing from '@atlaskit/focus-ring';
|
|
12
10
|
import { DEFAULT_APPEARANCE } from './constants';
|
|
13
|
-
import {
|
|
11
|
+
import { flagTextColor, flagBackgroundColor, flagIconColor } from './theme';
|
|
14
12
|
import Actions from './flag-actions';
|
|
15
13
|
import { useFlagGroup } from './flag-group';
|
|
16
|
-
import {
|
|
14
|
+
import { Expander, DismissButton } from './internal';
|
|
17
15
|
const analyticsAttributes = {
|
|
18
16
|
componentName: 'flag',
|
|
19
17
|
packageName: "@atlaskit/flag",
|
|
20
|
-
packageVersion: "
|
|
21
|
-
};
|
|
22
|
-
// const gridSize = getGridSize();
|
|
23
|
-
// const doubleGridSize = gridSize * 2;
|
|
24
|
-
|
|
25
|
-
const titleGroupStyles = css({
|
|
26
|
-
display: 'flex',
|
|
27
|
-
alignItems: 'start'
|
|
28
|
-
});
|
|
29
|
-
const iconTitleStyles = css({
|
|
30
|
-
display: 'flex',
|
|
31
|
-
// TODO Delete this comment after verifying spacing token -> previous value ``${gridSize / 2}px``
|
|
32
|
-
paddingTop: "var(--ds-scale-050, 4px)",
|
|
33
|
-
alignItems: 'start',
|
|
34
|
-
flex: 1
|
|
35
|
-
});
|
|
36
|
-
const flagHeaderStyles = css({
|
|
37
|
-
boxSizing: 'border-box',
|
|
38
|
-
width: '100%',
|
|
39
|
-
// TODO Delete this comment after verifying spacing token -> previous value `doubleGridSize`
|
|
40
|
-
padding: "var(--ds-scale-200, 16px)",
|
|
41
|
-
borderRadius: borderRadius()
|
|
42
|
-
});
|
|
43
|
-
const flagContainerStyles = css({
|
|
44
|
-
width: '100%',
|
|
45
|
-
zIndex: layers.flag(),
|
|
46
|
-
borderRadius: borderRadius(),
|
|
47
|
-
transition: 'background-color 200ms'
|
|
48
|
-
});
|
|
18
|
+
packageVersion: "15.0.0"
|
|
19
|
+
};
|
|
49
20
|
/**
|
|
50
21
|
* __Flag__
|
|
51
22
|
*
|
|
@@ -122,41 +93,55 @@ const Flag = props => {
|
|
|
122
93
|
onMouseOut,
|
|
123
94
|
onBlur: onBlurAnalytics
|
|
124
95
|
};
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
if (!isBold) {
|
|
128
|
-
boxShadowValue = `0 0 1px ${flagBorderColor}, ${boxShadowValue}`;
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const boxShadow = `var(--ds-shadow-overlay, ${boxShadowValue})`;
|
|
132
|
-
const {
|
|
133
|
-
mode
|
|
134
|
-
} = useGlobalTheme();
|
|
135
|
-
const textColor = getFlagTextColor(appearance, mode);
|
|
136
|
-
const iconColor = getFlagIconColor(appearance, mode);
|
|
96
|
+
const textColor = flagTextColor[appearance];
|
|
97
|
+
const iconColor = flagIconColor[appearance];
|
|
137
98
|
const isDismissable = isBold || isDismissAllowed;
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
99
|
+
const shouldRenderGap = !isBold && (description || actions.length) || isExpanded;
|
|
100
|
+
return jsx(FocusRing, null, jsx(Box, _extends({
|
|
101
|
+
display: "block",
|
|
102
|
+
backgroundColor: flagBackgroundColor[appearance],
|
|
103
|
+
shadow: "overlay",
|
|
104
|
+
padding: "scale.200",
|
|
105
|
+
borderRadius: "normal",
|
|
106
|
+
overflow: "hidden",
|
|
107
|
+
layer: "flag",
|
|
108
|
+
UNSAFE_style: {
|
|
109
|
+
width: '100%',
|
|
110
|
+
transition: 'background-color 200ms'
|
|
143
111
|
},
|
|
144
|
-
css: flagContainerStyles,
|
|
145
112
|
role: "alert",
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
113
|
+
tabIndex: 0,
|
|
114
|
+
testId: testId
|
|
115
|
+
}, autoDismissProps), jsx(Inline, {
|
|
116
|
+
gap: "scale.200"
|
|
117
|
+
}, jsx(Box, {
|
|
118
|
+
alignItems: "start",
|
|
119
|
+
UNSAFE_style: {
|
|
120
|
+
color: iconColor,
|
|
121
|
+
flexShrink: 0
|
|
122
|
+
}
|
|
123
|
+
}, icon), jsx(Stack, {
|
|
124
|
+
gap: shouldRenderGap ? 'scale.100' : 'scale.0' // Gap exists even when not expanded due to Expander internals always being in the DOM
|
|
149
125
|
,
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
126
|
+
UNSAFE_style: {
|
|
127
|
+
flexGrow: 1,
|
|
128
|
+
transition: `gap 0.3s`
|
|
129
|
+
}
|
|
130
|
+
}, jsx(Inline, {
|
|
131
|
+
gap: "scale.100",
|
|
132
|
+
justifyContent: "spaceBetween"
|
|
133
|
+
}, jsx(Box, {
|
|
134
|
+
display: "block",
|
|
135
|
+
UNSAFE_style: {
|
|
136
|
+
paddingTop: 2
|
|
137
|
+
}
|
|
138
|
+
}, jsx(Text, {
|
|
139
|
+
color: textColor,
|
|
140
|
+
fontWeight: "600",
|
|
141
|
+
UNSAFE_style: {
|
|
142
|
+
overflowWrap: 'anywhere' // For cases where a single word is longer than the container (e.g. filenames)
|
|
143
|
+
|
|
144
|
+
}
|
|
160
145
|
}, title)), isDismissable ? !(isBold && !description && !actions.length) && jsx(DismissButton, {
|
|
161
146
|
testId: testId,
|
|
162
147
|
appearance: appearance,
|
|
@@ -166,17 +151,23 @@ const Flag = props => {
|
|
|
166
151
|
}) : null), jsx(Expander, {
|
|
167
152
|
isExpanded: !isBold || isExpanded,
|
|
168
153
|
testId: testId
|
|
169
|
-
}, description && jsx(
|
|
170
|
-
|
|
154
|
+
}, description && jsx(Text, {
|
|
155
|
+
as: "div",
|
|
171
156
|
color: textColor,
|
|
172
|
-
|
|
157
|
+
UNSAFE_style: {
|
|
158
|
+
maxHeight: 100,
|
|
159
|
+
// height is defined as 5 lines maximum by design
|
|
160
|
+
overflow: 'auto',
|
|
161
|
+
overflowWrap: 'anywhere' // For cases where a single word is longer than the container (e.g. filenames)
|
|
162
|
+
|
|
163
|
+
},
|
|
164
|
+
testId: testId && `${testId}-description`
|
|
173
165
|
}, description), jsx(Actions, {
|
|
174
166
|
actions: actions,
|
|
175
167
|
appearance: appearance,
|
|
176
168
|
linkComponent: linkComponent,
|
|
177
|
-
testId: testId
|
|
178
|
-
|
|
179
|
-
})))));
|
|
169
|
+
testId: testId
|
|
170
|
+
}))))));
|
|
180
171
|
};
|
|
181
172
|
|
|
182
173
|
export default Flag;
|
|
@@ -1,30 +1,12 @@
|
|
|
1
1
|
/** @jsx jsx */
|
|
2
2
|
import { memo } from 'react';
|
|
3
|
-
import { jsx
|
|
3
|
+
import { jsx } from '@emotion/react';
|
|
4
|
+
import { UNSAFE_Box as Box } from '@atlaskit/ds-explorations';
|
|
4
5
|
import FocusRing from '@atlaskit/focus-ring';
|
|
5
|
-
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
6
|
-
import ChevronUpIcon from '@atlaskit/icon/glyph/chevron-up';
|
|
6
|
+
import ChevronDownIcon from '@atlaskit/icon/glyph/hipchat/chevron-down';
|
|
7
|
+
import ChevronUpIcon from '@atlaskit/icon/glyph/hipchat/chevron-up';
|
|
7
8
|
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
8
|
-
import {
|
|
9
|
-
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
10
|
-
import { getFlagTextColor } from '../theme';
|
|
11
|
-
const gridSize = getGridSize();
|
|
12
|
-
const borderRadius = getBorderRadius();
|
|
13
|
-
const dismissButtonStyles = css({
|
|
14
|
-
marginLeft: gridSize,
|
|
15
|
-
padding: 0,
|
|
16
|
-
flex: '0 0 auto',
|
|
17
|
-
appearance: 'none',
|
|
18
|
-
background: 'none',
|
|
19
|
-
border: 'none',
|
|
20
|
-
borderRadius,
|
|
21
|
-
cursor: 'pointer',
|
|
22
|
-
lineHeight: '1',
|
|
23
|
-
whiteSpace: 'nowrap'
|
|
24
|
-
});
|
|
25
|
-
const crossIconStyles = css({
|
|
26
|
-
paddingTop: `${gridSize}px`
|
|
27
|
-
});
|
|
9
|
+
import { flagTextColorToken } from '../theme';
|
|
28
10
|
|
|
29
11
|
const DismissButton = ({
|
|
30
12
|
appearance,
|
|
@@ -33,9 +15,6 @@ const DismissButton = ({
|
|
|
33
15
|
isExpanded,
|
|
34
16
|
testId
|
|
35
17
|
}) => {
|
|
36
|
-
const {
|
|
37
|
-
mode
|
|
38
|
-
} = useGlobalTheme();
|
|
39
18
|
let ButtonIcon = CrossIcon;
|
|
40
19
|
let buttonLabel = 'Dismiss';
|
|
41
20
|
let size = 'small';
|
|
@@ -44,22 +23,33 @@ const DismissButton = ({
|
|
|
44
23
|
if (isBold) {
|
|
45
24
|
ButtonIcon = isExpanded ? ChevronUpIcon : ChevronDownIcon;
|
|
46
25
|
buttonLabel = isExpanded ? 'Collapse' : 'Expand';
|
|
47
|
-
size = '
|
|
26
|
+
size = 'medium';
|
|
48
27
|
buttonTestId = testId && `${testId}-toggle`;
|
|
49
28
|
}
|
|
50
29
|
|
|
51
|
-
return jsx(FocusRing, null, jsx(
|
|
52
|
-
|
|
53
|
-
color: getFlagTextColor(appearance, mode)
|
|
54
|
-
},
|
|
55
|
-
css: [dismissButtonStyles, !isBold && crossIconStyles],
|
|
56
|
-
onClick: onClick,
|
|
57
|
-
"data-testid": buttonTestId,
|
|
30
|
+
return jsx(FocusRing, null, jsx(Box, {
|
|
31
|
+
as: "button",
|
|
58
32
|
type: "button",
|
|
59
|
-
"
|
|
33
|
+
justifyContent: "center",
|
|
34
|
+
alignItems: "center",
|
|
35
|
+
borderStyle: "none",
|
|
36
|
+
borderRadius: "normal",
|
|
37
|
+
padding: "scale.0",
|
|
38
|
+
width: "size.200",
|
|
39
|
+
height: "size.200",
|
|
40
|
+
onClick: onClick,
|
|
41
|
+
"aria-expanded": isBold ? isExpanded : undefined,
|
|
42
|
+
UNSAFE_style: {
|
|
43
|
+
flex: '0 0 auto',
|
|
44
|
+
background: 'none',
|
|
45
|
+
cursor: 'pointer',
|
|
46
|
+
whiteSpace: 'nowrap'
|
|
47
|
+
},
|
|
48
|
+
testId: buttonTestId
|
|
60
49
|
}, jsx(ButtonIcon, {
|
|
61
50
|
label: buttonLabel,
|
|
62
|
-
size: size
|
|
51
|
+
size: size,
|
|
52
|
+
primaryColor: flagTextColorToken[appearance]
|
|
63
53
|
})));
|
|
64
54
|
};
|
|
65
55
|
|