@kaizen/components 2.3.2 → 2.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/src/TitleBlock/TitleBlock.cjs +8 -2
- package/dist/cjs/src/TitleBlock/subcomponents/MainActions.cjs +15 -4
- package/dist/cjs/src/TitleBlock/subcomponents/SecondaryActions.cjs +24 -6
- package/dist/esm/src/TitleBlock/TitleBlock.mjs +8 -2
- package/dist/esm/src/TitleBlock/subcomponents/MainActions.mjs +15 -4
- package/dist/esm/src/TitleBlock/subcomponents/SecondaryActions.mjs +24 -6
- package/dist/styles.css +8 -11
- package/locales/en.json +24 -4
- package/package.json +1 -1
- package/src/TitleBlock/TitleBlock.module.scss +7 -9
- package/src/TitleBlock/TitleBlock.tsx +12 -2
- package/src/TitleBlock/_docs/TitleBlock.stories.tsx +248 -5
- package/src/TitleBlock/subcomponents/MainActions.tsx +17 -3
- package/src/TitleBlock/subcomponents/SecondaryActions.tsx +35 -3
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var i18nReactIntl = require('@cultureamp/i18n-react-intl');
|
|
5
6
|
var classnames = require('classnames');
|
|
6
7
|
var Avatar = require('../Avatar/Avatar.cjs');
|
|
7
8
|
require('../ButtonV1/Button/Button.cjs');
|
|
@@ -212,6 +213,7 @@ var TitleBlock = function (_a) {
|
|
|
212
213
|
isSmall = _o.isSmall,
|
|
213
214
|
isMedium = _o.isMedium;
|
|
214
215
|
var isSmallOrMediumViewport = isMedium || isSmall;
|
|
216
|
+
var formatMessage = i18nReactIntl.useIntl().formatMessage;
|
|
215
217
|
return React__default.default.createElement(React__default.default.Fragment, null, React__default.default.createElement("div", {
|
|
216
218
|
id: id,
|
|
217
219
|
className: classnames__default.default(TitleBlock_module.titleBlock, TitleBlock_module["".concat(variant, "Variant")], Boolean(subtitle) && TitleBlock_module.hasSubtitle, Boolean(pageSwitcherSelect) && TitleBlock_module.hasPageSwitcherSelect, collapseNavigationArea && !((_b = sectionTitle !== null && sectionTitle !== void 0 ? sectionTitle : sectionTitleDescription) !== null && _b !== void 0 ? _b : renderSectionTitle) && TitleBlock_module.collapseNavigationArea, title && title.length >= 30 && TitleBlock_module.hasLongTitle, subtitle && typeof subtitle === 'string' && subtitle.length >= 18 && TitleBlock_module.hasLongSubtitle, hasNavigationTabs && TitleBlock_module.hasNavigationTabs)
|
|
@@ -238,7 +240,11 @@ var TitleBlock = function (_a) {
|
|
|
238
240
|
name: "menu",
|
|
239
241
|
isPresentational: true
|
|
240
242
|
}),
|
|
241
|
-
label:
|
|
243
|
+
label: formatMessage({
|
|
244
|
+
id: 'kzTitleBlock.hamburgerMenuLabel',
|
|
245
|
+
defaultMessage: 'Open menu',
|
|
246
|
+
description: 'Label for the dropdown menu which displays navigation items'
|
|
247
|
+
}),
|
|
242
248
|
reversed: utils.isReversed(variant)
|
|
243
249
|
})), avatar && renderAvatar(avatar, avatarAutomationId), React__default.default.createElement("div", {
|
|
244
250
|
className: TitleBlock_module.titleAndSubtitle
|
|
@@ -284,7 +290,7 @@ var TitleBlock = function (_a) {
|
|
|
284
290
|
sectionTitleAutomationId: sectionTitleAutomationId,
|
|
285
291
|
sectionTitleDescription: sectionTitleDescription,
|
|
286
292
|
sectionTitleDescriptionAutomationId: sectionTitleDescriptionAutomationId
|
|
287
|
-
}) : defaultRenderSectionTitle(sectionTitle, sectionTitleDescription, variant, sectionTitleAutomationId, sectionTitleDescriptionAutomationId))), renderNavigationTabs(navigationTabs, collapseNavigationArea, title), (secondaryActions !== null && secondaryActions !== void 0 ? secondaryActions : secondaryOverflowMenuItems) && React__default.default.createElement(SecondaryActions.SecondaryActions, {
|
|
293
|
+
}) : defaultRenderSectionTitle(sectionTitle, sectionTitleDescription, variant, sectionTitleAutomationId, sectionTitleDescriptionAutomationId))), !sectionTitle && !sectionTitleDescription && !renderSectionTitle && renderNavigationTabs(navigationTabs, collapseNavigationArea, title), (secondaryActions !== null && secondaryActions !== void 0 ? secondaryActions : secondaryOverflowMenuItems) && React__default.default.createElement(SecondaryActions.SecondaryActions, {
|
|
288
294
|
secondaryActions: secondaryActions,
|
|
289
295
|
secondaryOverflowMenuItems: secondaryOverflowMenuItems,
|
|
290
296
|
reversed: utils.isReversed(variant)
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var i18nReactIntl = require('@cultureamp/i18n-react-intl');
|
|
5
6
|
var Button = require('../../ButtonV1/Button/Button.cjs');
|
|
6
7
|
var IconButton = require('../../ButtonV1/IconButton/IconButton.cjs');
|
|
7
8
|
var Icon = require('../../Icon/Icon.cjs');
|
|
@@ -19,12 +20,12 @@ function _interopDefault(e) {
|
|
|
19
20
|
};
|
|
20
21
|
}
|
|
21
22
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
22
|
-
var renderSecondaryAndOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
|
|
23
|
+
var renderSecondaryAndOverflowMenu = function (secondaryAndOverflowMenuLabel, secondaryOverflowMenuItems, reversed) {
|
|
23
24
|
if (!secondaryOverflowMenuItems) return undefined;
|
|
24
25
|
return React__default.default.createElement(index.Menu, {
|
|
25
26
|
align: "right",
|
|
26
27
|
button: React__default.default.createElement(IconButton.IconButton, {
|
|
27
|
-
label:
|
|
28
|
+
label: secondaryAndOverflowMenuLabel,
|
|
28
29
|
reversed: reversed,
|
|
29
30
|
icon: React__default.default.createElement(Icon.Icon, {
|
|
30
31
|
name: "more_horiz",
|
|
@@ -47,6 +48,12 @@ var MainActions = function (_a) {
|
|
|
47
48
|
secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
|
|
48
49
|
_e = _a.reversed,
|
|
49
50
|
reversed = _e === void 0 ? false : _e;
|
|
51
|
+
var formatMessage = i18nReactIntl.useIntl().formatMessage;
|
|
52
|
+
var secondaryAndOverflowMenuLabel = formatMessage({
|
|
53
|
+
id: 'kzTitleBlock.secondaryAndOverflowMenuLabel',
|
|
54
|
+
defaultMessage: 'Open secondary and overflow menu',
|
|
55
|
+
description: 'Label for the dropdown menu which displays additional actions'
|
|
56
|
+
});
|
|
50
57
|
var items;
|
|
51
58
|
// Build combined secondary + overflow menu items once, to be spread into the toolbar items
|
|
52
59
|
var secondaryAndOverflowMenu = [];
|
|
@@ -77,7 +84,7 @@ var MainActions = function (_a) {
|
|
|
77
84
|
if (allMenuItems.length > 0) {
|
|
78
85
|
secondaryAndOverflowMenu.push({
|
|
79
86
|
key: 'overflowMenu',
|
|
80
|
-
node: renderSecondaryAndOverflowMenu(allMenuItems, reversed)
|
|
87
|
+
node: renderSecondaryAndOverflowMenu(secondaryAndOverflowMenuLabel, allMenuItems, reversed)
|
|
81
88
|
});
|
|
82
89
|
}
|
|
83
90
|
var defaultActionItem = defaultAction ? [{
|
|
@@ -97,7 +104,11 @@ var MainActions = function (_a) {
|
|
|
97
104
|
}, React__default.default.createElement(index.Menu, {
|
|
98
105
|
align: "right",
|
|
99
106
|
button: React__default.default.createElement(IconButton.IconButton, {
|
|
100
|
-
label:
|
|
107
|
+
label: formatMessage({
|
|
108
|
+
id: 'kzTitleBlock.defaultActionMinimizedOverflowMenuLabel',
|
|
109
|
+
defaultMessage: 'Open default action overflow menu',
|
|
110
|
+
description: 'Label for the dropdown menu which displays the default action item'
|
|
111
|
+
}),
|
|
101
112
|
reversed: reversed,
|
|
102
113
|
icon: React__default.default.createElement(Icon.Icon, {
|
|
103
114
|
name: "more_horiz",
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
var tslib = require('tslib');
|
|
4
4
|
var React = require('react');
|
|
5
|
+
var i18nReactIntl = require('@cultureamp/i18n-react-intl');
|
|
5
6
|
var Button = require('../../ButtonV1/Button/Button.cjs');
|
|
6
7
|
var IconButton = require('../../ButtonV1/IconButton/IconButton.cjs');
|
|
7
8
|
var Icon = require('../../Icon/Icon.cjs');
|
|
@@ -17,7 +18,7 @@ function _interopDefault(e) {
|
|
|
17
18
|
};
|
|
18
19
|
}
|
|
19
20
|
var React__default = /*#__PURE__*/_interopDefault(React);
|
|
20
|
-
var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
|
|
21
|
+
var renderSecondaryOverflowMenu = function (menuAriaLabel, menuLabel, secondaryOverflowMenuItems, reversed) {
|
|
21
22
|
if (!secondaryOverflowMenuItems || secondaryOverflowMenuItems.length === 0) return undefined;
|
|
22
23
|
return React__default.default.createElement("div", {
|
|
23
24
|
className: TitleBlock_module.secondaryOverflowMenu
|
|
@@ -26,7 +27,8 @@ var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed
|
|
|
26
27
|
button: React__default.default.createElement(Button.Button, {
|
|
27
28
|
secondary: true,
|
|
28
29
|
reversed: reversed,
|
|
29
|
-
label:
|
|
30
|
+
label: menuLabel,
|
|
31
|
+
"aria-label": menuAriaLabel,
|
|
30
32
|
"data-automation-id": constants.TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
31
33
|
"data-testid": constants.TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
32
34
|
icon: React__default.default.createElement(Icon.Icon, {
|
|
@@ -42,7 +44,7 @@ var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed
|
|
|
42
44
|
}))));
|
|
43
45
|
};
|
|
44
46
|
// New: combined overflow menu (secondary actions converted + overflow menu items)
|
|
45
|
-
var renderCombinedSecondaryOverflowMenu = function (secondaryActions, secondaryOverflowMenuItems, reversed) {
|
|
47
|
+
var renderCombinedSecondaryOverflowMenu = function (combinedMenuLabel, secondaryActions, secondaryOverflowMenuItems, reversed) {
|
|
46
48
|
var secondaryConverted = secondaryActions ? utils.convertSecondaryActionsToMenuItems(secondaryActions) : [];
|
|
47
49
|
var overflowItems = secondaryOverflowMenuItems !== null && secondaryOverflowMenuItems !== void 0 ? secondaryOverflowMenuItems : [];
|
|
48
50
|
if (secondaryConverted.length === 0 && overflowItems.length === 0) return undefined;
|
|
@@ -52,7 +54,7 @@ var renderCombinedSecondaryOverflowMenu = function (secondaryActions, secondaryO
|
|
|
52
54
|
}, React__default.default.createElement(index.Menu, {
|
|
53
55
|
align: "right",
|
|
54
56
|
button: React__default.default.createElement(IconButton.IconButton, {
|
|
55
|
-
label:
|
|
57
|
+
label: combinedMenuLabel,
|
|
56
58
|
reversed: reversed,
|
|
57
59
|
icon: React__default.default.createElement(Icon.Icon, {
|
|
58
60
|
name: "more_horiz",
|
|
@@ -74,7 +76,23 @@ var SecondaryActions = function (_a) {
|
|
|
74
76
|
secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
|
|
75
77
|
_b = _a.reversed,
|
|
76
78
|
reversed = _b === void 0 ? false : _b;
|
|
79
|
+
var formatMessage = i18nReactIntl.useIntl().formatMessage;
|
|
77
80
|
if (!secondaryActions && !secondaryOverflowMenuItems) return null;
|
|
81
|
+
var menuLabel = formatMessage({
|
|
82
|
+
id: 'kzTitleBlock.overflowMenuLabel',
|
|
83
|
+
defaultMessage: 'Menu',
|
|
84
|
+
description: 'Label for the dropdown menu which displays additional action items'
|
|
85
|
+
});
|
|
86
|
+
var menuAriaLabel = formatMessage({
|
|
87
|
+
id: 'kzTitleBlock.overflowMenuAriaLabel',
|
|
88
|
+
defaultMessage: 'Opens overflow menu',
|
|
89
|
+
description: 'Aria Label for the dropdown menu which displays additional action items'
|
|
90
|
+
});
|
|
91
|
+
var combinedMenuLabel = formatMessage({
|
|
92
|
+
id: 'kzTitleBlock.combinedOverflowMenuLabel',
|
|
93
|
+
defaultMessage: 'Open combined secondary and overflow menu',
|
|
94
|
+
description: 'Label for the dropdown menu which displays additional action items and secondary actions'
|
|
95
|
+
});
|
|
78
96
|
var secondaryActionsAsToolbarItems = secondaryActions ? secondaryActions.map(function (action, i) {
|
|
79
97
|
if ('menuItems' in action) {
|
|
80
98
|
return {
|
|
@@ -118,8 +136,8 @@ var SecondaryActions = function (_a) {
|
|
|
118
136
|
};
|
|
119
137
|
}
|
|
120
138
|
}) : [];
|
|
121
|
-
var overflowMenu = renderSecondaryOverflowMenu(secondaryOverflowMenuItems, reversed);
|
|
122
|
-
var combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(secondaryActions, secondaryOverflowMenuItems, reversed);
|
|
139
|
+
var overflowMenu = renderSecondaryOverflowMenu(menuAriaLabel, menuLabel, secondaryOverflowMenuItems, reversed);
|
|
140
|
+
var combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(combinedMenuLabel, secondaryActions, secondaryOverflowMenuItems, reversed);
|
|
123
141
|
var toolbarItems = tslib.__spreadArray(tslib.__spreadArray(tslib.__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
|
|
124
142
|
key: 'overflowMenu',
|
|
125
143
|
node: overflowMenu
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __assign } from 'tslib';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useIntl } from '@cultureamp/i18n-react-intl';
|
|
3
4
|
import classnames from 'classnames';
|
|
4
5
|
import { Avatar } from '../Avatar/Avatar.mjs';
|
|
5
6
|
import '../ButtonV1/Button/Button.mjs';
|
|
@@ -204,6 +205,7 @@ const TitleBlock = /*#__PURE__*/function () {
|
|
|
204
205
|
isSmall = _o.isSmall,
|
|
205
206
|
isMedium = _o.isMedium;
|
|
206
207
|
var isSmallOrMediumViewport = isMedium || isSmall;
|
|
208
|
+
var formatMessage = useIntl().formatMessage;
|
|
207
209
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
|
|
208
210
|
id: id,
|
|
209
211
|
className: classnames(styles.titleBlock, styles["".concat(variant, "Variant")], Boolean(subtitle) && styles.hasSubtitle, Boolean(pageSwitcherSelect) && styles.hasPageSwitcherSelect, collapseNavigationArea && !((_b = sectionTitle !== null && sectionTitle !== void 0 ? sectionTitle : sectionTitleDescription) !== null && _b !== void 0 ? _b : renderSectionTitle) && styles.collapseNavigationArea, title && title.length >= 30 && styles.hasLongTitle, subtitle && typeof subtitle === 'string' && subtitle.length >= 18 && styles.hasLongSubtitle, hasNavigationTabs && styles.hasNavigationTabs)
|
|
@@ -230,7 +232,11 @@ const TitleBlock = /*#__PURE__*/function () {
|
|
|
230
232
|
name: "menu",
|
|
231
233
|
isPresentational: true
|
|
232
234
|
}),
|
|
233
|
-
label:
|
|
235
|
+
label: formatMessage({
|
|
236
|
+
id: 'kzTitleBlock.hamburgerMenuLabel',
|
|
237
|
+
defaultMessage: 'Open menu',
|
|
238
|
+
description: 'Label for the dropdown menu which displays navigation items'
|
|
239
|
+
}),
|
|
234
240
|
reversed: isReversed(variant)
|
|
235
241
|
}))), avatar && renderAvatar(avatar, avatarAutomationId), /*#__PURE__*/React.createElement("div", {
|
|
236
242
|
className: styles.titleAndSubtitle
|
|
@@ -276,7 +282,7 @@ const TitleBlock = /*#__PURE__*/function () {
|
|
|
276
282
|
sectionTitleAutomationId: sectionTitleAutomationId,
|
|
277
283
|
sectionTitleDescription: sectionTitleDescription,
|
|
278
284
|
sectionTitleDescriptionAutomationId: sectionTitleDescriptionAutomationId
|
|
279
|
-
}) : defaultRenderSectionTitle(sectionTitle, sectionTitleDescription, variant, sectionTitleAutomationId, sectionTitleDescriptionAutomationId)))), renderNavigationTabs(navigationTabs, collapseNavigationArea, title), (secondaryActions !== null && secondaryActions !== void 0 ? secondaryActions : secondaryOverflowMenuItems) && (/*#__PURE__*/React.createElement(SecondaryActions, {
|
|
285
|
+
}) : defaultRenderSectionTitle(sectionTitle, sectionTitleDescription, variant, sectionTitleAutomationId, sectionTitleDescriptionAutomationId)))), !sectionTitle && !sectionTitleDescription && !renderSectionTitle && renderNavigationTabs(navigationTabs, collapseNavigationArea, title), (secondaryActions !== null && secondaryActions !== void 0 ? secondaryActions : secondaryOverflowMenuItems) && (/*#__PURE__*/React.createElement(SecondaryActions, {
|
|
280
286
|
secondaryActions: secondaryActions,
|
|
281
287
|
secondaryOverflowMenuItems: secondaryOverflowMenuItems,
|
|
282
288
|
reversed: isReversed(variant)
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __spreadArray, __assign } from 'tslib';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useIntl } from '@cultureamp/i18n-react-intl';
|
|
3
4
|
import { Button } from '../../ButtonV1/Button/Button.mjs';
|
|
4
5
|
import { IconButton } from '../../ButtonV1/IconButton/IconButton.mjs';
|
|
5
6
|
import { Icon } from '../../Icon/Icon.mjs';
|
|
@@ -11,12 +12,12 @@ import { createTabletOverflowMenuItems, isMenuGroupNotButton } from '../utils.mj
|
|
|
11
12
|
import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
|
|
12
13
|
import { Toolbar } from './Toolbar.mjs';
|
|
13
14
|
import styles from './MainActions.module.scss.mjs';
|
|
14
|
-
var renderSecondaryAndOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
|
|
15
|
+
var renderSecondaryAndOverflowMenu = function (secondaryAndOverflowMenuLabel, secondaryOverflowMenuItems, reversed) {
|
|
15
16
|
if (!secondaryOverflowMenuItems) return undefined;
|
|
16
17
|
return /*#__PURE__*/React.createElement(Menu, {
|
|
17
18
|
align: "right",
|
|
18
19
|
button: /*#__PURE__*/React.createElement(IconButton, {
|
|
19
|
-
label:
|
|
20
|
+
label: secondaryAndOverflowMenuLabel,
|
|
20
21
|
reversed: reversed,
|
|
21
22
|
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
22
23
|
name: "more_horiz",
|
|
@@ -40,6 +41,12 @@ const MainActions = /*#__PURE__*/function () {
|
|
|
40
41
|
secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
|
|
41
42
|
_e = _a.reversed,
|
|
42
43
|
reversed = _e === void 0 ? false : _e;
|
|
44
|
+
var formatMessage = useIntl().formatMessage;
|
|
45
|
+
var secondaryAndOverflowMenuLabel = formatMessage({
|
|
46
|
+
id: 'kzTitleBlock.secondaryAndOverflowMenuLabel',
|
|
47
|
+
defaultMessage: 'Open secondary and overflow menu',
|
|
48
|
+
description: 'Label for the dropdown menu which displays additional actions'
|
|
49
|
+
});
|
|
43
50
|
var items;
|
|
44
51
|
// Build combined secondary + overflow menu items once, to be spread into the toolbar items
|
|
45
52
|
var secondaryAndOverflowMenu = [];
|
|
@@ -70,7 +77,7 @@ const MainActions = /*#__PURE__*/function () {
|
|
|
70
77
|
if (allMenuItems.length > 0) {
|
|
71
78
|
secondaryAndOverflowMenu.push({
|
|
72
79
|
key: 'overflowMenu',
|
|
73
|
-
node: renderSecondaryAndOverflowMenu(allMenuItems, reversed)
|
|
80
|
+
node: renderSecondaryAndOverflowMenu(secondaryAndOverflowMenuLabel, allMenuItems, reversed)
|
|
74
81
|
});
|
|
75
82
|
}
|
|
76
83
|
var defaultActionItem = defaultAction ? [{
|
|
@@ -90,7 +97,11 @@ const MainActions = /*#__PURE__*/function () {
|
|
|
90
97
|
}, /*#__PURE__*/React.createElement(Menu, {
|
|
91
98
|
align: "right",
|
|
92
99
|
button: /*#__PURE__*/React.createElement(IconButton, {
|
|
93
|
-
label:
|
|
100
|
+
label: formatMessage({
|
|
101
|
+
id: 'kzTitleBlock.defaultActionMinimizedOverflowMenuLabel',
|
|
102
|
+
defaultMessage: 'Open default action overflow menu',
|
|
103
|
+
description: 'Label for the dropdown menu which displays the default action item'
|
|
104
|
+
}),
|
|
94
105
|
reversed: reversed,
|
|
95
106
|
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
96
107
|
name: "more_horiz",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { __assign, __spreadArray } from 'tslib';
|
|
2
2
|
import React from 'react';
|
|
3
|
+
import { useIntl } from '@cultureamp/i18n-react-intl';
|
|
3
4
|
import { Button } from '../../ButtonV1/Button/Button.mjs';
|
|
4
5
|
import { IconButton } from '../../ButtonV1/IconButton/IconButton.mjs';
|
|
5
6
|
import { Icon } from '../../Icon/Icon.mjs';
|
|
@@ -9,7 +10,7 @@ import { TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID } from '../constants.mjs';
|
|
|
9
10
|
import { convertSecondaryActionsToMenuItems } from '../utils.mjs';
|
|
10
11
|
import { TitleBlockMenuItem } from './TitleBlockMenuItem.mjs';
|
|
11
12
|
import { Toolbar } from './Toolbar.mjs';
|
|
12
|
-
var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed) {
|
|
13
|
+
var renderSecondaryOverflowMenu = function (menuAriaLabel, menuLabel, secondaryOverflowMenuItems, reversed) {
|
|
13
14
|
if (!secondaryOverflowMenuItems || secondaryOverflowMenuItems.length === 0) return undefined;
|
|
14
15
|
return /*#__PURE__*/React.createElement("div", {
|
|
15
16
|
className: styles.secondaryOverflowMenu
|
|
@@ -18,7 +19,8 @@ var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed
|
|
|
18
19
|
button: /*#__PURE__*/React.createElement(Button, {
|
|
19
20
|
secondary: true,
|
|
20
21
|
reversed: reversed,
|
|
21
|
-
label:
|
|
22
|
+
label: menuLabel,
|
|
23
|
+
"aria-label": menuAriaLabel,
|
|
22
24
|
"data-automation-id": TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
23
25
|
"data-testid": TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID,
|
|
24
26
|
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
@@ -34,7 +36,7 @@ var renderSecondaryOverflowMenu = function (secondaryOverflowMenuItems, reversed
|
|
|
34
36
|
}))));
|
|
35
37
|
};
|
|
36
38
|
// New: combined overflow menu (secondary actions converted + overflow menu items)
|
|
37
|
-
var renderCombinedSecondaryOverflowMenu = function (secondaryActions, secondaryOverflowMenuItems, reversed) {
|
|
39
|
+
var renderCombinedSecondaryOverflowMenu = function (combinedMenuLabel, secondaryActions, secondaryOverflowMenuItems, reversed) {
|
|
38
40
|
var secondaryConverted = secondaryActions ? convertSecondaryActionsToMenuItems(secondaryActions) : [];
|
|
39
41
|
var overflowItems = secondaryOverflowMenuItems !== null && secondaryOverflowMenuItems !== void 0 ? secondaryOverflowMenuItems : [];
|
|
40
42
|
if (secondaryConverted.length === 0 && overflowItems.length === 0) return undefined;
|
|
@@ -44,7 +46,7 @@ var renderCombinedSecondaryOverflowMenu = function (secondaryActions, secondaryO
|
|
|
44
46
|
}, /*#__PURE__*/React.createElement(Menu, {
|
|
45
47
|
align: "right",
|
|
46
48
|
button: /*#__PURE__*/React.createElement(IconButton, {
|
|
47
|
-
label:
|
|
49
|
+
label: combinedMenuLabel,
|
|
48
50
|
reversed: reversed,
|
|
49
51
|
icon: /*#__PURE__*/React.createElement(Icon, {
|
|
50
52
|
name: "more_horiz",
|
|
@@ -67,7 +69,23 @@ const SecondaryActions = /*#__PURE__*/function () {
|
|
|
67
69
|
secondaryOverflowMenuItems = _a.secondaryOverflowMenuItems,
|
|
68
70
|
_b = _a.reversed,
|
|
69
71
|
reversed = _b === void 0 ? false : _b;
|
|
72
|
+
var formatMessage = useIntl().formatMessage;
|
|
70
73
|
if (!secondaryActions && !secondaryOverflowMenuItems) return null;
|
|
74
|
+
var menuLabel = formatMessage({
|
|
75
|
+
id: 'kzTitleBlock.overflowMenuLabel',
|
|
76
|
+
defaultMessage: 'Menu',
|
|
77
|
+
description: 'Label for the dropdown menu which displays additional action items'
|
|
78
|
+
});
|
|
79
|
+
var menuAriaLabel = formatMessage({
|
|
80
|
+
id: 'kzTitleBlock.overflowMenuAriaLabel',
|
|
81
|
+
defaultMessage: 'Opens overflow menu',
|
|
82
|
+
description: 'Aria Label for the dropdown menu which displays additional action items'
|
|
83
|
+
});
|
|
84
|
+
var combinedMenuLabel = formatMessage({
|
|
85
|
+
id: 'kzTitleBlock.combinedOverflowMenuLabel',
|
|
86
|
+
defaultMessage: 'Open combined secondary and overflow menu',
|
|
87
|
+
description: 'Label for the dropdown menu which displays additional action items and secondary actions'
|
|
88
|
+
});
|
|
71
89
|
var secondaryActionsAsToolbarItems = secondaryActions ? secondaryActions.map(function (action, i) {
|
|
72
90
|
if ('menuItems' in action) {
|
|
73
91
|
return {
|
|
@@ -111,8 +129,8 @@ const SecondaryActions = /*#__PURE__*/function () {
|
|
|
111
129
|
};
|
|
112
130
|
}
|
|
113
131
|
}) : [];
|
|
114
|
-
var overflowMenu = renderSecondaryOverflowMenu(secondaryOverflowMenuItems, reversed);
|
|
115
|
-
var combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(secondaryActions, secondaryOverflowMenuItems, reversed);
|
|
132
|
+
var overflowMenu = renderSecondaryOverflowMenu(menuAriaLabel, menuLabel, secondaryOverflowMenuItems, reversed);
|
|
133
|
+
var combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(combinedMenuLabel, secondaryActions, secondaryOverflowMenuItems, reversed);
|
|
116
134
|
var toolbarItems = __spreadArray(__spreadArray(__spreadArray([], secondaryActionsAsToolbarItems, true), overflowMenu ? [{
|
|
117
135
|
key: 'overflowMenu',
|
|
118
136
|
node: overflowMenu
|
package/dist/styles.css
CHANGED
|
@@ -10058,11 +10058,6 @@
|
|
|
10058
10058
|
width: 100%;
|
|
10059
10059
|
justify-content: center;
|
|
10060
10060
|
}
|
|
10061
|
-
@container (max-width: calc(768px - 1px)) {
|
|
10062
|
-
.TitleBlock-module_rowBelowSeparator__H4E63 {
|
|
10063
|
-
height: 3.75rem;
|
|
10064
|
-
}
|
|
10065
|
-
}
|
|
10066
10061
|
.TitleBlock-module_lightVariant__1EeLV .TitleBlock-module_titleRow__Ifqiu {
|
|
10067
10062
|
background-color: var(--color-white, #ffffff);
|
|
10068
10063
|
margin-bottom: 0.063rem;
|
|
@@ -10098,11 +10093,6 @@
|
|
|
10098
10093
|
margin-inline: 24px;
|
|
10099
10094
|
}
|
|
10100
10095
|
}
|
|
10101
|
-
@container (max-width: calc(768px - 1px)) {
|
|
10102
|
-
.TitleBlock-module_rowBelowSeparatorInner__3gNec {
|
|
10103
|
-
height: 3.75rem;
|
|
10104
|
-
}
|
|
10105
|
-
}
|
|
10106
10096
|
.TitleBlock-module_titleRowInnerContent__NhTHV {
|
|
10107
10097
|
box-sizing: border-box;
|
|
10108
10098
|
position: relative;
|
|
@@ -10258,7 +10248,6 @@
|
|
|
10258
10248
|
display: none;
|
|
10259
10249
|
align-self: self-start;
|
|
10260
10250
|
box-sizing: border-box;
|
|
10261
|
-
overflow: hidden;
|
|
10262
10251
|
height: 3rem;
|
|
10263
10252
|
width: 3rem;
|
|
10264
10253
|
margin-inline-end: calc(1.5rem / 2);
|
|
@@ -10268,6 +10257,7 @@
|
|
|
10268
10257
|
max-width: 100%;
|
|
10269
10258
|
}
|
|
10270
10259
|
.TitleBlock-module_avatar__mEjJ8.TitleBlock-module_withBorder__D8Mz2 {
|
|
10260
|
+
overflow: hidden;
|
|
10271
10261
|
border: 3px solid var(--color-white, #ffffff);
|
|
10272
10262
|
border-radius: 50%;
|
|
10273
10263
|
}
|
|
@@ -10338,14 +10328,21 @@
|
|
|
10338
10328
|
.TitleBlock-module_sectionTitleContainer__LrDPV {
|
|
10339
10329
|
display: flex;
|
|
10340
10330
|
align-items: center;
|
|
10331
|
+
padding-block: 9px;
|
|
10341
10332
|
padding-inline-end: 8px;
|
|
10342
10333
|
}
|
|
10334
|
+
@container (min-width: 1080px) {
|
|
10335
|
+
.TitleBlock-module_sectionTitleContainer__LrDPV {
|
|
10336
|
+
padding-block: 17px;
|
|
10337
|
+
}
|
|
10338
|
+
}
|
|
10343
10339
|
.TitleBlock-module_sectionTitle__b8daw {
|
|
10344
10340
|
display: block;
|
|
10345
10341
|
}
|
|
10346
10342
|
.TitleBlock-module_sectionTitleInner__nJfOP {
|
|
10347
10343
|
display: flex;
|
|
10348
10344
|
flex-direction: column;
|
|
10345
|
+
row-gap: 4px;
|
|
10349
10346
|
}
|
|
10350
10347
|
@container (min-width: 1080px) {
|
|
10351
10348
|
.TitleBlock-module_sectionTitleInner__nJfOP {
|
package/locales/en.json
CHANGED
|
@@ -221,6 +221,30 @@
|
|
|
221
221
|
"description": "Prompts user to interact with button to hide information",
|
|
222
222
|
"message": "Hide information:"
|
|
223
223
|
},
|
|
224
|
+
"kzTitleBlock.combinedOverflowMenuLabel": {
|
|
225
|
+
"description": "Label for the dropdown menu which displays additional action items and secondary actions",
|
|
226
|
+
"message": "Open combined secondary and overflow menu"
|
|
227
|
+
},
|
|
228
|
+
"kzTitleBlock.defaultActionMinimizedOverflowMenuLabel": {
|
|
229
|
+
"description": "Label for the dropdown menu which displays the default action item",
|
|
230
|
+
"message": "Open default action overflow menu"
|
|
231
|
+
},
|
|
232
|
+
"kzTitleBlock.hamburgerMenuLabel": {
|
|
233
|
+
"description": "Label for the dropdown menu which displays navigation items",
|
|
234
|
+
"message": "Open menu"
|
|
235
|
+
},
|
|
236
|
+
"kzTitleBlock.overflowMenuAriaLabel": {
|
|
237
|
+
"description": "Aria Label for the dropdown menu which displays additional action items",
|
|
238
|
+
"message": "Opens overflow menu"
|
|
239
|
+
},
|
|
240
|
+
"kzTitleBlock.overflowMenuLabel": {
|
|
241
|
+
"description": "Label for the dropdown menu which displays additional action items",
|
|
242
|
+
"message": "Menu"
|
|
243
|
+
},
|
|
244
|
+
"kzTitleBlock.secondaryAndOverflowMenuLabel": {
|
|
245
|
+
"description": "Label for the dropdown menu which displays additional actions",
|
|
246
|
+
"message": "Open secondary and overflow menu"
|
|
247
|
+
},
|
|
224
248
|
"singleSelect.chevronButton": {
|
|
225
249
|
"description": "Aria label text for the SingleSelect button to open and close suggestions list",
|
|
226
250
|
"message": "Show suggestions for {field}"
|
|
@@ -228,9 +252,5 @@
|
|
|
228
252
|
"singleSelect.clearButtonAlt_v2": {
|
|
229
253
|
"description": "Alt text for the clear selection button. The button clears the selection the user has made via a dropdown. The field placeholder is the label of the dropdown.",
|
|
230
254
|
"message": "Clear selection: {field}"
|
|
231
|
-
},
|
|
232
|
-
"splitButton.dropdownButton.label": {
|
|
233
|
-
"description": "Label for a dropdown menu holding additional actions",
|
|
234
|
-
"message": "Additional actions"
|
|
235
255
|
}
|
|
236
256
|
}
|
package/package.json
CHANGED
|
@@ -61,10 +61,6 @@
|
|
|
61
61
|
display: flex;
|
|
62
62
|
width: 100%;
|
|
63
63
|
justify-content: center;
|
|
64
|
-
|
|
65
|
-
@include title-block-small {
|
|
66
|
-
height: $tab-container-height-small;
|
|
67
|
-
}
|
|
68
64
|
}
|
|
69
65
|
|
|
70
66
|
.lightVariant .titleRow {
|
|
@@ -112,10 +108,6 @@
|
|
|
112
108
|
.rowBelowSeparatorInner {
|
|
113
109
|
@extend %titleBlockInner;
|
|
114
110
|
@extend %rowBelowSeparatorInnerMarginOverride;
|
|
115
|
-
|
|
116
|
-
@include title-block-small {
|
|
117
|
-
height: $tab-container-height-small;
|
|
118
|
-
}
|
|
119
111
|
}
|
|
120
112
|
|
|
121
113
|
.titleRowInnerContent {
|
|
@@ -285,7 +277,6 @@
|
|
|
285
277
|
display: none;
|
|
286
278
|
align-self: self-start;
|
|
287
279
|
box-sizing: border-box;
|
|
288
|
-
overflow: hidden;
|
|
289
280
|
height: $ca-grid * 2;
|
|
290
281
|
width: $ca-grid * 2;
|
|
291
282
|
|
|
@@ -296,6 +287,7 @@
|
|
|
296
287
|
}
|
|
297
288
|
|
|
298
289
|
&.withBorder {
|
|
290
|
+
overflow: hidden;
|
|
299
291
|
border: 3px solid $color-white;
|
|
300
292
|
border-radius: 50%;
|
|
301
293
|
}
|
|
@@ -367,7 +359,12 @@
|
|
|
367
359
|
.sectionTitleContainer {
|
|
368
360
|
display: flex;
|
|
369
361
|
align-items: center;
|
|
362
|
+
padding-block: 9px;
|
|
370
363
|
padding-inline-end: 8px; // 20 take 12 result in 8 extra padding needed in section versus tabs UI
|
|
364
|
+
|
|
365
|
+
@include title-block-min-container-1080 {
|
|
366
|
+
padding-block: 17px;
|
|
367
|
+
}
|
|
371
368
|
}
|
|
372
369
|
|
|
373
370
|
.sectionTitle {
|
|
@@ -377,6 +374,7 @@
|
|
|
377
374
|
.sectionTitleInner {
|
|
378
375
|
display: flex;
|
|
379
376
|
flex-direction: column;
|
|
377
|
+
row-gap: 4px;
|
|
380
378
|
|
|
381
379
|
@include title-block-min-container-1080 {
|
|
382
380
|
flex-direction: row;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React, { type ReactNode } from 'react'
|
|
2
|
+
import { useIntl } from '@cultureamp/i18n-react-intl'
|
|
2
3
|
import classnames from 'classnames'
|
|
3
4
|
import { Avatar } from '~components/Avatar'
|
|
4
5
|
import { IconButton } from '~components/ButtonV1'
|
|
@@ -266,6 +267,7 @@ export const TitleBlock = ({
|
|
|
266
267
|
queries: { isSmall, isMedium },
|
|
267
268
|
} = useMediaQueries()
|
|
268
269
|
const isSmallOrMediumViewport = isMedium || isSmall
|
|
270
|
+
const { formatMessage } = useIntl()
|
|
269
271
|
return (
|
|
270
272
|
<>
|
|
271
273
|
<div
|
|
@@ -305,7 +307,12 @@ export const TitleBlock = ({
|
|
|
305
307
|
<IconButton
|
|
306
308
|
onClick={handleHamburgerClick}
|
|
307
309
|
icon={<Icon name="menu" isPresentational />}
|
|
308
|
-
label=
|
|
310
|
+
label={formatMessage({
|
|
311
|
+
id: 'kzTitleBlock.hamburgerMenuLabel',
|
|
312
|
+
defaultMessage: 'Open menu',
|
|
313
|
+
description:
|
|
314
|
+
'Label for the dropdown menu which displays navigation items',
|
|
315
|
+
})}
|
|
309
316
|
reversed={isReversed(variant)}
|
|
310
317
|
/>
|
|
311
318
|
</div>
|
|
@@ -376,7 +383,10 @@ export const TitleBlock = ({
|
|
|
376
383
|
</div>
|
|
377
384
|
</div>
|
|
378
385
|
)}
|
|
379
|
-
{
|
|
386
|
+
{!sectionTitle &&
|
|
387
|
+
!sectionTitleDescription &&
|
|
388
|
+
!renderSectionTitle &&
|
|
389
|
+
renderNavigationTabs(navigationTabs, collapseNavigationArea, title)}
|
|
380
390
|
{(secondaryActions ?? secondaryOverflowMenuItems) && (
|
|
381
391
|
<SecondaryActions
|
|
382
392
|
secondaryActions={secondaryActions}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
2
|
import { type Meta, type StoryObj } from '@storybook/react'
|
|
3
3
|
import { expect, waitFor, within } from '@storybook/test'
|
|
4
|
+
import { Heading } from 'react-aria-components'
|
|
4
5
|
import { Icon } from '~components/Icon'
|
|
5
6
|
import { assetUrl } from '~components/utils/hostedAssets'
|
|
6
7
|
import { StickerSheet } from '~storybook/components/StickerSheet'
|
|
@@ -253,18 +254,18 @@ export const StickerSheetVariants: Story = {
|
|
|
253
254
|
]}
|
|
254
255
|
/>
|
|
255
256
|
</StickerSheet.Row>
|
|
256
|
-
<StickerSheet.Row header="Education (
|
|
257
|
+
<StickerSheet.Row header="Education (Blue background)">
|
|
257
258
|
<TitleBlock
|
|
258
259
|
variant="education"
|
|
259
260
|
title="Education Variant"
|
|
260
|
-
subtitle="This is the education variant with
|
|
261
|
+
subtitle="This is the education variant with blue background"
|
|
261
262
|
breadcrumb={{
|
|
262
263
|
path: '#',
|
|
263
264
|
text: 'Back to courses',
|
|
264
265
|
}}
|
|
265
266
|
navigationTabs={[
|
|
266
|
-
<NavigationTab key="1" text="Lessons" href="#" active />,
|
|
267
|
-
<NavigationTab key="2" text="Assignments" href="#" />,
|
|
267
|
+
<NavigationTab key="1" variant="education" text="Lessons" href="#" active />,
|
|
268
|
+
<NavigationTab key="2" variant="education" text="Assignments" href="#" />,
|
|
268
269
|
]}
|
|
269
270
|
/>
|
|
270
271
|
</StickerSheet.Row>
|
|
@@ -301,6 +302,192 @@ export const StickerSheetVariants: Story = {
|
|
|
301
302
|
</StickerSheet>
|
|
302
303
|
),
|
|
303
304
|
}
|
|
305
|
+
export const StickerSheetWithDefaultAvatar: Story = {
|
|
306
|
+
name: 'Sticker Sheet (DefaultAvatar)',
|
|
307
|
+
render: () => (
|
|
308
|
+
<StickerSheet title="TitleBlock Variants With Default Avatar">
|
|
309
|
+
<StickerSheet.Row header="Default (Purple background)">
|
|
310
|
+
<TitleBlock title="Default Variant" avatar={{ fullName: 'Blanca Wheeler' }} />
|
|
311
|
+
</StickerSheet.Row>
|
|
312
|
+
<StickerSheet.Row header="Education (Blue background)">
|
|
313
|
+
<TitleBlock
|
|
314
|
+
variant="education"
|
|
315
|
+
title="Education Variant"
|
|
316
|
+
avatar={{ fullName: 'Blanca Wheeler' }}
|
|
317
|
+
/>
|
|
318
|
+
</StickerSheet.Row>
|
|
319
|
+
<StickerSheet.Row header="Admin (White background)">
|
|
320
|
+
<TitleBlock variant="admin" title="Admin Variant" avatar={{ fullName: 'Blanca Wheeler' }} />
|
|
321
|
+
</StickerSheet.Row>
|
|
322
|
+
<StickerSheet.Row header="Light (White background)">
|
|
323
|
+
<TitleBlock variant="light" title="Light Variant" avatar={{ fullName: 'Blanca Wheeler' }} />
|
|
324
|
+
</StickerSheet.Row>
|
|
325
|
+
</StickerSheet>
|
|
326
|
+
),
|
|
327
|
+
}
|
|
328
|
+
export const StickerSheetVariantsWithSection: Story = {
|
|
329
|
+
name: 'Sticker Sheet (Variants With Section)',
|
|
330
|
+
render: () => (
|
|
331
|
+
<StickerSheet title="TitleBlock Variants">
|
|
332
|
+
<StickerSheet.Row header="Default (Purple background)">
|
|
333
|
+
<TitleBlock
|
|
334
|
+
title="Default Variant"
|
|
335
|
+
subtitle="This is the default purple variant with white text"
|
|
336
|
+
sectionTitle="Section title"
|
|
337
|
+
sectionTitleDescription="Description of section can go here"
|
|
338
|
+
navigationTabs={undefined}
|
|
339
|
+
surveyStatus={undefined}
|
|
340
|
+
/>
|
|
341
|
+
</StickerSheet.Row>
|
|
342
|
+
<StickerSheet.Row header="Education (Blue background)">
|
|
343
|
+
<TitleBlock
|
|
344
|
+
variant="education"
|
|
345
|
+
title="Education Variant"
|
|
346
|
+
subtitle="This is the education variant with blue background"
|
|
347
|
+
sectionTitle="Section title"
|
|
348
|
+
sectionTitleDescription="Description of section can go here"
|
|
349
|
+
navigationTabs={undefined}
|
|
350
|
+
surveyStatus={undefined}
|
|
351
|
+
/>
|
|
352
|
+
</StickerSheet.Row>
|
|
353
|
+
<StickerSheet.Row header="Admin (White background)">
|
|
354
|
+
<TitleBlock
|
|
355
|
+
variant="admin"
|
|
356
|
+
title="Admin Variant"
|
|
357
|
+
subtitle="This is the admin variant with white background"
|
|
358
|
+
sectionTitle="Section title"
|
|
359
|
+
sectionTitleDescription="Description of section can go here"
|
|
360
|
+
navigationTabs={undefined}
|
|
361
|
+
surveyStatus={undefined}
|
|
362
|
+
/>
|
|
363
|
+
</StickerSheet.Row>
|
|
364
|
+
<StickerSheet.Row header="Light (White background)">
|
|
365
|
+
<TitleBlock
|
|
366
|
+
variant="light"
|
|
367
|
+
title="Light Variant"
|
|
368
|
+
subtitle="This is the light variant with clean white background"
|
|
369
|
+
sectionTitle="Section title"
|
|
370
|
+
sectionTitleDescription="Description of section can go here"
|
|
371
|
+
navigationTabs={undefined}
|
|
372
|
+
surveyStatus={undefined}
|
|
373
|
+
/>
|
|
374
|
+
</StickerSheet.Row>
|
|
375
|
+
</StickerSheet>
|
|
376
|
+
),
|
|
377
|
+
}
|
|
378
|
+
export const StickerSheetVariantsWithSectionTitleOnly: Story = {
|
|
379
|
+
name: 'Sticker Sheet (Section Title Only)',
|
|
380
|
+
render: () => (
|
|
381
|
+
<StickerSheet title="TitleBlock Variants">
|
|
382
|
+
<StickerSheet.Row header="Default (Purple background)">
|
|
383
|
+
<TitleBlock
|
|
384
|
+
title="Default Variant"
|
|
385
|
+
subtitle="This is the default purple variant with white text"
|
|
386
|
+
sectionTitle="Section title"
|
|
387
|
+
sectionTitleDescription={undefined}
|
|
388
|
+
navigationTabs={undefined}
|
|
389
|
+
surveyStatus={undefined}
|
|
390
|
+
secondaryActions={undefined}
|
|
391
|
+
secondaryOverflowMenuItems={undefined}
|
|
392
|
+
primaryAction={undefined}
|
|
393
|
+
defaultAction={undefined}
|
|
394
|
+
/>
|
|
395
|
+
</StickerSheet.Row>
|
|
396
|
+
<StickerSheet.Row header="Education (Blue background)">
|
|
397
|
+
<TitleBlock
|
|
398
|
+
variant="education"
|
|
399
|
+
title="Education Variant"
|
|
400
|
+
subtitle="This is the education variant with blue background"
|
|
401
|
+
sectionTitle="Section title"
|
|
402
|
+
sectionTitleDescription={undefined}
|
|
403
|
+
navigationTabs={undefined}
|
|
404
|
+
surveyStatus={undefined}
|
|
405
|
+
secondaryActions={undefined}
|
|
406
|
+
secondaryOverflowMenuItems={undefined}
|
|
407
|
+
primaryAction={undefined}
|
|
408
|
+
defaultAction={undefined}
|
|
409
|
+
/>
|
|
410
|
+
</StickerSheet.Row>
|
|
411
|
+
<StickerSheet.Row header="Admin (White background)">
|
|
412
|
+
<TitleBlock
|
|
413
|
+
variant="admin"
|
|
414
|
+
title="Admin Variant"
|
|
415
|
+
subtitle="This is the admin variant with white background"
|
|
416
|
+
sectionTitle="Section title"
|
|
417
|
+
sectionTitleDescription={undefined}
|
|
418
|
+
navigationTabs={undefined}
|
|
419
|
+
surveyStatus={undefined}
|
|
420
|
+
secondaryActions={undefined}
|
|
421
|
+
secondaryOverflowMenuItems={undefined}
|
|
422
|
+
primaryAction={undefined}
|
|
423
|
+
defaultAction={undefined}
|
|
424
|
+
/>
|
|
425
|
+
</StickerSheet.Row>
|
|
426
|
+
<StickerSheet.Row header="Light (White background)">
|
|
427
|
+
<TitleBlock
|
|
428
|
+
variant="light"
|
|
429
|
+
title="Light Variant"
|
|
430
|
+
subtitle="This is the light variant with clean white background"
|
|
431
|
+
sectionTitle="Section title"
|
|
432
|
+
sectionTitleDescription={undefined}
|
|
433
|
+
navigationTabs={undefined}
|
|
434
|
+
surveyStatus={undefined}
|
|
435
|
+
secondaryActions={undefined}
|
|
436
|
+
secondaryOverflowMenuItems={undefined}
|
|
437
|
+
primaryAction={undefined}
|
|
438
|
+
defaultAction={undefined}
|
|
439
|
+
/>
|
|
440
|
+
</StickerSheet.Row>
|
|
441
|
+
</StickerSheet>
|
|
442
|
+
),
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
export const StickerSheetVariantsWithCollapseNavigationAreaWhenPossible: Story = {
|
|
446
|
+
name: 'Sticker Sheet (Variants WithCollapseNavigationAreaWhenPossible)',
|
|
447
|
+
render: () => (
|
|
448
|
+
<StickerSheet title="TitleBlock Variants">
|
|
449
|
+
<StickerSheet.Row header="Default">
|
|
450
|
+
<TitleBlock
|
|
451
|
+
title="Default Variant"
|
|
452
|
+
subtitle={undefined}
|
|
453
|
+
breadcrumb={undefined}
|
|
454
|
+
navigationTabs={undefined}
|
|
455
|
+
collapseNavigationAreaWhenPossible={true}
|
|
456
|
+
/>
|
|
457
|
+
</StickerSheet.Row>
|
|
458
|
+
<StickerSheet.Row header="Education">
|
|
459
|
+
<TitleBlock
|
|
460
|
+
variant="education"
|
|
461
|
+
title="Education Variant"
|
|
462
|
+
subtitle={undefined}
|
|
463
|
+
breadcrumb={undefined}
|
|
464
|
+
navigationTabs={undefined}
|
|
465
|
+
collapseNavigationAreaWhenPossible={true}
|
|
466
|
+
/>
|
|
467
|
+
</StickerSheet.Row>
|
|
468
|
+
<StickerSheet.Row header="Admin">
|
|
469
|
+
<TitleBlock
|
|
470
|
+
variant="admin"
|
|
471
|
+
title="Admin Variant"
|
|
472
|
+
subtitle={undefined}
|
|
473
|
+
breadcrumb={undefined}
|
|
474
|
+
navigationTabs={undefined}
|
|
475
|
+
collapseNavigationAreaWhenPossible={true}
|
|
476
|
+
/>
|
|
477
|
+
</StickerSheet.Row>
|
|
478
|
+
<StickerSheet.Row header="Light">
|
|
479
|
+
<TitleBlock
|
|
480
|
+
variant="light"
|
|
481
|
+
title="Light Variant"
|
|
482
|
+
subtitle={undefined}
|
|
483
|
+
breadcrumb={undefined}
|
|
484
|
+
navigationTabs={undefined}
|
|
485
|
+
collapseNavigationAreaWhenPossible={true}
|
|
486
|
+
/>
|
|
487
|
+
</StickerSheet.Row>
|
|
488
|
+
</StickerSheet>
|
|
489
|
+
),
|
|
490
|
+
}
|
|
304
491
|
|
|
305
492
|
export const StickerSheetBreadcrumbs: Story = {
|
|
306
493
|
name: 'Sticker Sheet (Breadcrumb)',
|
|
@@ -442,10 +629,66 @@ export const WithSection: Story = {
|
|
|
442
629
|
},
|
|
443
630
|
args: {
|
|
444
631
|
title: 'A extra long title with over thirty characters so it truncates in a mobile viewport',
|
|
445
|
-
variant: 'light',
|
|
446
632
|
sectionTitle: 'Section title',
|
|
447
633
|
sectionTitleDescription: 'Description of section can go here',
|
|
448
634
|
navigationTabs: undefined,
|
|
449
635
|
surveyStatus: undefined,
|
|
450
636
|
},
|
|
451
637
|
}
|
|
638
|
+
export const WithCustomSectionTitleOnly: Story = {
|
|
639
|
+
parameters: {
|
|
640
|
+
viewport: viewports,
|
|
641
|
+
chromatic: chromaticViewports,
|
|
642
|
+
},
|
|
643
|
+
args: {
|
|
644
|
+
title: 'Page title',
|
|
645
|
+
renderSectionTitle: () => (
|
|
646
|
+
<div>
|
|
647
|
+
<Heading className="m-0">Custom Section Title</Heading>
|
|
648
|
+
</div>
|
|
649
|
+
),
|
|
650
|
+
navigationTabs: undefined,
|
|
651
|
+
surveyStatus: undefined,
|
|
652
|
+
secondaryActions: undefined,
|
|
653
|
+
secondaryOverflowMenuItems: undefined,
|
|
654
|
+
primaryAction: undefined,
|
|
655
|
+
defaultAction: undefined,
|
|
656
|
+
},
|
|
657
|
+
}
|
|
658
|
+
|
|
659
|
+
export const WithTitleCollapseNavigationAreaWhenPossible: Story = {
|
|
660
|
+
parameters: {
|
|
661
|
+
viewport: viewports,
|
|
662
|
+
chromatic: chromaticViewports,
|
|
663
|
+
},
|
|
664
|
+
args: {
|
|
665
|
+
title: 'Page title',
|
|
666
|
+
navigationTabs: undefined,
|
|
667
|
+
surveyStatus: undefined,
|
|
668
|
+
primaryAction: undefined,
|
|
669
|
+
defaultAction: undefined,
|
|
670
|
+
secondaryActions: undefined,
|
|
671
|
+
secondaryOverflowMenuItems: undefined,
|
|
672
|
+
breadcrumb: undefined,
|
|
673
|
+
avatar: undefined,
|
|
674
|
+
collapseNavigationAreaWhenPossible: true,
|
|
675
|
+
},
|
|
676
|
+
}
|
|
677
|
+
|
|
678
|
+
export const WithOnlySecondaryActions: Story = {
|
|
679
|
+
parameters: {
|
|
680
|
+
viewport: viewports,
|
|
681
|
+
chromatic: chromaticViewports,
|
|
682
|
+
},
|
|
683
|
+
args: {
|
|
684
|
+
title: 'Page title',
|
|
685
|
+
navigationTabs: undefined,
|
|
686
|
+
surveyStatus: undefined,
|
|
687
|
+
primaryAction: undefined,
|
|
688
|
+
defaultAction: undefined,
|
|
689
|
+
sectionTitle: undefined,
|
|
690
|
+
sectionTitleDescription: undefined,
|
|
691
|
+
breadcrumb: undefined,
|
|
692
|
+
avatar: undefined,
|
|
693
|
+
},
|
|
694
|
+
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { useIntl } from '@cultureamp/i18n-react-intl'
|
|
2
3
|
import { Button, IconButton } from '~components/ButtonV1'
|
|
3
4
|
import { Icon } from '~components/Icon'
|
|
4
5
|
import { Menu, MenuList } from '~components/MenuV1'
|
|
@@ -24,6 +25,7 @@ type MainActionsProps = {
|
|
|
24
25
|
}
|
|
25
26
|
|
|
26
27
|
const renderSecondaryAndOverflowMenu = (
|
|
28
|
+
secondaryAndOverflowMenuLabel: string,
|
|
27
29
|
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[],
|
|
28
30
|
reversed?: boolean,
|
|
29
31
|
): JSX.Element | undefined => {
|
|
@@ -33,7 +35,7 @@ const renderSecondaryAndOverflowMenu = (
|
|
|
33
35
|
align="right"
|
|
34
36
|
button={
|
|
35
37
|
<IconButton
|
|
36
|
-
label={
|
|
38
|
+
label={secondaryAndOverflowMenuLabel}
|
|
37
39
|
reversed={reversed}
|
|
38
40
|
icon={<Icon name="more_horiz" isPresentational />}
|
|
39
41
|
id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
@@ -57,6 +59,13 @@ export const MainActions = ({
|
|
|
57
59
|
secondaryOverflowMenuItems,
|
|
58
60
|
reversed = false,
|
|
59
61
|
}: MainActionsProps): JSX.Element => {
|
|
62
|
+
const { formatMessage } = useIntl()
|
|
63
|
+
|
|
64
|
+
const secondaryAndOverflowMenuLabel = formatMessage({
|
|
65
|
+
id: 'kzTitleBlock.secondaryAndOverflowMenuLabel',
|
|
66
|
+
defaultMessage: 'Open secondary and overflow menu',
|
|
67
|
+
description: 'Label for the dropdown menu which displays additional actions',
|
|
68
|
+
})
|
|
60
69
|
let items
|
|
61
70
|
|
|
62
71
|
// Build combined secondary + overflow menu items once, to be spread into the toolbar items
|
|
@@ -97,7 +106,7 @@ export const MainActions = ({
|
|
|
97
106
|
if (allMenuItems.length > 0) {
|
|
98
107
|
secondaryAndOverflowMenu.push({
|
|
99
108
|
key: 'overflowMenu',
|
|
100
|
-
node: renderSecondaryAndOverflowMenu(allMenuItems, reversed)!,
|
|
109
|
+
node: renderSecondaryAndOverflowMenu(secondaryAndOverflowMenuLabel, allMenuItems, reversed)!,
|
|
101
110
|
})
|
|
102
111
|
}
|
|
103
112
|
|
|
@@ -130,7 +139,12 @@ export const MainActions = ({
|
|
|
130
139
|
align="right"
|
|
131
140
|
button={
|
|
132
141
|
<IconButton
|
|
133
|
-
label={
|
|
142
|
+
label={formatMessage({
|
|
143
|
+
id: 'kzTitleBlock.defaultActionMinimizedOverflowMenuLabel',
|
|
144
|
+
defaultMessage: 'Open default action overflow menu',
|
|
145
|
+
description:
|
|
146
|
+
'Label for the dropdown menu which displays the default action item',
|
|
147
|
+
})}
|
|
134
148
|
reversed={reversed}
|
|
135
149
|
icon={<Icon name="more_horiz" isPresentational />}
|
|
136
150
|
id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import React from 'react'
|
|
2
|
+
import { useIntl } from '@cultureamp/i18n-react-intl'
|
|
2
3
|
import { Button, IconButton } from '~components/ButtonV1'
|
|
3
4
|
import { Icon } from '~components/Icon'
|
|
4
5
|
import { Menu, MenuList } from '~components/MenuV1'
|
|
@@ -16,6 +17,8 @@ type Props = {
|
|
|
16
17
|
}
|
|
17
18
|
|
|
18
19
|
const renderSecondaryOverflowMenu = (
|
|
20
|
+
menuAriaLabel: string,
|
|
21
|
+
menuLabel: string,
|
|
19
22
|
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[],
|
|
20
23
|
reversed?: boolean,
|
|
21
24
|
): JSX.Element | undefined => {
|
|
@@ -28,7 +31,8 @@ const renderSecondaryOverflowMenu = (
|
|
|
28
31
|
<Button
|
|
29
32
|
secondary
|
|
30
33
|
reversed={reversed}
|
|
31
|
-
label=
|
|
34
|
+
label={menuLabel}
|
|
35
|
+
aria-label={menuAriaLabel}
|
|
32
36
|
data-automation-id={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
33
37
|
data-testid={TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}
|
|
34
38
|
icon={<Icon name="keyboard_arrow_down" isPresentational />}
|
|
@@ -48,6 +52,7 @@ const renderSecondaryOverflowMenu = (
|
|
|
48
52
|
|
|
49
53
|
// New: combined overflow menu (secondary actions converted + overflow menu items)
|
|
50
54
|
const renderCombinedSecondaryOverflowMenu = (
|
|
55
|
+
combinedMenuLabel: string,
|
|
51
56
|
secondaryActions?: SecondaryActionsProps,
|
|
52
57
|
secondaryOverflowMenuItems?: TitleBlockMenuItemProps[],
|
|
53
58
|
reversed?: boolean,
|
|
@@ -66,7 +71,7 @@ const renderCombinedSecondaryOverflowMenu = (
|
|
|
66
71
|
align="right"
|
|
67
72
|
button={
|
|
68
73
|
<IconButton
|
|
69
|
-
label=
|
|
74
|
+
label={combinedMenuLabel}
|
|
70
75
|
reversed={reversed}
|
|
71
76
|
icon={<Icon name="more_horiz" isPresentational />}
|
|
72
77
|
id={`${TITLE_BLOCK_ZEN_SECONDARY_MENU_HTML_ID}__combined`}
|
|
@@ -92,8 +97,29 @@ export const SecondaryActions = ({
|
|
|
92
97
|
secondaryOverflowMenuItems,
|
|
93
98
|
reversed = false,
|
|
94
99
|
}: Props): JSX.Element | null => {
|
|
100
|
+
const { formatMessage } = useIntl()
|
|
101
|
+
|
|
95
102
|
if (!secondaryActions && !secondaryOverflowMenuItems) return null
|
|
96
103
|
|
|
104
|
+
const menuLabel = formatMessage({
|
|
105
|
+
id: 'kzTitleBlock.overflowMenuLabel',
|
|
106
|
+
defaultMessage: 'Menu',
|
|
107
|
+
description: 'Label for the dropdown menu which displays additional action items',
|
|
108
|
+
})
|
|
109
|
+
|
|
110
|
+
const menuAriaLabel = formatMessage({
|
|
111
|
+
id: 'kzTitleBlock.overflowMenuAriaLabel',
|
|
112
|
+
defaultMessage: 'Opens overflow menu',
|
|
113
|
+
description: 'Aria Label for the dropdown menu which displays additional action items',
|
|
114
|
+
})
|
|
115
|
+
|
|
116
|
+
const combinedMenuLabel = formatMessage({
|
|
117
|
+
id: 'kzTitleBlock.combinedOverflowMenuLabel',
|
|
118
|
+
defaultMessage: 'Open combined secondary and overflow menu',
|
|
119
|
+
description:
|
|
120
|
+
'Label for the dropdown menu which displays additional action items and secondary actions',
|
|
121
|
+
})
|
|
122
|
+
|
|
97
123
|
const secondaryActionsAsToolbarItems = secondaryActions
|
|
98
124
|
? secondaryActions.map((action, i) => {
|
|
99
125
|
if ('menuItems' in action) {
|
|
@@ -148,8 +174,14 @@ export const SecondaryActions = ({
|
|
|
148
174
|
})
|
|
149
175
|
: []
|
|
150
176
|
|
|
151
|
-
const overflowMenu = renderSecondaryOverflowMenu(
|
|
177
|
+
const overflowMenu = renderSecondaryOverflowMenu(
|
|
178
|
+
menuAriaLabel,
|
|
179
|
+
menuLabel,
|
|
180
|
+
secondaryOverflowMenuItems,
|
|
181
|
+
reversed,
|
|
182
|
+
)
|
|
152
183
|
const combinedOverflowMenu = renderCombinedSecondaryOverflowMenu(
|
|
184
|
+
combinedMenuLabel,
|
|
153
185
|
secondaryActions,
|
|
154
186
|
secondaryOverflowMenuItems,
|
|
155
187
|
reversed,
|