@atlaskit/flag 14.7.2 → 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.
Files changed (57) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/cjs/auto-dismiss-flag.js +1 -1
  3. package/dist/cjs/flag-actions.js +18 -37
  4. package/dist/cjs/flag-group.js +15 -9
  5. package/dist/cjs/flag.js +62 -69
  6. package/dist/cjs/internal/dismiss-button.js +25 -38
  7. package/dist/cjs/internal/expander.js +25 -26
  8. package/dist/cjs/internal/index.js +0 -16
  9. package/dist/cjs/theme.js +50 -169
  10. package/dist/cjs/version.json +1 -1
  11. package/dist/es2019/auto-dismiss-flag.js +1 -1
  12. package/dist/es2019/flag-actions.js +18 -38
  13. package/dist/es2019/flag-group.js +14 -8
  14. package/dist/es2019/flag.js +62 -67
  15. package/dist/es2019/internal/dismiss-button.js +26 -36
  16. package/dist/es2019/internal/expander.js +20 -23
  17. package/dist/es2019/internal/index.js +0 -2
  18. package/dist/es2019/theme.js +47 -141
  19. package/dist/es2019/version.json +1 -1
  20. package/dist/esm/auto-dismiss-flag.js +1 -1
  21. package/dist/esm/flag-actions.js +18 -38
  22. package/dist/esm/flag-group.js +14 -8
  23. package/dist/esm/flag.js +62 -68
  24. package/dist/esm/internal/dismiss-button.js +26 -37
  25. package/dist/esm/internal/expander.js +21 -24
  26. package/dist/esm/internal/index.js +0 -2
  27. package/dist/esm/theme.js +49 -155
  28. package/dist/esm/version.json +1 -1
  29. package/dist/types/flag-actions.d.ts +2 -5
  30. package/dist/types/flag.d.ts +3 -2
  31. package/dist/types/internal/expander.d.ts +2 -3
  32. package/dist/types/internal/index.d.ts +0 -2
  33. package/dist/types/theme.d.ts +14 -9
  34. package/package.json +9 -15
  35. package/report.api.md +62 -148
  36. package/dist/cjs/internal/description.js +0 -34
  37. package/dist/cjs/internal/title.js +0 -30
  38. package/dist/es2019/internal/description.js +0 -24
  39. package/dist/es2019/internal/title.js +0 -20
  40. package/dist/esm/internal/description.js +0 -25
  41. package/dist/esm/internal/title.js +0 -21
  42. package/dist/types/internal/description.d.ts +0 -8
  43. package/dist/types/internal/title.d.ts +0 -6
  44. package/dist/types-ts4.0/auto-dismiss-flag.d.ts +0 -13
  45. package/dist/types-ts4.0/constants.d.ts +0 -2
  46. package/dist/types-ts4.0/flag-actions.d.ts +0 -15
  47. package/dist/types-ts4.0/flag-group.d.ts +0 -45
  48. package/dist/types-ts4.0/flag-provider.d.ts +0 -33
  49. package/dist/types-ts4.0/flag.d.ts +0 -14
  50. package/dist/types-ts4.0/index.d.ts +0 -6
  51. package/dist/types-ts4.0/internal/description.d.ts +0 -8
  52. package/dist/types-ts4.0/internal/dismiss-button.d.ts +0 -12
  53. package/dist/types-ts4.0/internal/expander.d.ts +0 -8
  54. package/dist/types-ts4.0/internal/index.d.ts +0 -4
  55. package/dist/types-ts4.0/internal/title.d.ts +0 -6
  56. package/dist/types-ts4.0/theme.d.ts +0 -10
  57. package/dist/types-ts4.0/types.d.ts +0 -101
