@carbon-labs/react-animated-header 0.3.0 → 0.4.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 +497 -587
- package/es/__stories__/data/index.d.ts +18 -8
- package/es/components/AnimatedHeader/AnimatedHeader.d.ts +26 -15
- package/es/components/AnimatedHeader/AnimatedHeader.js +63 -65
- package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +3 -3
- package/es/components/Tiles/AIPromptTile/AIPromptTile.js +7 -5
- package/es/components/Tiles/GlassTile/GlassTile.d.ts +3 -3
- package/es/components/Tiles/GlassTile/GlassTile.js +4 -4
- package/es/node_modules/@carbon/icons-react/es/Icon.js +1 -1
- package/lib/__stories__/AnimatedHeader.stories.d.ts +497 -587
- package/lib/__stories__/data/index.d.ts +18 -8
- package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +26 -15
- package/lib/components/AnimatedHeader/AnimatedHeader.js +62 -64
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +3 -3
- package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +7 -5
- package/lib/components/Tiles/GlassTile/GlassTile.d.ts +3 -3
- package/lib/components/Tiles/GlassTile/GlassTile.js +4 -4
- package/lib/node_modules/@carbon/icons-react/es/Icon.js +1 -1
- package/package.json +2 -2
- package/scss/AnimatedHeader/animated-header.scss +17 -11
- package/scss/Tiles/AIPromptTile/ai-prompt-tile.scss +11 -4
- package/scss/Tiles/GlassTile/glass-tile.scss +4 -2
- /package/es/node_modules/@carbon/{icon-helpers → icons-react/node_modules/@carbon/icon-helpers}/es/index.js +0 -0
- /package/lib/node_modules/@carbon/{icon-helpers → icons-react/node_modules/@carbon/icon-helpers}/es/index.js +0 -0
|
@@ -1,11 +1,3 @@
|
|
|
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
1
|
export const workspaceData: {
|
|
10
2
|
id: string;
|
|
11
3
|
text: string;
|
|
@@ -45,3 +37,21 @@ export const headerTiles: ({
|
|
|
45
37
|
subtitle?: undefined;
|
|
46
38
|
})[];
|
|
47
39
|
})[];
|
|
40
|
+
export namespace tasksConfigButton {
|
|
41
|
+
let type: string;
|
|
42
|
+
namespace button {
|
|
43
|
+
export let href: string;
|
|
44
|
+
export { Add as icon };
|
|
45
|
+
export let text: string;
|
|
46
|
+
let type_1: "tertiary";
|
|
47
|
+
export { type_1 as type };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
export namespace tasksConfigDropdown {
|
|
51
|
+
let type_2: string;
|
|
52
|
+
export { type_2 as type };
|
|
53
|
+
export namespace dropdown {
|
|
54
|
+
let label: string;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
import { Add } from '@carbon/react/icons';
|
|
@@ -1,17 +1,29 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ButtonKind } from '@carbon/react';
|
|
3
3
|
/** Animated Header */
|
|
4
|
+
export interface TasksConfig {
|
|
5
|
+
type: 'button' | 'dropdown' | string;
|
|
6
|
+
button?: {
|
|
7
|
+
href?: string;
|
|
8
|
+
icon?: any;
|
|
9
|
+
text?: string;
|
|
10
|
+
type?: ButtonKind;
|
|
11
|
+
};
|
|
12
|
+
dropdown?: {
|
|
13
|
+
label?: string;
|
|
14
|
+
};
|
|
15
|
+
}
|
|
4
16
|
export interface SelectedWorkspace {
|
|
5
17
|
id: string;
|
|
6
18
|
text: string;
|
|
7
19
|
}
|
|
8
20
|
export interface Tile {
|
|
9
|
-
id: string;
|
|
10
21
|
href: string | null;
|
|
11
|
-
|
|
12
|
-
subtitle: string | null;
|
|
22
|
+
id: string;
|
|
13
23
|
mainIcon: string | null;
|
|
14
|
-
secondaryIcon
|
|
24
|
+
secondaryIcon?: string | null;
|
|
25
|
+
subtitle?: string | null;
|
|
26
|
+
title: string | null;
|
|
15
27
|
}
|
|
16
28
|
export interface TileGroup {
|
|
17
29
|
id: number;
|
|
@@ -19,21 +31,20 @@ export interface TileGroup {
|
|
|
19
31
|
tiles: Tile[];
|
|
20
32
|
}
|
|
21
33
|
export interface AnimatedHeaderProps {
|
|
22
|
-
|
|
34
|
+
allTiles: TileGroup[];
|
|
35
|
+
allWorkspaces?: SelectedWorkspace[];
|
|
23
36
|
description?: string;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
buttonIcon?: any;
|
|
27
|
-
headerDropdown?: boolean;
|
|
37
|
+
headerAnimation?: object;
|
|
38
|
+
headerStatic?: React.JSX.Element;
|
|
28
39
|
productName?: string;
|
|
29
|
-
selectedWorkspace?: SelectedWorkspace[] | any;
|
|
30
|
-
setSelectedWorkspace: (e: any) => void;
|
|
31
|
-
allWorkspaces?: SelectedWorkspace[];
|
|
32
40
|
selectedTileGroup: TileGroup[] | any;
|
|
41
|
+
selectedWorkspace?: SelectedWorkspace | any;
|
|
33
42
|
setSelectedTileGroup: (e: any) => void;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
43
|
+
setSelectedWorkspace: (e: any) => void;
|
|
44
|
+
tasksConfig?: TasksConfig;
|
|
45
|
+
userName?: string;
|
|
46
|
+
welcomeText?: string;
|
|
47
|
+
workspaceLabel?: string;
|
|
37
48
|
}
|
|
38
49
|
declare const AnimatedHeader: React.FC<AnimatedHeaderProps>;
|
|
39
50
|
export default AnimatedHeader;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
import PropTypes from 'prop-types';
|
|
9
9
|
import React, { useState, useEffect, createRef } from 'react';
|
|
10
|
-
import {
|
|
10
|
+
import { Grid, Column, Tooltip, Button, Dropdown, IconButton } from '@carbon/react';
|
|
11
11
|
import lottie from '../../_virtual/lottie.js';
|
|
12
12
|
import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
|
|
13
13
|
import { BaseTile } from '../Tiles/BaseTile/BaseTile.js';
|
|
@@ -21,25 +21,24 @@ var _PauseFilled, _PlayFilledAlt;
|
|
|
21
21
|
|
|
22
22
|
const AnimatedHeader = _ref => {
|
|
23
23
|
let {
|
|
24
|
-
|
|
24
|
+
allTiles,
|
|
25
|
+
allWorkspaces,
|
|
25
26
|
description,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
buttonIcon = null,
|
|
29
|
-
headerDropdown = false,
|
|
27
|
+
headerAnimation,
|
|
28
|
+
headerStatic,
|
|
30
29
|
productName = '[Product name]',
|
|
31
|
-
selectedWorkspace,
|
|
32
|
-
setSelectedWorkspace,
|
|
33
|
-
allWorkspaces,
|
|
34
30
|
selectedTileGroup,
|
|
31
|
+
selectedWorkspace,
|
|
35
32
|
setSelectedTileGroup,
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
33
|
+
setSelectedWorkspace,
|
|
34
|
+
tasksConfig,
|
|
35
|
+
userName,
|
|
36
|
+
welcomeText,
|
|
37
|
+
workspaceLabel = `Open in: ${userName}'s workspace` || `Select a workspace`
|
|
39
38
|
} = _ref;
|
|
40
39
|
const prefix = usePrefix();
|
|
41
40
|
const blockClass = `${prefix}--animated-header`;
|
|
42
|
-
|
|
41
|
+
const animationContainer = /*#__PURE__*/createRef();
|
|
43
42
|
const [open, setOpen] = useState(true);
|
|
44
43
|
const [playing, setPlaying] = useState(true);
|
|
45
44
|
const [headingTextAnimation, setHeadingTextAnimation] = useState('');
|
|
@@ -63,7 +62,7 @@ const AnimatedHeader = _ref => {
|
|
|
63
62
|
setPlaying(!playing);
|
|
64
63
|
};
|
|
65
64
|
useEffect(() => {
|
|
66
|
-
|
|
65
|
+
const animation = lottie.loadAnimation({
|
|
67
66
|
container: animationContainer.current,
|
|
68
67
|
animationData: headerAnimation,
|
|
69
68
|
renderer: 'svg',
|
|
@@ -84,7 +83,7 @@ const AnimatedHeader = _ref => {
|
|
|
84
83
|
animation.setSpeed(lottieLoopSpeed);
|
|
85
84
|
animation.playSegments([animationData.markers.at(1).tm, animationData.op], true);
|
|
86
85
|
}
|
|
87
|
-
if (
|
|
86
|
+
if (isReduced) {
|
|
88
87
|
// reduced motion on
|
|
89
88
|
animation.addEventListener('DOMLoaded', reducedMotion);
|
|
90
89
|
} else {
|
|
@@ -96,7 +95,12 @@ const AnimatedHeader = _ref => {
|
|
|
96
95
|
// Run Looped Animation
|
|
97
96
|
animation.addEventListener('complete', loop);
|
|
98
97
|
}
|
|
99
|
-
|
|
98
|
+
return () => {
|
|
99
|
+
animation?.removeEventListener('DOMLoaded', reducedMotion);
|
|
100
|
+
animation?.removeEventListener('DOMLoaded', load);
|
|
101
|
+
animation?.removeEventListener('complete', loop);
|
|
102
|
+
};
|
|
103
|
+
}, [animationContainer, headerAnimation, isReduced]);
|
|
100
104
|
return /*#__PURE__*/React.createElement("section", {
|
|
101
105
|
className: `${blockClass} ${!open && collapsed}`
|
|
102
106
|
}, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement("div", {
|
|
@@ -121,14 +125,14 @@ const AnimatedHeader = _ref => {
|
|
|
121
125
|
lg: 16
|
|
122
126
|
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
123
127
|
align: "bottom",
|
|
124
|
-
label:
|
|
128
|
+
label: `${welcomeText}, ${userName}`
|
|
125
129
|
}, /*#__PURE__*/React.createElement("h1", {
|
|
126
130
|
className: `${blockClass}__heading ${headingTextAnimation}`
|
|
127
131
|
}, /*#__PURE__*/React.createElement("span", {
|
|
128
132
|
className: `${blockClass}__heading-welcome`
|
|
129
|
-
}, "
|
|
133
|
+
}, welcomeText, ",", ' '), /*#__PURE__*/React.createElement("span", {
|
|
130
134
|
className: `${blockClass}__heading-name`
|
|
131
|
-
},
|
|
135
|
+
}, userName)))), (description || tasksConfig && tasksConfig.type === 'button' && tasksConfig.button?.text || tasksConfig && tasksConfig.type === 'dropdown' && tasksConfig.dropdown?.label) && /*#__PURE__*/React.createElement(Column, {
|
|
132
136
|
sm: 4,
|
|
133
137
|
md: 8,
|
|
134
138
|
lg: 4,
|
|
@@ -138,20 +142,19 @@ const AnimatedHeader = _ref => {
|
|
|
138
142
|
label: description
|
|
139
143
|
}, /*#__PURE__*/React.createElement("h2", {
|
|
140
144
|
className: `${blockClass}__description`
|
|
141
|
-
}, description)),
|
|
145
|
+
}, description)), tasksConfig?.button?.text && /*#__PURE__*/React.createElement(Button, {
|
|
142
146
|
className: `${blockClass}__button`,
|
|
143
|
-
kind:
|
|
144
|
-
renderIcon:
|
|
145
|
-
|
|
147
|
+
kind: tasksConfig.button.type,
|
|
148
|
+
renderIcon: tasksConfig.button.icon,
|
|
149
|
+
href: tasksConfig.button.href
|
|
150
|
+
}, tasksConfig.button.text), !tasksConfig?.button?.text && tasksConfig && tasksConfig.type === 'dropdown' && allTiles && /*#__PURE__*/React.createElement("div", {
|
|
146
151
|
className: `${blockClass}__header-dropdown--container`
|
|
147
152
|
}, /*#__PURE__*/React.createElement(Dropdown, {
|
|
148
153
|
id: `${blockClass}__header-dropdown`,
|
|
149
154
|
className: `${blockClass}__header-dropdown`,
|
|
150
155
|
size: "md",
|
|
151
|
-
autoAlign: true,
|
|
152
156
|
titleText: "Label",
|
|
153
|
-
|
|
154
|
-
label: allTiles[0].name || 'Select an option below',
|
|
157
|
+
label: tasksConfig.dropdown?.label || allTiles[0].name,
|
|
155
158
|
hideLabel: true,
|
|
156
159
|
type: "inline",
|
|
157
160
|
items: allTiles,
|
|
@@ -169,7 +172,7 @@ const AnimatedHeader = _ref => {
|
|
|
169
172
|
className: `${blockClass}__workspace`,
|
|
170
173
|
size: "sm",
|
|
171
174
|
titleText: "Label",
|
|
172
|
-
label:
|
|
175
|
+
label: workspaceLabel,
|
|
173
176
|
hideLabel: true,
|
|
174
177
|
type: "inline",
|
|
175
178
|
items: allWorkspaces,
|
|
@@ -215,76 +218,71 @@ const AnimatedHeader = _ref => {
|
|
|
215
218
|
AnimatedHeader.displayName = 'Animated Header';
|
|
216
219
|
AnimatedHeader.propTypes = {
|
|
217
220
|
/**
|
|
218
|
-
*
|
|
219
|
-
*/
|
|
220
|
-
className: PropTypes.string,
|
|
221
|
-
/**
|
|
222
|
-
* Specify the current username of active user
|
|
221
|
+
* Array of each tile group setup
|
|
223
222
|
*/
|
|
224
|
-
|
|
223
|
+
allTiles: PropTypes.arrayOf(PropTypes.object),
|
|
225
224
|
/**
|
|
226
|
-
*
|
|
225
|
+
* Array of all workspace options
|
|
227
226
|
*/
|
|
228
|
-
|
|
227
|
+
allWorkspaces: PropTypes.arrayOf(PropTypes.object),
|
|
229
228
|
/**
|
|
230
|
-
*
|
|
231
|
-
* the user or content that triggers an action and allow users to
|
|
232
|
-
* directly start working and gain value (within one click)
|
|
229
|
+
* Specify an optional className to be added to your Animated Header
|
|
233
230
|
*/
|
|
234
|
-
|
|
231
|
+
className: PropTypes.string,
|
|
235
232
|
/**
|
|
236
|
-
*
|
|
233
|
+
* Provide short sentence in max. 3 lines related to product context
|
|
237
234
|
*/
|
|
238
|
-
|
|
235
|
+
description: PropTypes.string,
|
|
239
236
|
/**
|
|
240
|
-
*
|
|
241
|
-
*
|
|
237
|
+
* In-product imagery / lottie animation (.json) dim. 1312 x 738
|
|
238
|
+
* (to update headerAnimation content storybook requires remount in toolbar)
|
|
242
239
|
*/
|
|
243
|
-
|
|
240
|
+
headerAnimation: PropTypes.object,
|
|
244
241
|
/**
|
|
245
|
-
*
|
|
242
|
+
* In-product imagery / static imagery dim. 1312 x 738
|
|
243
|
+
* Only active when headerAnimation is not in use
|
|
246
244
|
*/
|
|
247
|
-
|
|
245
|
+
headerStatic: PropTypes.object,
|
|
248
246
|
/**
|
|
249
247
|
* Provide current product name
|
|
250
248
|
*/
|
|
251
249
|
productName: PropTypes.string,
|
|
250
|
+
/**
|
|
251
|
+
* The tile group that is active in the header
|
|
252
|
+
* ex. "AI Chat Tile w/ two glass tiles", "Four glass tiles", ect.
|
|
253
|
+
*/
|
|
254
|
+
selectedTileGroup: PropTypes.object,
|
|
252
255
|
/**
|
|
253
256
|
* Object containing workspace selection
|
|
254
257
|
* `Open in: "_"`
|
|
255
258
|
*/
|
|
256
259
|
selectedWorkspace: PropTypes.object,
|
|
257
260
|
/**
|
|
258
|
-
* Provide function to be called when switching
|
|
259
|
-
*/
|
|
260
|
-
setSelectedWorkspace: PropTypes.func,
|
|
261
|
-
/**
|
|
262
|
-
* Array of all workspace options
|
|
261
|
+
* Provide function to be called when switching selected tile group
|
|
263
262
|
*/
|
|
264
|
-
|
|
263
|
+
setSelectedTileGroup: PropTypes.func,
|
|
265
264
|
/**
|
|
266
|
-
*
|
|
267
|
-
* ex. "AI Chat Tile w/ two glass tiles", "Four glass tiles", ect.
|
|
265
|
+
* Provide function to be called when switching workspace selection
|
|
268
266
|
*/
|
|
269
|
-
|
|
267
|
+
setSelectedWorkspace: PropTypes.func,
|
|
270
268
|
/**
|
|
271
|
-
*
|
|
269
|
+
* Configuration for Carbon button or dropdown menu in header. Customized
|
|
270
|
+
* tasks are used to allow users that have multiple roles and permissions
|
|
271
|
+
* to experience better tailored content based on their need.
|
|
272
272
|
*/
|
|
273
|
-
|
|
273
|
+
tasksConfig: PropTypes.object,
|
|
274
274
|
/**
|
|
275
|
-
*
|
|
275
|
+
* Specify the current username of active user
|
|
276
276
|
*/
|
|
277
|
-
|
|
277
|
+
userName: PropTypes.string,
|
|
278
278
|
/**
|
|
279
|
-
*
|
|
280
|
-
* (to update headerAnimation content storybook requires remount in toolbar)
|
|
279
|
+
* Specify the current welcome text on the header
|
|
281
280
|
*/
|
|
282
|
-
|
|
281
|
+
welcomeText: PropTypes.string,
|
|
283
282
|
/**
|
|
284
|
-
*
|
|
285
|
-
* Only active when headerAnimation is not in use
|
|
283
|
+
* Specify the default workspace label above the tiles
|
|
286
284
|
*/
|
|
287
|
-
|
|
285
|
+
workspaceLabel: PropTypes.string
|
|
288
286
|
};
|
|
289
287
|
|
|
290
288
|
export { AnimatedHeader as default };
|
|
@@ -9,12 +9,12 @@
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
/** Primary UI component for user interaction */
|
|
11
11
|
interface AIPromptTileProps {
|
|
12
|
-
id?: string;
|
|
13
12
|
href?: string;
|
|
14
|
-
|
|
13
|
+
id?: string;
|
|
15
14
|
mainIcon?: string;
|
|
16
|
-
|
|
15
|
+
open?: boolean;
|
|
17
16
|
productName?: string;
|
|
17
|
+
title?: string;
|
|
18
18
|
}
|
|
19
19
|
export declare const AIPromptTile: React.FC<AIPromptTileProps>;
|
|
20
20
|
export {};
|
|
@@ -17,12 +17,12 @@ var _AILabel;
|
|
|
17
17
|
|
|
18
18
|
const AIPromptTile = _ref => {
|
|
19
19
|
let {
|
|
20
|
-
id,
|
|
21
20
|
href,
|
|
22
|
-
|
|
21
|
+
id,
|
|
23
22
|
mainIcon,
|
|
24
|
-
|
|
25
|
-
productName
|
|
23
|
+
open,
|
|
24
|
+
productName,
|
|
25
|
+
title
|
|
26
26
|
} = _ref;
|
|
27
27
|
const prefix = usePrefix();
|
|
28
28
|
const blockClass = `${prefix}--animated-header__ai-prompt-tile`;
|
|
@@ -35,7 +35,9 @@ const AIPromptTile = _ref => {
|
|
|
35
35
|
};
|
|
36
36
|
const openInNewTab = url => {
|
|
37
37
|
const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
|
|
38
|
-
if (newWindow)
|
|
38
|
+
if (newWindow) {
|
|
39
|
+
newWindow.opener = null;
|
|
40
|
+
}
|
|
39
41
|
};
|
|
40
42
|
const handleTextInputKeyDown = event => {
|
|
41
43
|
if (event.key === 'Enter') {
|
|
@@ -9,13 +9,13 @@
|
|
|
9
9
|
import React from 'react';
|
|
10
10
|
/** Primary UI component for user interaction */
|
|
11
11
|
interface GlassTileProps {
|
|
12
|
-
id?: string;
|
|
13
12
|
href?: string;
|
|
14
|
-
|
|
13
|
+
id?: string;
|
|
15
14
|
mainIcon?: string;
|
|
15
|
+
open?: boolean;
|
|
16
16
|
secondaryIcon?: string;
|
|
17
|
-
title?: string;
|
|
18
17
|
subtitle?: string;
|
|
18
|
+
title?: string;
|
|
19
19
|
}
|
|
20
20
|
export declare const GlassTile: React.FC<GlassTileProps>;
|
|
21
21
|
export {};
|
|
@@ -14,13 +14,13 @@ import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePr
|
|
|
14
14
|
|
|
15
15
|
const GlassTile = _ref => {
|
|
16
16
|
let {
|
|
17
|
-
id,
|
|
18
17
|
href,
|
|
19
|
-
|
|
18
|
+
id,
|
|
20
19
|
mainIcon,
|
|
20
|
+
open,
|
|
21
21
|
secondaryIcon,
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
subtitle,
|
|
23
|
+
title
|
|
24
24
|
} = _ref;
|
|
25
25
|
const prefix = usePrefix();
|
|
26
26
|
const blockClass = `${prefix}--animated-header__glass-tile`;
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* LICENSE file in the root directory of this source tree.
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
import { getAttributes } from '
|
|
8
|
+
import { getAttributes } from '../node_modules/@carbon/icon-helpers/es/index.js';
|
|
9
9
|
import PropTypes from 'prop-types';
|
|
10
10
|
import React from 'react';
|
|
11
11
|
|