@atlaskit/flag 14.5.1 → 14.5.2
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 +10 -0
- package/__perf__/withFlagGroup.tsx +1 -1
- package/dist/cjs/auto-dismiss-flag.js +4 -4
- package/dist/cjs/flag-actions.js +50 -6
- package/dist/cjs/flag-group.js +56 -18
- package/dist/cjs/flag.js +83 -106
- package/dist/cjs/internal/description.js +32 -0
- package/dist/cjs/internal/dismiss-button.js +83 -0
- package/dist/cjs/{expander.js → internal/expander.js} +15 -7
- package/dist/cjs/internal/index.js +39 -0
- package/dist/cjs/internal/title.js +32 -0
- package/dist/cjs/theme.js +61 -61
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/auto-dismiss-flag.js +2 -3
- package/dist/es2019/flag-actions.js +50 -32
- package/dist/es2019/flag-group.js +48 -65
- package/dist/es2019/flag.js +77 -164
- package/dist/es2019/internal/description.js +22 -0
- package/dist/es2019/internal/dismiss-button.js +63 -0
- package/dist/es2019/{expander.js → internal/expander.js} +14 -10
- package/dist/es2019/internal/index.js +4 -0
- package/dist/es2019/internal/title.js +22 -0
- package/dist/es2019/theme.js +61 -61
- package/dist/es2019/version.json +1 -1
- package/dist/esm/auto-dismiss-flag.js +2 -3
- package/dist/esm/flag-actions.js +49 -6
- package/dist/esm/flag-group.js +52 -16
- package/dist/esm/flag.js +79 -101
- package/dist/esm/internal/description.js +23 -0
- package/dist/esm/internal/dismiss-button.js +63 -0
- package/dist/esm/{expander.js → internal/expander.js} +14 -5
- package/dist/esm/internal/index.js +4 -0
- package/dist/esm/internal/title.js +23 -0
- package/dist/esm/theme.js +61 -61
- package/dist/esm/version.json +1 -1
- package/dist/types/flag-actions.d.ts +4 -4
- package/dist/types/flag-group.d.ts +2 -2
- package/dist/types/flag.d.ts +1 -1
- package/dist/types/internal/description.d.ts +7 -0
- package/dist/types/internal/dismiss-button.d.ts +11 -0
- package/dist/types/internal/expander.d.ts +8 -0
- package/dist/types/internal/index.d.ts +4 -0
- package/dist/types/internal/title.d.ts +6 -0
- package/dist/types/theme.d.ts +1 -1
- package/package.json +7 -3
- package/dist/types/expander.d.ts +0 -9
- package/expander/package.json +0 -7
package/dist/esm/flag-actions.js
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
1
|
+
/* eslint-disable @repo/internal/styles/no-nested-styles */
|
|
4
2
|
|
|
5
3
|
/** @jsx jsx */
|
|
6
4
|
import { css, jsx } from '@emotion/core';
|
|
@@ -11,6 +9,46 @@ import { getActionBackground, getActionColor, getFlagFocusRingColor } from './th
|
|
|
11
9
|
var gridSize = getGridSize();
|
|
12
10
|
var separatorWidth = gridSize * 2;
|
|
13
11
|
var defaultAppearanceTranslate = gridSize / 4;
|
|
12
|
+
var separatorStyles = css({
|
|
13
|
+
display: 'inline-block',
|
|
14
|
+
width: separatorWidth,
|
|
15
|
+
textAlign: 'center'
|
|
16
|
+
});
|
|
17
|
+
var actionContainerStyles = css({
|
|
18
|
+
display: 'flex',
|
|
19
|
+
paddingTop: gridSize,
|
|
20
|
+
alignItems: 'center',
|
|
21
|
+
flexWrap: 'wrap',
|
|
22
|
+
transform: "translateX(-".concat(defaultAppearanceTranslate, "px)")
|
|
23
|
+
});
|
|
24
|
+
var boldActionContainerStyles = css({
|
|
25
|
+
transform: 0
|
|
26
|
+
});
|
|
27
|
+
var buttonStyles = css({
|
|
28
|
+
'&&, a&&': {
|
|
29
|
+
marginLeft: 0,
|
|
30
|
+
padding: "0 ".concat(gridSize, "px !important"),
|
|
31
|
+
background: "var(--bg-color)",
|
|
32
|
+
color: "var(--color) !important",
|
|
33
|
+
fontWeight: 500
|
|
34
|
+
},
|
|
35
|
+
'&&:focus, a&&:focus': {
|
|
36
|
+
boxShadow: "0 0 0 2px var(--focus-color)"
|
|
37
|
+
},
|
|
38
|
+
'&&:hover, &&:active, a&&:hover, a&&:active': {
|
|
39
|
+
textDecoration: 'underline'
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
var appeanceNormalButtonStyles = css({
|
|
43
|
+
'&&, a&&': {
|
|
44
|
+
padding: '0 !important'
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
var isBoldButtonStyles = css({
|
|
48
|
+
'&&, a&&': {
|
|
49
|
+
marginLeft: gridSize
|
|
50
|
+
}
|
|
51
|
+
});
|
|
14
52
|
|
|
15
53
|
var FlagActions = function FlagActions(props) {
|
|
16
54
|
var _props$appearance = props.appearance,
|
|
@@ -27,11 +65,11 @@ var FlagActions = function FlagActions(props) {
|
|
|
27
65
|
|
|
28
66
|
var isBold = appearance !== DEFAULT_APPEARANCE;
|
|
29
67
|
return jsx("div", {
|
|
30
|
-
css:
|
|
68
|
+
css: [actionContainerStyles, isBold && boldActionContainerStyles],
|
|
31
69
|
"data-testid": testId && "".concat(testId, "-actions")
|
|
32
70
|
}, actions.map(function (action, index) {
|
|
33
71
|
return [index && !isBold ? jsx("div", {
|
|
34
|
-
css:
|
|
72
|
+
css: separatorStyles,
|
|
35
73
|
key: index + 0.5
|
|
36
74
|
}, "\xB7") : '', jsx(Button, {
|
|
37
75
|
onClick: action.onClick,
|
|
@@ -42,7 +80,12 @@ var FlagActions = function FlagActions(props) {
|
|
|
42
80
|
spacing: "compact",
|
|
43
81
|
testId: action.testId,
|
|
44
82
|
key: index,
|
|
45
|
-
|
|
83
|
+
style: {
|
|
84
|
+
'--color': getActionColor(appearance, mode),
|
|
85
|
+
'--bg-color': getActionBackground(appearance, mode),
|
|
86
|
+
'--focus-color': getFlagFocusRingColor(appearance, mode)
|
|
87
|
+
},
|
|
88
|
+
css: [buttonStyles, isBold && isBoldButtonStyles, appearance === 'normal' && appeanceNormalButtonStyles]
|
|
46
89
|
}, action.content)];
|
|
47
90
|
}));
|
|
48
91
|
};
|
package/dist/esm/flag-group.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
2
|
import _typeof from "@babel/runtime/helpers/typeof";
|
|
4
3
|
|
|
5
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
6
|
-
|
|
7
4
|
/** @jsx jsx */
|
|
8
5
|
import { Children, createContext, useContext, useMemo } from 'react';
|
|
9
6
|
import { css, jsx } from '@emotion/core';
|
|
10
7
|
import { easeIn, ExitingPersistence, SlideIn } from '@atlaskit/motion';
|
|
8
|
+
import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
9
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
11
10
|
import Portal from '@atlaskit/portal';
|
|
12
11
|
import { gridSize as getGridSize, layers } from '@atlaskit/theme/constants';
|
|
13
12
|
var gridSize = getGridSize();
|
|
@@ -15,9 +14,6 @@ export var flagWidth = gridSize * 50;
|
|
|
15
14
|
export var flagAnimationTime = 400;
|
|
16
15
|
var flagBottom = gridSize * 6;
|
|
17
16
|
var flagLeft = gridSize * 10;
|
|
18
|
-
|
|
19
|
-
function noop() {}
|
|
20
|
-
|
|
21
17
|
var defaultFlagGroupContext = {
|
|
22
18
|
onDismissed: function onDismissed() {},
|
|
23
19
|
isDismissAllowed: false
|
|
@@ -28,7 +24,51 @@ export function useFlagGroup() {
|
|
|
28
24
|
} // transition: none is set on first-of-type to prevent a bug in Firefox
|
|
29
25
|
// that causes a broken transition
|
|
30
26
|
|
|
31
|
-
var baseStyles =
|
|
27
|
+
var baseStyles = css({
|
|
28
|
+
width: flagWidth,
|
|
29
|
+
position: 'absolute',
|
|
30
|
+
bottom: 0,
|
|
31
|
+
transition: "transform ".concat(flagAnimationTime, "ms ease-in-out"),
|
|
32
|
+
'@media (max-width: 560px)': {
|
|
33
|
+
width: '100vw'
|
|
34
|
+
},
|
|
35
|
+
':first-of-type': {
|
|
36
|
+
transform: "translate(0,0)",
|
|
37
|
+
transition: 'none'
|
|
38
|
+
},
|
|
39
|
+
':nth-of-type(n + 2)': {
|
|
40
|
+
animationDuration: '0ms',
|
|
41
|
+
transform: "translateX(0) translateY(100%) translateY(".concat(2 * gridSize, "px)")
|
|
42
|
+
},
|
|
43
|
+
':nth-of-type(1)': {
|
|
44
|
+
zIndex: 5
|
|
45
|
+
},
|
|
46
|
+
':nth-of-type(2)': {
|
|
47
|
+
zIndex: 4
|
|
48
|
+
},
|
|
49
|
+
'&:nth-of-type(n + 4)': {
|
|
50
|
+
visibility: 'hidden'
|
|
51
|
+
}
|
|
52
|
+
}); // Transform needed to push up while 1st flag is leaving
|
|
53
|
+
// Exiting time should match the exiting time of motion so is halved
|
|
54
|
+
|
|
55
|
+
var dismissAllowedStyles = css({
|
|
56
|
+
// eslint-disable-next-line @repo/internal/styles/no-nested-styles
|
|
57
|
+
'&& + *': {
|
|
58
|
+
transform: "translate(0, 0)",
|
|
59
|
+
transitionDuration: "".concat(flagAnimationTime / 2, "ms")
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
var flagGroupContainerStyles = css({
|
|
63
|
+
position: 'fixed',
|
|
64
|
+
zIndex: layers.flag(),
|
|
65
|
+
bottom: flagBottom,
|
|
66
|
+
left: flagLeft,
|
|
67
|
+
'@media (max-width: 560px)': {
|
|
68
|
+
bottom: 0,
|
|
69
|
+
left: 0
|
|
70
|
+
}
|
|
71
|
+
});
|
|
32
72
|
|
|
33
73
|
var FlagGroup = function FlagGroup(props) {
|
|
34
74
|
var id = props.id,
|
|
@@ -51,17 +91,15 @@ var FlagGroup = function FlagGroup(props) {
|
|
|
51
91
|
return children && _typeof(children) === 'object' ? Children.map(children, function (flag, index) {
|
|
52
92
|
var isDismissAllowed = index === 0;
|
|
53
93
|
return jsx(SlideIn, {
|
|
54
|
-
enterFrom:
|
|
55
|
-
fade:
|
|
94
|
+
enterFrom: "left",
|
|
95
|
+
fade: "inout",
|
|
56
96
|
duration: flagAnimationTime,
|
|
57
97
|
animationTimingFunction: function animationTimingFunction() {
|
|
58
98
|
return easeIn;
|
|
59
99
|
}
|
|
60
100
|
}, function (props) {
|
|
61
101
|
return jsx("div", _extends({}, props, {
|
|
62
|
-
css:
|
|
63
|
-
// Exiting time should match the exiting time of motion so is halved
|
|
64
|
-
"\n && + * {\n transform: translate(0, 0);\n transition-duration: ".concat(flagAnimationTime / 2, "ms\n }") : '')
|
|
102
|
+
css: [baseStyles, isDismissAllowed && dismissAllowedStyles]
|
|
65
103
|
}), jsx(FlagGroupContext.Provider, {
|
|
66
104
|
value: // Only the first flag should be able to be dismissed.
|
|
67
105
|
isDismissAllowed ? dismissFlagContext : defaultFlagGroupContext
|
|
@@ -74,10 +112,8 @@ var FlagGroup = function FlagGroup(props) {
|
|
|
74
112
|
zIndex: layers.flag()
|
|
75
113
|
}, jsx("div", {
|
|
76
114
|
id: id,
|
|
77
|
-
css:
|
|
78
|
-
}, hasFlags ? jsx(LabelTag, {
|
|
79
|
-
css: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n white-space: nowrap;\n width: 1px;\n "])))
|
|
80
|
-
}, label) : null, jsx(ExitingPersistence, {
|
|
115
|
+
css: flagGroupContainerStyles
|
|
116
|
+
}, hasFlags ? jsx(VisuallyHidden, null, jsx(LabelTag, null, label)) : null, jsx(ExitingPersistence, {
|
|
81
117
|
appear: false
|
|
82
118
|
}, renderChildren())));
|
|
83
119
|
};
|
package/dist/esm/flag.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
3
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
4
3
|
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
5
4
|
|
|
6
|
-
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6;
|
|
7
|
-
|
|
8
5
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
6
|
|
|
10
7
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
@@ -12,28 +9,41 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
12
9
|
/** @jsx jsx */
|
|
13
10
|
import { useCallback, useEffect, useState } from 'react';
|
|
14
11
|
import { css, jsx } from '@emotion/core';
|
|
15
|
-
import
|
|
16
|
-
import ChevronUpIcon from '@atlaskit/icon/glyph/chevron-up';
|
|
17
|
-
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
18
|
-
import GlobalTheme from '@atlaskit/theme/components';
|
|
12
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
19
13
|
import { borderRadius, gridSize as getGridSize, layers } from '@atlaskit/theme/constants';
|
|
20
14
|
import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
|
|
15
|
+
import noop from '@atlaskit/ds-lib/noop';
|
|
16
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
21
17
|
import { DEFAULT_APPEARANCE } from './constants';
|
|
22
|
-
import { flagBorderColor, flagShadowColor, getFlagBackgroundColor,
|
|
23
|
-
import Expander from './expander';
|
|
18
|
+
import { flagBorderColor, flagShadowColor, getFlagBackgroundColor, getFlagTextColor, getFlagIconColor } from './theme';
|
|
24
19
|
import Actions from './flag-actions';
|
|
25
20
|
import { useFlagGroup } from './flag-group';
|
|
26
|
-
|
|
27
|
-
function noop() {}
|
|
28
|
-
|
|
21
|
+
import { Title, Description, Expander, DismissButton } from './internal';
|
|
29
22
|
var analyticsAttributes = {
|
|
30
23
|
componentName: 'flag',
|
|
31
24
|
packageName: "@atlaskit/flag",
|
|
32
|
-
packageVersion: "14.5.
|
|
25
|
+
packageVersion: "14.5.2"
|
|
33
26
|
};
|
|
34
27
|
var gridSize = getGridSize();
|
|
35
28
|
var doubleGridSize = gridSize * 2;
|
|
36
29
|
var headerHeight = gridSize * 4;
|
|
30
|
+
var iconStyles = css({
|
|
31
|
+
display: 'flex',
|
|
32
|
+
height: headerHeight,
|
|
33
|
+
alignItems: 'center'
|
|
34
|
+
});
|
|
35
|
+
var flagHeaderStyles = css({
|
|
36
|
+
boxSizing: 'border-box',
|
|
37
|
+
width: '100%',
|
|
38
|
+
padding: doubleGridSize,
|
|
39
|
+
borderRadius: borderRadius()
|
|
40
|
+
});
|
|
41
|
+
var flagContainerStyles = css({
|
|
42
|
+
width: '100%',
|
|
43
|
+
zIndex: layers.flag(),
|
|
44
|
+
borderRadius: borderRadius(),
|
|
45
|
+
transition: 'background-color 200ms'
|
|
46
|
+
});
|
|
37
47
|
|
|
38
48
|
var Flag = function Flag(props) {
|
|
39
49
|
var _props$actions = props.actions,
|
|
@@ -76,60 +86,16 @@ var Flag = function Flag(props) {
|
|
|
76
86
|
analyticsData: analyticsContext
|
|
77
87
|
}, analyticsAttributes));
|
|
78
88
|
var isBold = appearance !== DEFAULT_APPEARANCE;
|
|
79
|
-
var
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
if (
|
|
86
|
-
|
|
87
|
-
} // If it is bold then ensure there is a description or actions to render
|
|
88
|
-
// the toggle button
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
if (isBold && !description && !actions.length) {
|
|
92
|
-
return null;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
var ButtonIcon = CrossIcon;
|
|
96
|
-
var buttonLabel = 'Dismiss';
|
|
97
|
-
|
|
98
|
-
var buttonAction = function buttonAction() {
|
|
99
|
-
if (isDismissAllowed) {
|
|
100
|
-
onDismissedAnalytics(id);
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
|
|
104
|
-
var size = 'small';
|
|
105
|
-
var buttonTestId = testId && "".concat(testId, "-dismiss");
|
|
106
|
-
var a11yProps = {};
|
|
107
|
-
|
|
108
|
-
if (isBold) {
|
|
109
|
-
ButtonIcon = isExpanded ? ChevronUpIcon : ChevronDownIcon;
|
|
110
|
-
buttonLabel = isExpanded ? 'Collapse' : 'Expand';
|
|
111
|
-
|
|
112
|
-
buttonAction = function buttonAction() {
|
|
113
|
-
return setIsExpanded(!isExpanded);
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
size = 'large';
|
|
117
|
-
buttonTestId = testId && "".concat(testId, "-toggle");
|
|
118
|
-
a11yProps = {
|
|
119
|
-
'aria-expanded': isExpanded
|
|
120
|
-
};
|
|
89
|
+
var toggleExpand = useCallback(function () {
|
|
90
|
+
setIsExpanded(function (previous) {
|
|
91
|
+
return !previous;
|
|
92
|
+
});
|
|
93
|
+
}, []);
|
|
94
|
+
var buttonActionCallback = useCallback(function () {
|
|
95
|
+
if (isDismissAllowed) {
|
|
96
|
+
onDismissedAnalytics(id);
|
|
121
97
|
}
|
|
122
|
-
|
|
123
|
-
return jsx("button", _extends({
|
|
124
|
-
css: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n appearance: none;\n background: none;\n border: none;\n border-radius: ", "px;\n color: ", ";\n cursor: pointer;\n flex: 0 0 auto;\n line-height: 1;\n margin-left: ", "px;\n padding: 0;\n white-space: nowrap;\n &:focus {\n outline: none;\n box-shadow: 0 0 0 2px ", ";\n }\n "])), borderRadius(), getFlagTextColor(appearance, mode), gridSize, getFlagFocusRingColor(appearance, mode)),
|
|
125
|
-
onClick: buttonAction,
|
|
126
|
-
"data-testid": buttonTestId,
|
|
127
|
-
type: "button"
|
|
128
|
-
}, a11yProps), jsx(ButtonIcon, {
|
|
129
|
-
label: buttonLabel,
|
|
130
|
-
size: size
|
|
131
|
-
}));
|
|
132
|
-
}, [actions.length, appearance, description, id, isBold, isDismissAllowed, isExpanded, onDismissedAnalytics, testId]);
|
|
98
|
+
}, [onDismissedAnalytics, id, isDismissAllowed]);
|
|
133
99
|
useEffect(function () {
|
|
134
100
|
// If buttons are removed as a prop, update isExpanded to be false
|
|
135
101
|
if (isBold && isExpanded && !description && !actions.length) {
|
|
@@ -152,45 +118,57 @@ var Flag = function Flag(props) {
|
|
|
152
118
|
onMouseOut: onMouseOut,
|
|
153
119
|
onBlur: onBlurAnalytics
|
|
154
120
|
};
|
|
155
|
-
var
|
|
156
|
-
var boxShadow = "var(--ds-overlay, ".concat("0 20px 32px -8px ".concat(flagShadowColor), ")");
|
|
121
|
+
var boxShadow = "var(--ds-shadow-overlay, ".concat("0 20px 32px -8px ".concat(flagShadowColor), ")");
|
|
157
122
|
|
|
158
123
|
if (!isBold) {
|
|
159
|
-
boxShadow = "var(--ds-overlay, ".concat("0 0 1px ".concat(flagBorderColor, ", ").concat(boxShadow), ")");
|
|
124
|
+
boxShadow = "var(--ds-shadow-overlay, ".concat("0 0 1px ".concat(flagBorderColor, ", ").concat(boxShadow), ")");
|
|
160
125
|
}
|
|
161
126
|
|
|
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
|
-
|
|
127
|
+
var _useGlobalTheme = useGlobalTheme(),
|
|
128
|
+
mode = _useGlobalTheme.mode;
|
|
129
|
+
|
|
130
|
+
var textColor = getFlagTextColor(appearance, mode);
|
|
131
|
+
var iconColor = getFlagIconColor(appearance, mode);
|
|
132
|
+
var isDismissable = isBold || isDismissAllowed;
|
|
133
|
+
return jsx("div", _extends({
|
|
134
|
+
style: {
|
|
135
|
+
color: textColor,
|
|
136
|
+
backgroundColor: getFlagBackgroundColor(appearance, mode),
|
|
137
|
+
boxShadow: boxShadow
|
|
138
|
+
},
|
|
139
|
+
css: flagContainerStyles,
|
|
140
|
+
role: "alert",
|
|
141
|
+
"data-testid": testId
|
|
142
|
+
}, autoDismissProps), jsx(FocusRing, null, jsx("div", {
|
|
143
|
+
css: flagHeaderStyles // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
|
|
144
|
+
,
|
|
145
|
+
tabIndex: 0
|
|
146
|
+
}, jsx("div", {
|
|
147
|
+
style: {
|
|
148
|
+
color: iconColor
|
|
149
|
+
},
|
|
150
|
+
css: iconStyles
|
|
151
|
+
}, icon, jsx(Title, {
|
|
152
|
+
color: textColor
|
|
153
|
+
}, title), isDismissable ? !(isBold && !description && !actions.length) && jsx(DismissButton, {
|
|
154
|
+
testId: testId,
|
|
155
|
+
appearance: appearance,
|
|
156
|
+
isBold: isBold,
|
|
157
|
+
isExpanded: isExpanded,
|
|
158
|
+
onClick: isBold ? toggleExpand : buttonActionCallback
|
|
159
|
+
}) : null), jsx(Expander, {
|
|
160
|
+
isExpanded: !isBold || isExpanded,
|
|
161
|
+
testId: testId
|
|
162
|
+
}, description && jsx(Description, {
|
|
163
|
+
testId: testId && "".concat(testId, "-description"),
|
|
164
|
+
color: textColor
|
|
165
|
+
}, description), jsx(Actions, {
|
|
166
|
+
actions: actions,
|
|
167
|
+
appearance: appearance,
|
|
168
|
+
linkComponent: linkComponent,
|
|
169
|
+
testId: testId,
|
|
170
|
+
mode: mode
|
|
171
|
+
})))));
|
|
194
172
|
};
|
|
195
173
|
|
|
196
174
|
export default Flag;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, css } from '@emotion/core';
|
|
3
|
+
var descriptionStyles = css({
|
|
4
|
+
/* height is defined as 5 lines maximum by design */
|
|
5
|
+
maxHeight: 100,
|
|
6
|
+
overflow: 'auto',
|
|
7
|
+
wordWrap: 'break-word'
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
var Description = function Description(_ref) {
|
|
11
|
+
var color = _ref.color,
|
|
12
|
+
testId = _ref.testId,
|
|
13
|
+
children = _ref.children;
|
|
14
|
+
return jsx("div", {
|
|
15
|
+
style: {
|
|
16
|
+
color: color
|
|
17
|
+
},
|
|
18
|
+
css: descriptionStyles,
|
|
19
|
+
"data-testid": testId
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default Description;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { memo } from 'react';
|
|
3
|
+
import { jsx, css } from '@emotion/core';
|
|
4
|
+
import FocusRing from '@atlaskit/focus-ring';
|
|
5
|
+
import ChevronDownIcon from '@atlaskit/icon/glyph/chevron-down';
|
|
6
|
+
import ChevronUpIcon from '@atlaskit/icon/glyph/chevron-up';
|
|
7
|
+
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
8
|
+
import { borderRadius as getBorderRadius, gridSize as getGridSize } from '@atlaskit/theme/constants';
|
|
9
|
+
import { useGlobalTheme } from '@atlaskit/theme/components';
|
|
10
|
+
import { getFlagTextColor } from '../theme';
|
|
11
|
+
var gridSize = getGridSize();
|
|
12
|
+
var borderRadius = getBorderRadius();
|
|
13
|
+
var dismissButtonStyles = css({
|
|
14
|
+
marginLeft: gridSize,
|
|
15
|
+
padding: 0,
|
|
16
|
+
flex: '0 0 auto',
|
|
17
|
+
appearance: 'none',
|
|
18
|
+
background: 'none',
|
|
19
|
+
border: 'none',
|
|
20
|
+
borderRadius: borderRadius,
|
|
21
|
+
cursor: 'pointer',
|
|
22
|
+
lineHeight: '1',
|
|
23
|
+
whiteSpace: 'nowrap'
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
var DismissButton = function DismissButton(_ref) {
|
|
27
|
+
var appearance = _ref.appearance,
|
|
28
|
+
onClick = _ref.onClick,
|
|
29
|
+
isBold = _ref.isBold,
|
|
30
|
+
isExpanded = _ref.isExpanded,
|
|
31
|
+
testId = _ref.testId;
|
|
32
|
+
|
|
33
|
+
var _useGlobalTheme = useGlobalTheme(),
|
|
34
|
+
mode = _useGlobalTheme.mode;
|
|
35
|
+
|
|
36
|
+
var ButtonIcon = CrossIcon;
|
|
37
|
+
var buttonLabel = 'Dismiss';
|
|
38
|
+
var size = 'small';
|
|
39
|
+
var buttonTestId = testId && "".concat(testId, "-dismiss");
|
|
40
|
+
|
|
41
|
+
if (isBold) {
|
|
42
|
+
ButtonIcon = isExpanded ? ChevronUpIcon : ChevronDownIcon;
|
|
43
|
+
buttonLabel = isExpanded ? 'Collapse' : 'Expand';
|
|
44
|
+
size = 'large';
|
|
45
|
+
buttonTestId = testId && "".concat(testId, "-toggle");
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return jsx(FocusRing, null, jsx("button", {
|
|
49
|
+
style: {
|
|
50
|
+
color: getFlagTextColor(appearance, mode)
|
|
51
|
+
},
|
|
52
|
+
css: dismissButtonStyles,
|
|
53
|
+
onClick: onClick,
|
|
54
|
+
"data-testid": buttonTestId,
|
|
55
|
+
type: "button",
|
|
56
|
+
"aria-expanded": isBold ? isExpanded : undefined
|
|
57
|
+
}, jsx(ButtonIcon, {
|
|
58
|
+
label: buttonLabel,
|
|
59
|
+
size: size
|
|
60
|
+
})));
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export default /*#__PURE__*/memo(DismissButton);
|
|
@@ -1,12 +1,21 @@
|
|
|
1
|
-
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
-
|
|
3
|
-
var _templateObject;
|
|
4
|
-
|
|
5
1
|
/** @jsx jsx */
|
|
6
2
|
import { css, jsx } from '@emotion/core';
|
|
7
3
|
import { ExitingPersistence, FadeIn } from '@atlaskit/motion';
|
|
8
4
|
import { gridSize } from '@atlaskit/theme/constants';
|
|
9
5
|
var paddingLeft = gridSize() * 5;
|
|
6
|
+
var expanderStyles = css({
|
|
7
|
+
display: 'flex',
|
|
8
|
+
minWidth: 0,
|
|
9
|
+
maxHeight: 0,
|
|
10
|
+
padding: "0 0 0 ".concat(paddingLeft, "px"),
|
|
11
|
+
justifyContent: 'center',
|
|
12
|
+
flex: '1 1 100%',
|
|
13
|
+
flexDirection: 'column',
|
|
14
|
+
transition: "max-height 0.3s"
|
|
15
|
+
});
|
|
16
|
+
var expandedStyles = css({
|
|
17
|
+
maxHeight: 150
|
|
18
|
+
});
|
|
10
19
|
|
|
11
20
|
var Expander = function Expander(_ref) {
|
|
12
21
|
var children = _ref.children,
|
|
@@ -17,7 +26,7 @@ var Expander = function Expander(_ref) {
|
|
|
17
26
|
// the the reveal because we don't know the height of the content.
|
|
18
27
|
return jsx("div", {
|
|
19
28
|
"aria-hidden": !isExpanded,
|
|
20
|
-
css:
|
|
29
|
+
css: [expanderStyles, isExpanded && expandedStyles],
|
|
21
30
|
"data-testid": testId && "".concat(testId, "-expander")
|
|
22
31
|
}, jsx(ExitingPersistence, {
|
|
23
32
|
appear: true
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/** @jsx jsx */
|
|
2
|
+
import { jsx, css } from '@emotion/core';
|
|
3
|
+
var titleStyles = css({
|
|
4
|
+
padding: "0 0 0 16px",
|
|
5
|
+
flex: 1,
|
|
6
|
+
fontWeight: 600,
|
|
7
|
+
overflow: 'hidden',
|
|
8
|
+
textOverflow: 'ellipsis',
|
|
9
|
+
whiteSpace: 'nowrap'
|
|
10
|
+
});
|
|
11
|
+
|
|
12
|
+
var Title = function Title(_ref) {
|
|
13
|
+
var color = _ref.color,
|
|
14
|
+
children = _ref.children;
|
|
15
|
+
return jsx("span", {
|
|
16
|
+
style: {
|
|
17
|
+
color: color
|
|
18
|
+
},
|
|
19
|
+
css: titleStyles
|
|
20
|
+
}, children);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default Title;
|