@carbon-labs/react-animated-header 0.22.0 → 0.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/es/__stories__/AnimatedHeader.stories.d.ts +198 -332
- package/es/__stories__/data/index.d.ts +21 -0
- package/es/components/AnimatedHeader/AnimatedHeader.d.ts +9 -0
- package/es/components/AnimatedHeader/AnimatedHeader.js +30 -22
- package/es/components/HeaderTitle/HeaderTitle.d.ts +18 -0
- package/es/components/HeaderTitle/HeaderTitle.js +53 -0
- package/es/components/TasksController/TasksController.d.ts +1 -0
- package/es/components/TasksController/TasksController.js +2 -1
- package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +1 -0
- package/es/components/Tiles/AIPromptTile/AIPromptTile.js +4 -1
- package/es/components/Tiles/BaseTile/BaseTile.d.ts +1 -0
- package/es/components/Tiles/GlassTile/GlassTile.d.ts +1 -0
- package/es/components/Tiles/GlassTile/GlassTile.js +9 -2
- package/es/components/WorkspaceSelector/WorkspaceSelector.d.ts +1 -0
- package/es/components/WorkspaceSelector/WorkspaceSelector.js +1 -0
- package/es/index.d.ts +3 -2
- package/es/index.js +1 -0
- package/lib/__stories__/AnimatedHeader.stories.d.ts +198 -332
- package/lib/__stories__/data/index.d.ts +21 -0
- package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +9 -0
- package/lib/components/AnimatedHeader/AnimatedHeader.js +29 -21
- package/lib/components/HeaderTitle/HeaderTitle.d.ts +18 -0
- package/lib/components/HeaderTitle/HeaderTitle.js +57 -0
- package/lib/components/TasksController/TasksController.d.ts +1 -0
- package/lib/components/TasksController/TasksController.js +2 -1
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +1 -0
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +4 -1
- package/lib/components/Tiles/BaseTile/BaseTile.d.ts +1 -0
- package/lib/components/Tiles/GlassTile/GlassTile.d.ts +1 -0
- package/lib/components/Tiles/GlassTile/GlassTile.js +9 -2
- package/lib/components/WorkspaceSelector/WorkspaceSelector.d.ts +1 -0
- package/lib/components/WorkspaceSelector/WorkspaceSelector.js +1 -0
- package/lib/index.d.ts +3 -2
- package/lib/index.js +2 -0
- package/package.json +2 -2
- package/scss/AnimatedHeader/animated-header.scss +20 -113
- package/scss/HeaderTitle/header-title.scss +60 -0
- package/scss/animated-header.scss +1 -0
|
@@ -10,6 +10,7 @@ export const headerTiles: ({
|
|
|
10
10
|
href: string;
|
|
11
11
|
title: string;
|
|
12
12
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
13
|
+
ariaLabel: string;
|
|
13
14
|
subtitle?: undefined;
|
|
14
15
|
} | {
|
|
15
16
|
id: string;
|
|
@@ -17,6 +18,7 @@ export const headerTiles: ({
|
|
|
17
18
|
title: string;
|
|
18
19
|
subtitle: string;
|
|
19
20
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
21
|
+
ariaLabel: string;
|
|
20
22
|
})[];
|
|
21
23
|
} | {
|
|
22
24
|
id: number;
|
|
@@ -27,6 +29,7 @@ export const headerTiles: ({
|
|
|
27
29
|
title: string;
|
|
28
30
|
subtitle: string;
|
|
29
31
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
32
|
+
ariaLabel: string;
|
|
30
33
|
secondaryIcon?: undefined;
|
|
31
34
|
} | {
|
|
32
35
|
id: string;
|
|
@@ -34,6 +37,7 @@ export const headerTiles: ({
|
|
|
34
37
|
title: string;
|
|
35
38
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
36
39
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
40
|
+
ariaLabel: string;
|
|
37
41
|
subtitle?: undefined;
|
|
38
42
|
})[];
|
|
39
43
|
} | {
|
|
@@ -46,6 +50,7 @@ export const headerTiles: ({
|
|
|
46
50
|
subtitle: string;
|
|
47
51
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
48
52
|
isLoading: boolean;
|
|
53
|
+
ariaLabel: string;
|
|
49
54
|
isDisabled?: undefined;
|
|
50
55
|
secondaryIcon?: undefined;
|
|
51
56
|
} | {
|
|
@@ -53,6 +58,7 @@ export const headerTiles: ({
|
|
|
53
58
|
title: string;
|
|
54
59
|
subtitle: string;
|
|
55
60
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
61
|
+
ariaLabel: string;
|
|
56
62
|
href?: undefined;
|
|
57
63
|
isLoading?: undefined;
|
|
58
64
|
isDisabled?: undefined;
|
|
@@ -64,6 +70,7 @@ export const headerTiles: ({
|
|
|
64
70
|
subtitle: string;
|
|
65
71
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
66
72
|
isDisabled: boolean;
|
|
73
|
+
ariaLabel: string;
|
|
67
74
|
isLoading?: undefined;
|
|
68
75
|
secondaryIcon?: undefined;
|
|
69
76
|
} | {
|
|
@@ -72,6 +79,7 @@ export const headerTiles: ({
|
|
|
72
79
|
title: string;
|
|
73
80
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
74
81
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
82
|
+
ariaLabel: string;
|
|
75
83
|
subtitle?: undefined;
|
|
76
84
|
isLoading?: undefined;
|
|
77
85
|
isDisabled?: undefined;
|
|
@@ -82,6 +90,7 @@ export const headerTiles: ({
|
|
|
82
90
|
tiles: {
|
|
83
91
|
id: string;
|
|
84
92
|
customContent: import("react/jsx-runtime").JSX.Element;
|
|
93
|
+
ariaLabel: string;
|
|
85
94
|
}[];
|
|
86
95
|
})[];
|
|
87
96
|
export namespace tasksControllerConfigButton {
|
|
@@ -108,6 +117,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
108
117
|
href: string;
|
|
109
118
|
title: string;
|
|
110
119
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
120
|
+
ariaLabel: string;
|
|
111
121
|
subtitle?: undefined;
|
|
112
122
|
} | {
|
|
113
123
|
id: string;
|
|
@@ -115,6 +125,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
115
125
|
title: string;
|
|
116
126
|
subtitle: string;
|
|
117
127
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
128
|
+
ariaLabel: string;
|
|
118
129
|
})[];
|
|
119
130
|
} | {
|
|
120
131
|
id: number;
|
|
@@ -125,6 +136,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
125
136
|
title: string;
|
|
126
137
|
subtitle: string;
|
|
127
138
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
139
|
+
ariaLabel: string;
|
|
128
140
|
secondaryIcon?: undefined;
|
|
129
141
|
} | {
|
|
130
142
|
id: string;
|
|
@@ -132,6 +144,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
132
144
|
title: string;
|
|
133
145
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
134
146
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
147
|
+
ariaLabel: string;
|
|
135
148
|
subtitle?: undefined;
|
|
136
149
|
})[];
|
|
137
150
|
} | {
|
|
@@ -144,6 +157,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
144
157
|
subtitle: string;
|
|
145
158
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
146
159
|
isLoading: boolean;
|
|
160
|
+
ariaLabel: string;
|
|
147
161
|
isDisabled?: undefined;
|
|
148
162
|
secondaryIcon?: undefined;
|
|
149
163
|
} | {
|
|
@@ -151,6 +165,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
151
165
|
title: string;
|
|
152
166
|
subtitle: string;
|
|
153
167
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
168
|
+
ariaLabel: string;
|
|
154
169
|
href?: undefined;
|
|
155
170
|
isLoading?: undefined;
|
|
156
171
|
isDisabled?: undefined;
|
|
@@ -162,6 +177,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
162
177
|
subtitle: string;
|
|
163
178
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
164
179
|
isDisabled: boolean;
|
|
180
|
+
ariaLabel: string;
|
|
165
181
|
isLoading?: undefined;
|
|
166
182
|
secondaryIcon?: undefined;
|
|
167
183
|
} | {
|
|
@@ -170,6 +186,7 @@ export namespace tasksControllerConfigDropdown {
|
|
|
170
186
|
title: string;
|
|
171
187
|
mainIcon: import("@carbon/react/icons").CarbonIconType;
|
|
172
188
|
secondaryIcon: import("@carbon/react/icons").CarbonIconType;
|
|
189
|
+
ariaLabel: string;
|
|
173
190
|
subtitle?: undefined;
|
|
174
191
|
isLoading?: undefined;
|
|
175
192
|
isDisabled?: undefined;
|
|
@@ -180,9 +197,11 @@ export namespace tasksControllerConfigDropdown {
|
|
|
180
197
|
tiles: {
|
|
181
198
|
id: string;
|
|
182
199
|
customContent: import("react/jsx-runtime").JSX.Element;
|
|
200
|
+
ariaLabel: string;
|
|
183
201
|
}[];
|
|
184
202
|
};
|
|
185
203
|
export function setSelectedTileGroup(): void;
|
|
204
|
+
export let ariaLabel: string;
|
|
186
205
|
}
|
|
187
206
|
}
|
|
188
207
|
export namespace tasksControllerConfigLoading {
|
|
@@ -198,6 +217,8 @@ export namespace workspaceSelectorConfig {
|
|
|
198
217
|
export { label_1 as label };
|
|
199
218
|
export function renderSelectedItem(item: any): string;
|
|
200
219
|
}
|
|
220
|
+
let ariaLabel_1: string;
|
|
221
|
+
export { ariaLabel_1 as ariaLabel };
|
|
201
222
|
}
|
|
202
223
|
export namespace workspaceSelectorConfigLoading {
|
|
203
224
|
export { workspaceData as allWorkspaces };
|
|
@@ -2,6 +2,13 @@ import React, { ElementType, ReactNode } from 'react';
|
|
|
2
2
|
import { TasksControllerProps } from '../TasksController/TasksController';
|
|
3
3
|
import { WorkspaceSelectorProps } from '../WorkspaceSelector/WorkspaceSelector';
|
|
4
4
|
/** Animated Header */
|
|
5
|
+
export interface AriaLabels {
|
|
6
|
+
welcome?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
collapseButton?: string;
|
|
9
|
+
expandButton?: string;
|
|
10
|
+
tilesContainer?: string;
|
|
11
|
+
}
|
|
5
12
|
export interface Tile {
|
|
6
13
|
href?: string | null;
|
|
7
14
|
id: string;
|
|
@@ -13,6 +20,7 @@ export interface Tile {
|
|
|
13
20
|
isLoading?: boolean;
|
|
14
21
|
isDisabled?: boolean;
|
|
15
22
|
onClick?: () => void;
|
|
23
|
+
ariaLabel?: string;
|
|
16
24
|
}
|
|
17
25
|
export interface TileGroup {
|
|
18
26
|
id: number;
|
|
@@ -21,6 +29,7 @@ export interface TileGroup {
|
|
|
21
29
|
}
|
|
22
30
|
export type AnimatedHeaderProps = {
|
|
23
31
|
allTileGroups?: TileGroup[];
|
|
32
|
+
ariaLabels?: AriaLabels;
|
|
24
33
|
selectedTileGroup?: TileGroup;
|
|
25
34
|
setSelectedTileGroup: (e: any) => void;
|
|
26
35
|
description?: string;
|
|
@@ -19,11 +19,13 @@ require('@carbon/react/icons');
|
|
|
19
19
|
var BaseTile = require('../Tiles/BaseTile/BaseTile.js');
|
|
20
20
|
var TasksController = require('../TasksController/TasksController.js');
|
|
21
21
|
var WorkspaceSelector = require('../WorkspaceSelector/WorkspaceSelector.js');
|
|
22
|
+
var HeaderTitle = require('../HeaderTitle/HeaderTitle.js');
|
|
22
23
|
|
|
23
24
|
/** Animated Header */
|
|
24
25
|
|
|
25
26
|
const AnimatedHeader = ({
|
|
26
27
|
allTileGroups,
|
|
28
|
+
ariaLabels = {},
|
|
27
29
|
selectedTileGroup,
|
|
28
30
|
setSelectedTileGroup,
|
|
29
31
|
description,
|
|
@@ -44,17 +46,13 @@ const AnimatedHeader = ({
|
|
|
44
46
|
const blockClass = `${prefix}--animated-header`;
|
|
45
47
|
const animationContainer = React.useRef(null);
|
|
46
48
|
const [open, setOpen] = React.useState(true);
|
|
47
|
-
const [headingTextAnimation, setHeadingTextAnimation] = React.useState('');
|
|
48
49
|
const isReduced = window.matchMedia('(prefers-reduced-motion)').matches;
|
|
49
50
|
const collapsed = `${blockClass}--collapsed`;
|
|
50
51
|
const contentCollapsed = `${blockClass}__content--collapsed`;
|
|
51
52
|
const descriptionCollapsed = `${blockClass}__left-area-container--collapsed`;
|
|
52
|
-
const headingCollapsed = `${blockClass}__heading--collapsed`;
|
|
53
|
-
const headingExpanded = `${blockClass}__heading--expanded`;
|
|
54
53
|
const lottieCollapsed = `${blockClass}__lottie-animation--collapsed`;
|
|
55
54
|
const handleButtonCollapseClick = () => {
|
|
56
55
|
setOpen(!open);
|
|
57
|
-
open ? setHeadingTextAnimation(headingCollapsed) : setHeadingTextAnimation(headingExpanded);
|
|
58
56
|
};
|
|
59
57
|
React.useEffect(() => {
|
|
60
58
|
if (!animationContainer.current) {
|
|
@@ -91,7 +89,7 @@ const AnimatedHeader = ({
|
|
|
91
89
|
};
|
|
92
90
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
93
91
|
}, [isReduced]);
|
|
94
|
-
return /*#__PURE__*/React.createElement("
|
|
92
|
+
return /*#__PURE__*/React.createElement("header", {
|
|
95
93
|
className: `${blockClass}${!open ? ` ${collapsed}` : ''}`
|
|
96
94
|
}, /*#__PURE__*/React.createElement(react.Grid, null, /*#__PURE__*/React.createElement("div", {
|
|
97
95
|
className: `${blockClass}__gradient--overlay`
|
|
@@ -105,32 +103,32 @@ const AnimatedHeader = ({
|
|
|
105
103
|
,
|
|
106
104
|
style: {
|
|
107
105
|
backgroundImage: `url(${headerStatic})`
|
|
108
|
-
}
|
|
106
|
+
},
|
|
107
|
+
"aria-hidden": "true"
|
|
109
108
|
})), /*#__PURE__*/React.createElement("div", {
|
|
110
109
|
className: `${blockClass}__lottie-animation--container`
|
|
111
110
|
}, /*#__PURE__*/React.createElement("div", {
|
|
112
111
|
ref: animationContainer,
|
|
113
|
-
className: `${blockClass}__lottie-animation${!open ? ` ${lottieCollapsed}` : ''}
|
|
112
|
+
className: `${blockClass}__lottie-animation${!open ? ` ${lottieCollapsed}` : ''}`,
|
|
113
|
+
"aria-hidden": "true"
|
|
114
114
|
})), /*#__PURE__*/React.createElement(react.Column, {
|
|
115
115
|
sm: 4,
|
|
116
116
|
md: 8,
|
|
117
117
|
lg: 16
|
|
118
|
-
}, /*#__PURE__*/React.createElement(
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
}, /*#__PURE__*/React.createElement(
|
|
124
|
-
className: `${blockClass}__heading-welcome`
|
|
125
|
-
}, welcomeText, ",", ' '), /*#__PURE__*/React.createElement("span", {
|
|
126
|
-
className: `${blockClass}__heading-name`
|
|
127
|
-
}, userName)))), (description || tasksControllerConfig) && /*#__PURE__*/React.createElement(react.Column, {
|
|
118
|
+
}, /*#__PURE__*/React.createElement(HeaderTitle.default, {
|
|
119
|
+
userName: userName,
|
|
120
|
+
welcomeText: welcomeText,
|
|
121
|
+
headerExpanded: open,
|
|
122
|
+
ariaLabels: ariaLabels
|
|
123
|
+
})), (description || tasksControllerConfig) && /*#__PURE__*/React.createElement(react.Column, {
|
|
128
124
|
sm: 4,
|
|
129
125
|
md: 8,
|
|
130
126
|
lg: 4,
|
|
127
|
+
id: `${blockClass}-content`,
|
|
131
128
|
className: `${blockClass}__left-area-container${!open ? ` ${descriptionCollapsed}` : ''}`
|
|
132
129
|
}, description && /*#__PURE__*/React.createElement("h2", {
|
|
133
|
-
className: `${blockClass}__description
|
|
130
|
+
className: `${blockClass}__description`,
|
|
131
|
+
"aria-label": ariaLabels?.description ?? `Header description`
|
|
134
132
|
}, description), /*#__PURE__*/React.createElement(TasksController.default, {
|
|
135
133
|
tasksControllerConfig: tasksControllerConfig,
|
|
136
134
|
isLoading: isLoading,
|
|
@@ -149,7 +147,9 @@ const AnimatedHeader = ({
|
|
|
149
147
|
userName: userName,
|
|
150
148
|
isLoading: isLoading
|
|
151
149
|
})), /*#__PURE__*/React.createElement("div", {
|
|
152
|
-
className: `${blockClass}__tiles-container
|
|
150
|
+
className: `${blockClass}__tiles-container`,
|
|
151
|
+
"aria-label": ariaLabels?.tilesContainer ?? `Feature tiles`,
|
|
152
|
+
role: "list"
|
|
153
153
|
}, selectedTileGroup.tiles.map(tile => {
|
|
154
154
|
return /*#__PURE__*/React.createElement(BaseTile.BaseTile, {
|
|
155
155
|
onClick: tile.href || tile.onClick ? () => {
|
|
@@ -168,7 +168,8 @@ const AnimatedHeader = ({
|
|
|
168
168
|
customContent: tile.customContent,
|
|
169
169
|
isLoading: isLoading || tile.isLoading,
|
|
170
170
|
isDisabled: tile.isDisabled,
|
|
171
|
-
disabledTaskLabel: disabledTaskLabel
|
|
171
|
+
disabledTaskLabel: disabledTaskLabel,
|
|
172
|
+
ariaLabel: tile.ariaLabel
|
|
172
173
|
});
|
|
173
174
|
}))), /*#__PURE__*/React.createElement("div", {
|
|
174
175
|
className: `${blockClass}__button-collapse--gradient`
|
|
@@ -178,7 +179,10 @@ const AnimatedHeader = ({
|
|
|
178
179
|
id: `${blockClass}__button-collapse`,
|
|
179
180
|
kind: "ghost",
|
|
180
181
|
renderIcon: open ? iconsReact.ChevronUp : iconsReact.ChevronDown,
|
|
181
|
-
onClick: handleButtonCollapseClick
|
|
182
|
+
onClick: handleButtonCollapseClick,
|
|
183
|
+
"aria-expanded": open,
|
|
184
|
+
"aria-controls": `${blockClass}-content`,
|
|
185
|
+
"aria-label": open ? ariaLabels?.collapseButton ?? 'Collapse header details' : ariaLabels?.expandButton ?? 'Expand header details'
|
|
182
186
|
}, open ? collapseButtonLabel : expandButtonLabel))));
|
|
183
187
|
};
|
|
184
188
|
AnimatedHeader.displayName = 'Animated Header';
|
|
@@ -187,6 +191,10 @@ AnimatedHeader.propTypes = {
|
|
|
187
191
|
* Array of each tile group setup
|
|
188
192
|
*/
|
|
189
193
|
allTileGroups: PropTypes.arrayOf(PropTypes.object),
|
|
194
|
+
/**
|
|
195
|
+
* Provide custom aria labels for each part of the header.
|
|
196
|
+
*/
|
|
197
|
+
ariaLabels: PropTypes.object,
|
|
190
198
|
/**
|
|
191
199
|
* Specify an optional className to be added to your Animated Header
|
|
192
200
|
*/
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @license
|
|
3
|
+
*
|
|
4
|
+
* Copyright IBM Corp. 2025
|
|
5
|
+
*
|
|
6
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
|
+
* LICENSE file in the root directory of this source tree.
|
|
8
|
+
*/
|
|
9
|
+
import React from 'react';
|
|
10
|
+
import { AriaLabels } from '../AnimatedHeader/AnimatedHeader';
|
|
11
|
+
export type HeaderTitleProps = {
|
|
12
|
+
userName?: string;
|
|
13
|
+
welcomeText?: string;
|
|
14
|
+
headerExpanded?: boolean;
|
|
15
|
+
ariaLabels?: AriaLabels;
|
|
16
|
+
};
|
|
17
|
+
declare const HeaderTitle: React.FC<HeaderTitleProps>;
|
|
18
|
+
export default HeaderTitle;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright IBM Corp. 2024
|
|
3
|
+
*
|
|
4
|
+
* This source code is licensed under the Apache-2.0 license found in the
|
|
5
|
+
* LICENSE file in the root directory of this source tree.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
'use strict';
|
|
9
|
+
|
|
10
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
11
|
+
|
|
12
|
+
var React = require('react');
|
|
13
|
+
var react = require('@carbon/react');
|
|
14
|
+
var usePrefix = require('../../node_modules/@carbon-labs/utilities/es/usePrefix.js');
|
|
15
|
+
|
|
16
|
+
const NAME_FIRST_LANGS = ['ar',
|
|
17
|
+
// Arabic
|
|
18
|
+
'he',
|
|
19
|
+
// Hebrew
|
|
20
|
+
'fa',
|
|
21
|
+
// Farsi/Persian
|
|
22
|
+
'ur',
|
|
23
|
+
// Urdu
|
|
24
|
+
'ja',
|
|
25
|
+
// Japanese
|
|
26
|
+
'zh' // Chinese
|
|
27
|
+
];
|
|
28
|
+
const HeaderTitle = ({
|
|
29
|
+
userName,
|
|
30
|
+
welcomeText,
|
|
31
|
+
headerExpanded,
|
|
32
|
+
ariaLabels
|
|
33
|
+
}) => {
|
|
34
|
+
const prefix = usePrefix.usePrefix();
|
|
35
|
+
const blockClass = `${prefix}--animated-header__title`;
|
|
36
|
+
const currentLang = typeof window !== 'undefined' ? document.documentElement.lang || 'en' : 'en';
|
|
37
|
+
const isNameFirst = NAME_FIRST_LANGS.includes(currentLang.slice(0, 2));
|
|
38
|
+
const headingCollapsed = `${blockClass}-collapsed`;
|
|
39
|
+
const headingExpanded = `${blockClass}-expanded`;
|
|
40
|
+
return /*#__PURE__*/React.createElement(react.Tooltip, {
|
|
41
|
+
align: "bottom",
|
|
42
|
+
label: `${welcomeText}, ${userName}`
|
|
43
|
+
}, /*#__PURE__*/React.createElement("h1", {
|
|
44
|
+
className: `${blockClass} ${headerExpanded ? headingExpanded : headingCollapsed}`,
|
|
45
|
+
"aria-label": ariaLabels?.welcome ?? `${welcomeText}, ${userName}`
|
|
46
|
+
}, isNameFirst ? /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
47
|
+
className: `${blockClass}-first`
|
|
48
|
+
}, userName, ", "), /*#__PURE__*/React.createElement("span", {
|
|
49
|
+
className: `${blockClass}-second`
|
|
50
|
+
}, welcomeText)) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
|
|
51
|
+
className: `${blockClass}-first`
|
|
52
|
+
}, welcomeText, ", "), /*#__PURE__*/React.createElement("span", {
|
|
53
|
+
className: `${blockClass}-second`
|
|
54
|
+
}, userName))));
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.default = HeaderTitle;
|
|
@@ -50,9 +50,10 @@ const TasksController = ({
|
|
|
50
50
|
setSelectedTileGroup?.(e);
|
|
51
51
|
dropdownCustomOnChange?.(e);
|
|
52
52
|
},
|
|
53
|
+
'aria-label': tasksControllerConfig?.dropdown?.ariaLabel ?? 'Select a task group',
|
|
53
54
|
...dropdownOverrideProps
|
|
54
55
|
};
|
|
55
|
-
}, [allTileGroups,
|
|
56
|
+
}, [allTileGroups, blockClass, dropdownCustomClass, selectedTileGroup, tasksControllerConfig?.dropdown?.ariaLabel, dropdownOverrideProps, setSelectedTileGroup, dropdownCustomOnChange]);
|
|
56
57
|
if (!tasksControllerConfig?.type) {
|
|
57
58
|
return null;
|
|
58
59
|
}
|
|
@@ -26,7 +26,8 @@ const AIPromptTile = ({
|
|
|
26
26
|
isLoading,
|
|
27
27
|
isDisabled,
|
|
28
28
|
disabledTaskLabel,
|
|
29
|
-
onClick
|
|
29
|
+
onClick,
|
|
30
|
+
ariaLabel
|
|
30
31
|
}) => {
|
|
31
32
|
const prefix = usePrefix.usePrefix();
|
|
32
33
|
const blockClass = `${prefix}--animated-header__ai-prompt-tile`;
|
|
@@ -50,6 +51,8 @@ const AIPromptTile = ({
|
|
|
50
51
|
return /*#__PURE__*/React.createElement("div", {
|
|
51
52
|
id: `${blockClass}`,
|
|
52
53
|
className: `${prefix}--animated-header__tile ${blockClass}${isDisabled ? ' ' + disabled : ''}`,
|
|
54
|
+
"aria-label": ariaLabel ?? title ?? 'AI Tile',
|
|
55
|
+
role: "listitem",
|
|
53
56
|
title: isDisabled ? disabledTaskLabel ?? '' : '',
|
|
54
57
|
key: id
|
|
55
58
|
}, isLoading ? /*#__PURE__*/React.createElement(react.SkeletonPlaceholder, {
|
|
@@ -26,7 +26,8 @@ const GlassTile = ({
|
|
|
26
26
|
isLoading,
|
|
27
27
|
isDisabled,
|
|
28
28
|
disabledTaskLabel,
|
|
29
|
-
onClick: glassTileClickHandler
|
|
29
|
+
onClick: glassTileClickHandler,
|
|
30
|
+
ariaLabel
|
|
30
31
|
}) => {
|
|
31
32
|
const prefix = usePrefix.usePrefix();
|
|
32
33
|
const blockClass = `${prefix}--animated-header__glass-tile`;
|
|
@@ -44,7 +45,10 @@ const GlassTile = ({
|
|
|
44
45
|
if (!href && !glassTileClickHandler) {
|
|
45
46
|
return /*#__PURE__*/React.createElement("div", {
|
|
46
47
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
47
|
-
key: id
|
|
48
|
+
key: id,
|
|
49
|
+
"aria-label": ariaLabel ?? title ?? 'Glass Tile',
|
|
50
|
+
title: isDisabled ? disabledTaskLabel ?? '' : '',
|
|
51
|
+
tabIndex: -1
|
|
48
52
|
}, body);
|
|
49
53
|
}
|
|
50
54
|
return /*#__PURE__*/React.createElement(react.Link, {
|
|
@@ -52,6 +56,9 @@ const GlassTile = ({
|
|
|
52
56
|
glassTileClickHandler?.();
|
|
53
57
|
},
|
|
54
58
|
className: `${prefix}--animated-header__tile ${blockClass}`,
|
|
59
|
+
"aria-label": ariaLabel ?? title ?? 'Glass Tile',
|
|
60
|
+
role: "listitem",
|
|
61
|
+
tabIndex: isDisabled || isLoading ? -1 : 0,
|
|
55
62
|
key: id,
|
|
56
63
|
href: href ?? undefined,
|
|
57
64
|
disabled: isDisabled || isLoading,
|
|
@@ -13,6 +13,7 @@ export interface Workspace {
|
|
|
13
13
|
}
|
|
14
14
|
export type WorkspaceSelectorConfig = {
|
|
15
15
|
propsOverrides: Partial<Omit<DropdownProps<Workspace>, 'id' | 'items' | 'selectedItem' | 'setSelectedWorkspace'>>;
|
|
16
|
+
ariaLabel?: string;
|
|
16
17
|
allWorkspaces: Workspace[];
|
|
17
18
|
selectedWorkspace?: Workspace | null;
|
|
18
19
|
setSelectedWorkspace: (e: any) => void;
|
|
@@ -43,6 +43,7 @@ const WorkspaceSelector = ({
|
|
|
43
43
|
workspaceSelectorConfig?.setSelectedWorkspace?.(e);
|
|
44
44
|
dropdownCustomOnChange?.(e);
|
|
45
45
|
},
|
|
46
|
+
'aria-label': workspaceSelectorConfig?.ariaLabel ?? 'Select a workspace',
|
|
46
47
|
...dropdownOverrideProps
|
|
47
48
|
};
|
|
48
49
|
}, [blockClass, dropdownCustomClass, dropdownOverrideProps, userName, workspaceSelectorConfig, dropdownCustomOnChange]);
|
package/lib/index.d.ts
CHANGED
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* This source code is licensed under the Apache-2.0 license found in the
|
|
7
7
|
* LICENSE file in the root directory of this source tree.
|
|
8
8
|
*/
|
|
9
|
-
import AnimatedHeader from './components/AnimatedHeader/AnimatedHeader';
|
|
9
|
+
import AnimatedHeader, { AriaLabels } from './components/AnimatedHeader/AnimatedHeader';
|
|
10
|
+
import HeaderTitle from './components/HeaderTitle/HeaderTitle';
|
|
10
11
|
import { BaseTile } from './components/Tiles/index.js';
|
|
11
12
|
export * from './assets';
|
|
12
13
|
export type { Workspace, WorkspaceSelectorConfig, } from './components/WorkspaceSelector/WorkspaceSelector';
|
|
13
14
|
export type { TasksControllerConfig } from './components/TasksController/TasksController';
|
|
14
|
-
export { AnimatedHeader, BaseTile };
|
|
15
|
+
export { AnimatedHeader, BaseTile, HeaderTitle, type AriaLabels };
|
package/lib/index.js
CHANGED
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
'use strict';
|
|
9
9
|
|
|
10
10
|
var AnimatedHeader = require('./components/AnimatedHeader/AnimatedHeader.js');
|
|
11
|
+
var HeaderTitle = require('./components/HeaderTitle/HeaderTitle.js');
|
|
11
12
|
require('react');
|
|
12
13
|
require('@carbon/react');
|
|
13
14
|
require('@carbon/react/icons');
|
|
@@ -26,6 +27,7 @@ var header_illustration_container_wxbia_dark_05 = require('./assets/animated/hea
|
|
|
26
27
|
|
|
27
28
|
|
|
28
29
|
exports.AnimatedHeader = AnimatedHeader.default;
|
|
30
|
+
exports.HeaderTitle = HeaderTitle.default;
|
|
29
31
|
exports.BaseTile = BaseTile.BaseTile;
|
|
30
32
|
exports.dataFabricAnimatedLight = header_1312x738_data_fabric_light_03.default;
|
|
31
33
|
exports.dataFabricAnimatedDark = header_1312x738_data_fabric_dark_06.default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@carbon-labs/react-animated-header",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@carbon-labs/utilities": "canary"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "08382345837d436d247447996fd43c11f12a36bc"
|
|
49
49
|
}
|