package/dist/cjs/theme.js CHANGED
@@ -3,187 +3,68 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.getFlagTextColor = exports.getFlagIconColor = exports.getFlagFocusRingColor = exports.getFlagBackgroundColor = exports.getActionColor = exports.getActionBackground = exports.flagShadowColor = exports.flagBorderColor = void 0;
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
- light: "var(--ds-background-danger-bold, ".concat(_colors.R400, ")"),
13
- dark: "var(--ds-background-danger-bold, ".concat(_colors.R300, ")")
14
- },
15
- info: {
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
- light: "var(--ds-icon-inverse, ".concat(_colors.N0, ")"),
50
- dark: "var(--ds-icon-inverse, ".concat(_colors.DN40, ")")
51
- },
52
- info: {
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
- var getFlagTextColor = function getFlagTextColor(appearance, mode) {
93
- return flagTextColor[appearance][mode];
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
- exports.getFlagTextColor = getFlagTextColor;
97
-
98
- var getFlagIconColor = function getFlagIconColor(appearance, mode) {
99
- return flagIconColor[appearance][mode];
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
- light: "var(--ds-border-focused, ".concat(_colors.N40, ")"),
106
- dark: "var(--ds-border-focused, ".concat(_colors.N40, ")")
107
- },
108
- info: {
109
- light: "var(--ds-border-focused, ".concat(_colors.N40, ")"),
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
- var actionBackground = {
135
- success: {
136
- light: "var(--ds-background-neutral, ".concat(lightButtonBackground, ")"),
137
- dark: "var(--ds-background-neutral, ".concat(_colors.N30A, ")")
138
- },
139
- info: {
140
- light: "var(--ds-background-neutral, ".concat(lightButtonBackground, ")"),
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
- var actionColor = {
157
- success: {
158
- light: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
159
- dark: "var(--ds-text-inverse, ".concat(_colors.DN40, ")")
160
- },
161
- info: {
162
- light: "var(--ds-text-inverse, ".concat(_colors.N0, ")"),
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;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/flag",
3
- "version": "14.7.2",
3
+ "version": "15.0.0",
4
4
  "sideEffects": false
5
5
  }
@@ -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 = "14.7.2";
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 { getActionBackground, getActionColor, getFlagFocusRingColor } from './theme';
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 appeanceNormalButtonStyles = css({
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("div", {
68
- css: [actionContainerStyles, isBold && boldActionContainerStyles],
69
- "data-testid": testId && `${testId}-actions`
70
- }, actions.map((action, index) => [index && !isBold ? jsx("div", {
71
- css: separatorStyles,
72
- key: index + 0.5
73
- }, "\xB7") : '', jsx(Button, {
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': getActionColor(appearance, mode),
84
- '--bg-color': getActionBackground(appearance, mode),
85
- '--focus-color': getFlagFocusRingColor(appearance, mode)
63
+ '--color': actionTextColor[appearance],
64
+ '--bg-color': actionBackgroundColor[appearance],
65
+ '--focus-color': flagFocusRingColor[appearance]
86
66
  },
87
- css: [buttonStyles, isBold && isBoldButtonStyles, appearance === 'normal' && appeanceNormalButtonStyles]
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
- }, props => jsx("div", _extends({}, props, {
105
- css: [baseStyles, isDismissAllowed && dismissAllowedStyles]
106
- }), jsx(FlagGroupContext.Provider, {
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("div", {
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, {
@@ -2,46 +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 { css, jsx } from '@emotion/react';
6
- import { useGlobalTheme } from '@atlaskit/theme/components';
7
- import { borderRadius, gridSize as getGridSize, 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';
8
7
  import { usePlatformLeafEventHandler } from '@atlaskit/analytics-next/usePlatformLeafEventHandler';
9
8
  import noop from '@atlaskit/ds-lib/noop';
10
9
  import FocusRing from '@atlaskit/focus-ring';
11
10
  import { DEFAULT_APPEARANCE } from './constants';
12
- import { flagBorderColor, flagShadowColor, getFlagBackgroundColor, getFlagTextColor, getFlagIconColor } from './theme';
11
+ import { flagTextColor, flagBackgroundColor, flagIconColor } from './theme';
13
12
  import Actions from './flag-actions';
14
13
  import { useFlagGroup } from './flag-group';
15
- import { Title, Description, Expander, DismissButton } from './internal';
14
+ import { Expander, DismissButton } from './internal';
16
15
  const analyticsAttributes = {
17
16
  componentName: 'flag',
18
17
  packageName: "@atlaskit/flag",
19
- packageVersion: "14.7.2"
18
+ packageVersion: "15.0.0"
20
19
  };
21
- const gridSize = getGridSize();
22
- const doubleGridSize = gridSize * 2;
23
- const titleGroupStyles = css({
24
- display: 'flex',
25
- alignItems: 'start'
26
- });
27
- const iconTitleStyles = css({
28
- display: 'flex',
29
- paddingTop: `${gridSize / 2}px`,
30
- alignItems: 'start',
31
- flex: 1
32
- });
33
- const flagHeaderStyles = css({
34
- boxSizing: 'border-box',
35
- width: '100%',
36
- padding: doubleGridSize,
37
- borderRadius: borderRadius()
38
- });
39
- const flagContainerStyles = css({
40
- width: '100%',
41
- zIndex: layers.flag(),
42
- borderRadius: borderRadius(),
43
- transition: 'background-color 200ms'
44
- });
45
20
  /**
46
21
  * __Flag__
47
22
  *
@@ -118,41 +93,55 @@ const Flag = props => {
118
93
  onMouseOut,
119
94
  onBlur: onBlurAnalytics
120
95
  };
121
- let boxShadowValue = `0 20px 32px -8px ${flagShadowColor}`;
122
-
123
- if (!isBold) {
124
- boxShadowValue = `0 0 1px ${flagBorderColor}, ${boxShadowValue}`;
125
- }
126
-
127
- const boxShadow = `var(--ds-shadow-overlay, ${boxShadowValue})`;
128
- const {
129
- mode
130
- } = useGlobalTheme();
131
- const textColor = getFlagTextColor(appearance, mode);
132
- const iconColor = getFlagIconColor(appearance, mode);
96
+ const textColor = flagTextColor[appearance];
97
+ const iconColor = flagIconColor[appearance];
133
98
  const isDismissable = isBold || isDismissAllowed;
134
- return jsx("div", _extends({
135
- style: {
136
- color: textColor,
137
- backgroundColor: getFlagBackgroundColor(appearance, mode),
138
- boxShadow
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'
139
111
  },
140
- css: flagContainerStyles,
141
112
  role: "alert",
142
- "data-testid": testId
143
- }, autoDismissProps), jsx(FocusRing, null, jsx("div", {
144
- css: flagHeaderStyles // eslint-disable-next-line jsx-a11y/no-noninteractive-tabindex
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
145
125
  ,
146
- tabIndex: 0
147
- }, jsx("div", {
148
- style: {
149
- color: iconColor
150
- },
151
- css: titleGroupStyles
152
- }, jsx("div", {
153
- css: iconTitleStyles
154
- }, icon, jsx(Title, {
155
- color: textColor
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
+ }
156
145
  }, title)), isDismissable ? !(isBold && !description && !actions.length) && jsx(DismissButton, {
157
146
  testId: testId,
158
147
  appearance: appearance,
@@ -162,17 +151,23 @@ const Flag = props => {
162
151
  }) : null), jsx(Expander, {
163
152
  isExpanded: !isBold || isExpanded,
164
153
  testId: testId
165
- }, description && jsx(Description, {
166
- testId: testId && `${testId}-description`,
154
+ }, description && jsx(Text, {
155
+ as: "div",
167
156
  color: textColor,
168
- isBold: isBold
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`
169
165
  }, description), jsx(Actions, {
170
166
  actions: actions,
171
167
  appearance: appearance,
172
168
  linkComponent: linkComponent,
173
- testId: testId,
174
- mode: mode
175
- })))));
169
+ testId: testId
170
+ }))))));
176
171
  };
177
172
 
178
173
  export default Flag;
@@ -1,30 +1,12 @@
1
1
  /** @jsx jsx */
2
2
  import { memo } from 'react';
3
- import { jsx, css } from '@emotion/react';
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 { borderRadius as getBorderRadius, gridSize as getGridSize } from '@atlaskit/theme/constants';
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 = 'large';
26
+ size = 'medium';
48
27
  buttonTestId = testId && `${testId}-toggle`;
49
28
  }
50
29
 
51
- return jsx(FocusRing, null, jsx("button", {
52
- style: {
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
- "aria-expanded": isBold ? isExpanded : undefined
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