@carbon-labs/react-animated-header 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (92) hide show
  1. package/LICENSE +201 -0
  2. package/es/__stories__/AnimatedHeader.stories.d.ts +17275 -0
  3. package/es/_virtual/_commonjsHelpers.js +12 -0
  4. package/es/_virtual/lottie.js +14 -0
  5. package/es/_virtual/lottie2.js +10 -0
  6. package/es/assets/index.d.ts +7 -0
  7. package/es/components/AnimatedHeader/AnimatedHeader.d.ts +31 -0
  8. package/es/components/AnimatedHeader/AnimatedHeader.js +277 -0
  9. package/es/components/Tiles/AIPromptTile/AIPromptTile.d.ts +20 -0
  10. package/es/components/Tiles/AIPromptTile/AIPromptTile.js +94 -0
  11. package/es/components/Tiles/BaseTile/BaseTile.d.ts +22 -0
  12. package/es/components/Tiles/BaseTile/BaseTile.js +39 -0
  13. package/es/components/Tiles/GlassTile/GlassTile.d.ts +21 -0
  14. package/es/components/Tiles/GlassTile/GlassTile.js +53 -0
  15. package/es/components/Tiles/index.d.ts +12 -0
  16. package/es/data/index.d.ts +47 -0
  17. package/es/index.d.ts +11 -0
  18. package/es/index.js +11 -0
  19. package/es/node_modules/@carbon/icon-helpers/es/index.js +125 -0
  20. package/es/node_modules/@carbon/icons-react/es/Icon.js +71 -0
  21. package/es/node_modules/@carbon/icons-react/es/generated/bucket-0.js +2967 -0
  22. package/es/node_modules/@carbon/icons-react/es/generated/bucket-1.js +3260 -0
  23. package/es/node_modules/@carbon/icons-react/es/generated/bucket-10.js +2906 -0
  24. package/es/node_modules/@carbon/icons-react/es/generated/bucket-11.js +3151 -0
  25. package/es/node_modules/@carbon/icons-react/es/generated/bucket-12.js +2966 -0
  26. package/es/node_modules/@carbon/icons-react/es/generated/bucket-13.js +3019 -0
  27. package/es/node_modules/@carbon/icons-react/es/generated/bucket-14.js +2923 -0
  28. package/es/node_modules/@carbon/icons-react/es/generated/bucket-15.js +3076 -0
  29. package/es/node_modules/@carbon/icons-react/es/generated/bucket-16.js +2913 -0
  30. package/es/node_modules/@carbon/icons-react/es/generated/bucket-17.js +2917 -0
  31. package/es/node_modules/@carbon/icons-react/es/generated/bucket-18.js +3141 -0
  32. package/es/node_modules/@carbon/icons-react/es/generated/bucket-19.js +811 -0
  33. package/es/node_modules/@carbon/icons-react/es/generated/bucket-2.js +3195 -0
  34. package/es/node_modules/@carbon/icons-react/es/generated/bucket-3.js +3119 -0
  35. package/es/node_modules/@carbon/icons-react/es/generated/bucket-4.js +3002 -0
  36. package/es/node_modules/@carbon/icons-react/es/generated/bucket-5.js +2929 -0
  37. package/es/node_modules/@carbon/icons-react/es/generated/bucket-6.js +2978 -0
  38. package/es/node_modules/@carbon/icons-react/es/generated/bucket-7.js +3017 -0
  39. package/es/node_modules/@carbon/icons-react/es/generated/bucket-8.js +3149 -0
  40. package/es/node_modules/@carbon/icons-react/es/generated/bucket-9.js +3084 -0
  41. package/es/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +14 -0
  42. package/es/node_modules/@carbon/icons-react/es/index.js +30 -0
  43. package/es/node_modules/@carbon-labs/utilities/es/usePrefix.js +20 -0
  44. package/es/node_modules/lottie-web/build/player/lottie.js +682 -0
  45. package/lib/__stories__/AnimatedHeader.stories.d.ts +17275 -0
  46. package/lib/_virtual/_commonjsHelpers.js +14 -0
  47. package/lib/_virtual/lottie.js +18 -0
  48. package/lib/_virtual/lottie2.js +12 -0
  49. package/lib/assets/index.d.ts +7 -0
  50. package/lib/components/AnimatedHeader/AnimatedHeader.d.ts +31 -0
  51. package/lib/components/AnimatedHeader/AnimatedHeader.js +281 -0
  52. package/lib/components/Tiles/AIPromptTile/AIPromptTile.d.ts +20 -0
  53. package/lib/components/Tiles/AIPromptTile/AIPromptTile.js +96 -0
  54. package/lib/components/Tiles/BaseTile/BaseTile.d.ts +22 -0
  55. package/lib/components/Tiles/BaseTile/BaseTile.js +41 -0
  56. package/lib/components/Tiles/GlassTile/GlassTile.d.ts +21 -0
  57. package/lib/components/Tiles/GlassTile/GlassTile.js +55 -0
  58. package/lib/components/Tiles/index.d.ts +12 -0
  59. package/lib/data/index.d.ts +47 -0
  60. package/lib/index.d.ts +11 -0
  61. package/lib/index.js +18 -0
  62. package/lib/node_modules/@carbon/icon-helpers/es/index.js +128 -0
  63. package/lib/node_modules/@carbon/icons-react/es/Icon.js +75 -0
  64. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-0.js +3093 -0
  65. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-1.js +3386 -0
  66. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-10.js +3032 -0
  67. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-11.js +3277 -0
  68. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-12.js +3092 -0
  69. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-13.js +3145 -0
  70. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-14.js +3049 -0
  71. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-15.js +3202 -0
  72. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-16.js +3039 -0
  73. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-17.js +3043 -0
  74. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-18.js +3267 -0
  75. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-19.js +847 -0
  76. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-2.js +3321 -0
  77. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-3.js +3245 -0
  78. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-4.js +3128 -0
  79. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-5.js +3055 -0
  80. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-6.js +3104 -0
  81. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-7.js +3143 -0
  82. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-8.js +3275 -0
  83. package/lib/node_modules/@carbon/icons-react/es/generated/bucket-9.js +3210 -0
  84. package/lib/node_modules/@carbon/icons-react/es/iconPropTypes-4cbeb95d.js +16 -0
  85. package/lib/node_modules/@carbon/icons-react/es/index.js +2446 -0
  86. package/lib/node_modules/@carbon-labs/utilities/es/usePrefix.js +23 -0
  87. package/lib/node_modules/lottie-web/build/player/lottie.js +684 -0
  88. package/package.json +35 -0
  89. package/scss/AnimatedHeader/animated-header.scss +619 -0
  90. package/scss/Tiles/AIPromptTile/ai-prompt-tile.scss +187 -0
  91. package/scss/Tiles/GlassTile/glass-tile.scss +111 -0
  92. package/scss/animated_header.scss +10 -0
@@ -0,0 +1,12 @@
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
+ function getDefaultExportFromCjs (x) {
9
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
10
+ }
11
+
12
+ export { getDefaultExportFromCjs };
@@ -0,0 +1,14 @@
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
+ import { getDefaultExportFromCjs } from './_commonjsHelpers.js';
9
+ import { __require as requireLottie } from '../node_modules/lottie-web/build/player/lottie.js';
10
+
11
+ var lottieExports = requireLottie();
12
+ var lottie = /*@__PURE__*/getDefaultExportFromCjs(lottieExports);
13
+
14
+ export { lottie as default };
@@ -0,0 +1,10 @@
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
+ var lottie = {exports: {}};
9
+
10
+ export { lottie as __module };
@@ -0,0 +1,7 @@
1
+ import dataFabricAnimatedLight from './animated/header_1312x738_data_fabric_light_03.json';
2
+ import dataFabricAnimatedDark from './animated/header_1312x738_data_fabric_dark_06.json';
3
+ import watsonXAnimatedLight from './animated/header_1312x738_watsonx_data_light_03.json';
4
+ import watsonXAnimatedDark from './animated/header_1312x738_watsonx_data_dark_02.json';
5
+ import wxbiaAnimatedLight from './animated/header_illustration_container_wxbia_light_08.json';
6
+ import wxbiaAnimatedDark from './animated/header_illustration_container_wxbia_dark_05.json';
7
+ export { dataFabricAnimatedLight, dataFabricAnimatedDark, dataFabricStaticLight, dataFabricStaticDark, watsonXAnimatedLight, watsonXAnimatedDark, watsonXStaticLight, watsonXStaticDark, wxbiaAnimatedLight, wxbiaAnimatedDark };
@@ -0,0 +1,31 @@
1
+ import React from 'react';
2
+ import { ButtonKind } from '@carbon/react';
3
+ /** Animated Header */
4
+ export interface Tile {
5
+ id: string;
6
+ href: string;
7
+ title: string;
8
+ mainIcon: string;
9
+ }
10
+ export interface TileGroup {
11
+ id: number;
12
+ name: string;
13
+ tiles: Tile[];
14
+ }
15
+ export interface AnimatedHeaderProps {
16
+ name?: string;
17
+ description?: string;
18
+ buttonText?: string;
19
+ buttonType?: ButtonKind;
20
+ buttonIcon?: any;
21
+ headerDropdown?: boolean;
22
+ productName?: string;
23
+ tileDropdownItems?: Array<object>;
24
+ selectedTileGroup: TileGroup[] | any;
25
+ setSelectedTileGroup: (e: any) => void;
26
+ allTiles: TileGroup[];
27
+ headerAnimation?: object;
28
+ headerStatic?: React.JSX.Element;
29
+ }
30
+ declare const AnimatedHeader: React.FC<AnimatedHeaderProps>;
31
+ export default AnimatedHeader;
@@ -0,0 +1,277 @@
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
+ import PropTypes from 'prop-types';
9
+ import React, { useState, useEffect, createRef } from 'react';
10
+ import { ButtonKinds, Grid, Column, Tooltip, Button, Dropdown, IconButton } from '@carbon/react';
11
+ import lottie from '../../_virtual/lottie.js';
12
+ import { usePrefix } from '../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
13
+ import { BaseTile } from '../Tiles/BaseTile/BaseTile.js';
14
+ import { PauseFilled } from '../../node_modules/@carbon/icons-react/es/generated/bucket-12.js';
15
+ import { PlayFilledAlt } from '../../node_modules/@carbon/icons-react/es/generated/bucket-13.js';
16
+ import { ChevronUp, ChevronDown } from '../../node_modules/@carbon/icons-react/es/generated/bucket-3.js';
17
+
18
+ var _PauseFilled, _PlayFilledAlt;
19
+
20
+ /** Animated Header */
21
+
22
+ const AnimatedHeader = _ref => {
23
+ let {
24
+ name,
25
+ description,
26
+ buttonText,
27
+ buttonType = 'tertiary',
28
+ buttonIcon = null,
29
+ headerDropdown = false,
30
+ productName = '[Product name]',
31
+ tileDropdownItems,
32
+ selectedTileGroup,
33
+ setSelectedTileGroup,
34
+ allTiles,
35
+ headerAnimation,
36
+ headerStatic
37
+ } = _ref;
38
+ const prefix = usePrefix();
39
+ const blockClass = `${prefix}-animated-header`;
40
+ let animationContainer = /*#__PURE__*/createRef();
41
+ const [open, setOpen] = useState(true);
42
+ const [playing, setPlaying] = useState(true);
43
+ const [headingTextAnimation, setHeadingTextAnimation] = useState('');
44
+ const isReduced = window.matchMedia('(prefers-reduced-motion)').matches;
45
+ const collapsed = `${blockClass}--collapsed`;
46
+ const contentCollapsed = `${blockClass}__content--collapsed`;
47
+ const descriptionCollapsed = `${blockClass}__left-area-container--collapsed`;
48
+ const headingCollapsed = `${blockClass}__heading--collapsed`;
49
+ const headingExpanded = `${blockClass}__heading--expanded`;
50
+ const lottieCollapsed = `${blockClass}__lottie-animation--collapsed`;
51
+ const handleButtonCollapseClick = () => {
52
+ setOpen(!open);
53
+ open ? setHeadingTextAnimation(headingCollapsed) : setHeadingTextAnimation(headingExpanded);
54
+ };
55
+ const handleLottieAnimationClick = () => {
56
+ if (playing) {
57
+ lottie.pause();
58
+ } else {
59
+ lottie.play();
60
+ }
61
+ setPlaying(!playing);
62
+ };
63
+ useEffect(() => {
64
+ let animation = lottie.loadAnimation({
65
+ container: animationContainer.current,
66
+ animationData: headerAnimation,
67
+ renderer: 'svg',
68
+ loop: false,
69
+ autoplay: false
70
+ });
71
+ const lottieLoadSpeed = 1;
72
+ const lottieLoopSpeed = 1;
73
+ const animationData = animation['animationData'];
74
+ function reducedMotion() {
75
+ animation.goToAndStop(5000);
76
+ }
77
+ function load() {
78
+ animation.setSpeed(lottieLoadSpeed);
79
+ animation.playSegments([animationData.markers.at(0).tm, animationData.markers.at(1).tm], true);
80
+ }
81
+ function loop() {
82
+ animation.setSpeed(lottieLoopSpeed);
83
+ animation.playSegments([animationData.markers.at(1).tm, animationData.op], true);
84
+ }
85
+ if (!!isReduced) {
86
+ // reduced motion on
87
+ animation.addEventListener('DOMLoaded', reducedMotion);
88
+ } else {
89
+ // reduced motion off
90
+
91
+ // Run Start Animation
92
+ animation.addEventListener('DOMLoaded', load);
93
+
94
+ // Run Looped Animation
95
+ animation.addEventListener('complete', loop);
96
+ }
97
+ }, []);
98
+ return /*#__PURE__*/React.createElement("section", {
99
+ className: `${blockClass} ${!open && collapsed}`
100
+ }, /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement("div", {
101
+ className: `${blockClass}__gradient--overlay`
102
+ }), /*#__PURE__*/React.createElement("div", {
103
+ className: `${blockClass}__container--gradient`
104
+ }), !headerAnimation && headerStatic && /*#__PURE__*/React.createElement("div", {
105
+ className: `${blockClass}__static--container`
106
+ }, /*#__PURE__*/React.createElement("div", {
107
+ className: `${blockClass}__static`,
108
+ style: {
109
+ backgroundImage: `url(${headerStatic})`
110
+ }
111
+ })), /*#__PURE__*/React.createElement("div", {
112
+ className: `${blockClass}__lottie-animation--container`
113
+ }, /*#__PURE__*/React.createElement("div", {
114
+ ref: animationContainer,
115
+ className: `${blockClass}__lottie-animation ${!open && lottieCollapsed}`
116
+ })), /*#__PURE__*/React.createElement(Column, {
117
+ sm: 4,
118
+ md: 8,
119
+ lg: 16
120
+ }, /*#__PURE__*/React.createElement(Tooltip, {
121
+ align: "bottom",
122
+ label: `Welcome, ${name}`
123
+ }, /*#__PURE__*/React.createElement("h1", {
124
+ className: `${blockClass}__heading ${headingTextAnimation}`
125
+ }, /*#__PURE__*/React.createElement("span", {
126
+ className: `${blockClass}__heading-welcome`
127
+ }, "Welcome,", ' '), /*#__PURE__*/React.createElement("span", {
128
+ className: `${blockClass}__heading-name`
129
+ }, name)))), (description || buttonText || headerDropdown) && /*#__PURE__*/React.createElement(Column, {
130
+ sm: 4,
131
+ md: 8,
132
+ lg: 4,
133
+ className: `${blockClass}__left-area-container ${!open && descriptionCollapsed}`
134
+ }, description && /*#__PURE__*/React.createElement(Tooltip, {
135
+ align: "bottom",
136
+ label: description
137
+ }, /*#__PURE__*/React.createElement("h2", {
138
+ className: `${blockClass}__description`
139
+ }, description)), buttonText && /*#__PURE__*/React.createElement(Button, {
140
+ className: `${blockClass}__button`,
141
+ kind: buttonType,
142
+ renderIcon: buttonIcon
143
+ }, buttonText), !buttonText && headerDropdown && allTiles && /*#__PURE__*/React.createElement(Dropdown, {
144
+ id: `${blockClass}__header-dropdown`,
145
+ className: `${blockClass}__header-dropdown`,
146
+ size: "md",
147
+ autoAlign: true,
148
+ titleText: "Label",
149
+ initialSelectedItem: allTiles[0],
150
+ label: allTiles[0].name,
151
+ hideLabel: true,
152
+ type: "inline",
153
+ items: allTiles,
154
+ itemToString: item => item ? item.name : '',
155
+ onChange: e => setSelectedTileGroup(e)
156
+ })), selectedTileGroup && /*#__PURE__*/React.createElement(Column, {
157
+ sm: 4,
158
+ md: 8,
159
+ lg: 12,
160
+ className: `${blockClass}__content`
161
+ }, tileDropdownItems && /*#__PURE__*/React.createElement("div", {
162
+ className: `${blockClass}__tile-dropdown--container ${!open && contentCollapsed}`
163
+ }, /*#__PURE__*/React.createElement(Dropdown, {
164
+ id: `${blockClass}__tile-dropdown`,
165
+ className: `${blockClass}__tile-dropdown`,
166
+ size: "sm",
167
+ titleText: "Label",
168
+ label: `Open in: ${name}'s sandbox`,
169
+ hideLabel: true,
170
+ type: "inline",
171
+ items: tileDropdownItems,
172
+ itemToString: item => item ? item['text'] : ''
173
+ })), /*#__PURE__*/React.createElement("div", {
174
+ className: `${blockClass}__tiles-container`
175
+ }, selectedTileGroup.tiles.map(tile => {
176
+ return /*#__PURE__*/React.createElement(BaseTile, {
177
+ key: tile.id,
178
+ id: tile.id,
179
+ open: open,
180
+ href: tile.href,
181
+ mainIcon: tile.mainIcon,
182
+ secondaryIcon: tile.secondaryIcon,
183
+ title: tile.title,
184
+ subtitle: tile.subtitle,
185
+ productName: productName
186
+ });
187
+ }))), /*#__PURE__*/React.createElement("div", {
188
+ className: `${blockClass}__button-collapse--gradient`
189
+ }), /*#__PURE__*/React.createElement("div", {
190
+ className: `${blockClass}__button-collapse--container`
191
+ }, headerAnimation && !isReduced && /*#__PURE__*/React.createElement(IconButton, {
192
+ className: `${blockClass}__icon-button`,
193
+ label: playing ? 'Pause' : 'Play',
194
+ kind: "ghost",
195
+ type: "button",
196
+ onClick: handleLottieAnimationClick
197
+ }, playing ? _PauseFilled || (_PauseFilled = /*#__PURE__*/React.createElement(PauseFilled, {
198
+ size: 16,
199
+ fill: `var(--cds-icon-secondary)`
200
+ })) : _PlayFilledAlt || (_PlayFilledAlt = /*#__PURE__*/React.createElement(PlayFilledAlt, {
201
+ size: 16,
202
+ fill: `var(--cds-icon-secondary)`
203
+ }))), /*#__PURE__*/React.createElement(Button, {
204
+ id: `${blockClass}__button-collapse`,
205
+ kind: "ghost",
206
+ renderIcon: open ? ChevronUp : ChevronDown,
207
+ onClick: handleButtonCollapseClick
208
+ }, open ? `Collapse` : `Expand`))));
209
+ };
210
+ AnimatedHeader.displayName = 'Animated Header';
211
+ AnimatedHeader.propTypes = {
212
+ /**
213
+ * Specify an optional className to be added to your Animated Header
214
+ */
215
+ className: PropTypes.string,
216
+ /**
217
+ * Specify the current username of active user
218
+ */
219
+ name: PropTypes.string,
220
+ /**
221
+ * Provide short sentence in max. 3 lines related to product context
222
+ */
223
+ description: PropTypes.string,
224
+ /**
225
+ * (optional), Provide content that needs highest attention from
226
+ * the user or content that triggers an action and allow users to
227
+ * directly start working and gain value (within one click)
228
+ */
229
+ buttonText: PropTypes.string,
230
+ /**
231
+ * Specify the carbon button type
232
+ */
233
+ buttonType: ButtonKinds,
234
+ /**
235
+ * (optional), Provide the renderIcon used in the button
236
+ * ex. Launch, Add, ect.
237
+ */
238
+ buttonIcon: PropTypes.any,
239
+ /**
240
+ * Header dropdown menu when button/buttonText is not in use
241
+ */
242
+ headerDropdown: PropTypes.bool,
243
+ /**
244
+ * Provide current product name
245
+ */
246
+ productName: PropTypes.string,
247
+ /**
248
+ * Object containing dropdown items
249
+ * `Open in: "_"`
250
+ */
251
+ tileDropdownItems: PropTypes.arrayOf(PropTypes.object),
252
+ /**
253
+ * The tile group that is active in the header
254
+ * ex. "AI Chat Tile w/ two glass tiles", "Four glass tiles", ect.
255
+ */
256
+ selectedTileGroup: PropTypes.object,
257
+ /**
258
+ * Provide function to be called when switching selected tile group
259
+ */
260
+ setSelectedTileGroup: PropTypes.func,
261
+ /**
262
+ * Array of each tile group setup
263
+ */
264
+ allTiles: PropTypes.arrayOf(PropTypes.object),
265
+ /**
266
+ * In-product imagery / lottie animation (.json) dim. 1312 x 738
267
+ * (to update headerAnimation content storybook requires remount in toolbar)
268
+ */
269
+ headerAnimation: PropTypes.object,
270
+ /**
271
+ * In-product imagery / static imagery dim. 1312 x 738
272
+ * Only active when headerAnimation is not in use
273
+ */
274
+ headerStatic: PropTypes.object
275
+ };
276
+
277
+ export { AnimatedHeader as default };
@@ -0,0 +1,20 @@
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
+ /** Primary UI component for user interaction */
11
+ interface AIPromptTileProps {
12
+ id?: string;
13
+ href?: string;
14
+ open?: boolean;
15
+ mainIcon?: string;
16
+ title?: string;
17
+ productName?: string;
18
+ }
19
+ export declare const AIPromptTile: React.FC<AIPromptTileProps>;
20
+ export {};
@@ -0,0 +1,94 @@
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
+ import React, { useState } from 'react';
9
+ import { AILabel, TextInput, IconButton, Button } from '@carbon/react';
10
+ import * as index from '../../../node_modules/@carbon/icons-react/es/index.js';
11
+ import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
12
+ import { Send } from '../../../node_modules/@carbon/icons-react/es/generated/bucket-14.js';
13
+
14
+ var _AILabel;
15
+
16
+ /** Primary UI component for user interaction */
17
+
18
+ const AIPromptTile = _ref => {
19
+ let {
20
+ id,
21
+ href,
22
+ open,
23
+ mainIcon,
24
+ title,
25
+ productName
26
+ } = _ref;
27
+ const prefix = usePrefix();
28
+ const blockClass = `${prefix}-animated-header__ai-prompt-tile`;
29
+ const collapsed = `${blockClass}--collapsed`;
30
+ const [textInput, setTextInput] = useState('');
31
+ const MainIcon = mainIcon ? index[mainIcon] : null;
32
+ const Send$1 = Send;
33
+ const handleTextInput = e => {
34
+ setTextInput(e.target.value);
35
+ };
36
+ const openInNewTab = url => {
37
+ const newWindow = window.open(url, '_blank', 'noopener,noreferrer');
38
+ if (newWindow) newWindow.opener = null;
39
+ };
40
+ const handleTextInputKeyDown = event => {
41
+ if (event.key === 'Enter') {
42
+ console.log('do validate');
43
+ openInNewTab(`${href}&primed_chat=${textInput}`);
44
+ }
45
+ };
46
+ return /*#__PURE__*/React.createElement("div", {
47
+ id: `${blockClass}`,
48
+ className: `${prefix}-animated-header__tile ${blockClass}`,
49
+ key: id
50
+ }, /*#__PURE__*/React.createElement("div", {
51
+ className: `${blockClass}--body ${!open && collapsed}`
52
+ }, /*#__PURE__*/React.createElement("div", {
53
+ className: `${blockClass}--icons`
54
+ }, MainIcon && /*#__PURE__*/React.createElement(MainIcon, {
55
+ fill: `var(--cds-icon-secondary)`,
56
+ size: 24
57
+ }), _AILabel || (_AILabel = /*#__PURE__*/React.createElement(AILabel, {
58
+ autoAlign: true,
59
+ aiText: "AI",
60
+ size: "mini"
61
+ }))), /*#__PURE__*/React.createElement("div", {
62
+ className: `${blockClass}--title`
63
+ }, title), /*#__PURE__*/React.createElement("div", {
64
+ className: `${blockClass}--text-input-container ${textInput && `${blockClass}--text-input-container__active`}`
65
+ }, /*#__PURE__*/React.createElement(TextInput, {
66
+ id: `${blockClass}--text-input`,
67
+ className: `${blockClass}--text-input`,
68
+ type: "text",
69
+ labelText: "AI Chat Input",
70
+ hideLabel: true,
71
+ placeholder: "Start chatting...",
72
+ size: "sm",
73
+ onChange: handleTextInput,
74
+ onKeyDown: handleTextInputKeyDown,
75
+ value: textInput
76
+ }), /*#__PURE__*/React.createElement(IconButton, {
77
+ className: `${blockClass}--icon-button ${textInput && `${blockClass}--icon-button__active`}`,
78
+ label: `Chat in ${productName}`,
79
+ kind: "ghost",
80
+ size: "sm",
81
+ disabled: !textInput,
82
+ align: "top-right",
83
+ onClick: () => openInNewTab(`${href}&primed_chat=${textInput}`),
84
+ onKeyDown: handleTextInputKeyDown
85
+ }, /*#__PURE__*/React.createElement(Send$1, null))), /*#__PURE__*/React.createElement("div", {
86
+ className: `${blockClass}--footer`
87
+ }, /*#__PURE__*/React.createElement(Button, {
88
+ kind: "ghost",
89
+ size: "sm",
90
+ href: href
91
+ }, "Open ", productName))));
92
+ };
93
+
94
+ export { AIPromptTile };
@@ -0,0 +1,22 @@
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
+ /** Base Tile */
11
+ interface BaseTileProps {
12
+ id?: string;
13
+ open?: boolean;
14
+ href?: string;
15
+ mainIcon?: string;
16
+ secondaryIcon?: string;
17
+ title?: string;
18
+ productName?: string;
19
+ subtitle?: string;
20
+ }
21
+ export declare const BaseTile: React.FC<BaseTileProps>;
22
+ export {};
@@ -0,0 +1,39 @@
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
+ import React from 'react';
9
+ import { AIPromptTile } from '../AIPromptTile/AIPromptTile.js';
10
+ import { GlassTile } from '../GlassTile/GlassTile.js';
11
+
12
+ /** Base Tile */
13
+
14
+ const BaseTile = _ref => {
15
+ let {
16
+ id,
17
+ open,
18
+ href,
19
+ mainIcon,
20
+ secondaryIcon,
21
+ title,
22
+ productName,
23
+ subtitle
24
+ } = _ref;
25
+ const props = {
26
+ id,
27
+ open,
28
+ href,
29
+ mainIcon,
30
+ secondaryIcon,
31
+ title,
32
+ productName,
33
+ subtitle
34
+ };
35
+ const tile = id === 'ai-tile' ? /*#__PURE__*/React.createElement(AIPromptTile, props) : /*#__PURE__*/React.createElement(GlassTile, props);
36
+ return tile;
37
+ };
38
+
39
+ export { BaseTile };
@@ -0,0 +1,21 @@
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
+ /** Primary UI component for user interaction */
11
+ interface GlassTileProps {
12
+ id?: string;
13
+ href?: string;
14
+ open?: boolean;
15
+ mainIcon?: string;
16
+ secondaryIcon?: string;
17
+ title?: string;
18
+ subtitle?: string;
19
+ }
20
+ export declare const GlassTile: React.FC<GlassTileProps>;
21
+ export {};
@@ -0,0 +1,53 @@
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
+ import React from 'react';
9
+ import { Link } from '@carbon/react';
10
+ import * as index from '../../../node_modules/@carbon/icons-react/es/index.js';
11
+ import { usePrefix } from '../../../node_modules/@carbon-labs/utilities/es/usePrefix.js';
12
+
13
+ /** Primary UI component for user interaction */
14
+
15
+ const GlassTile = _ref => {
16
+ let {
17
+ id,
18
+ href,
19
+ open,
20
+ mainIcon,
21
+ secondaryIcon,
22
+ title,
23
+ subtitle
24
+ } = _ref;
25
+ const prefix = usePrefix();
26
+ const blockClass = `${prefix}-animated-header__glass-tile`;
27
+ const collapsed = `${blockClass}--collapsed`;
28
+ const MainIcon = mainIcon ? index[mainIcon] : null;
29
+ const SecondaryIcon = secondaryIcon ? index[secondaryIcon] : null;
30
+ return /*#__PURE__*/React.createElement(Link, {
31
+ className: `${prefix}-animated-header__tile ${blockClass}`,
32
+ key: id,
33
+ href: href
34
+ }, /*#__PURE__*/React.createElement("div", {
35
+ className: `${blockClass}--body ${!open && collapsed}`
36
+ }, /*#__PURE__*/React.createElement("div", {
37
+ className: `${blockClass}--icons`
38
+ }, MainIcon && /*#__PURE__*/React.createElement(MainIcon, {
39
+ fill: `var(--cds-icon-secondary)`,
40
+ size: 24
41
+ })), /*#__PURE__*/React.createElement("div", {
42
+ className: `${blockClass}--title`
43
+ }, title), /*#__PURE__*/React.createElement("div", {
44
+ className: `${blockClass}--footer`
45
+ }, subtitle && /*#__PURE__*/React.createElement("div", {
46
+ className: `${blockClass}--subtitle`
47
+ }, subtitle), SecondaryIcon && /*#__PURE__*/React.createElement(SecondaryIcon, {
48
+ size: 16,
49
+ fill: `var(--cds-icon-secondary)`
50
+ }))));
51
+ };
52
+
53
+ export { GlassTile };
@@ -0,0 +1,12 @@
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 { AIPromptTile } from './AIPromptTile/AIPromptTile';
10
+ import { BaseTile } from './BaseTile/BaseTile';
11
+ import { GlassTile } from './GlassTile/GlassTile';
12
+ export { AIPromptTile, BaseTile, GlassTile };
@@ -0,0 +1,47 @@
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
+ export const tileDropdownData: {
10
+ id: string;
11
+ text: string;
12
+ }[];
13
+ export const headerTiles: ({
14
+ id: number;
15
+ name: string;
16
+ tiles: ({
17
+ id: string;
18
+ href: string;
19
+ title: string;
20
+ mainIcon: string;
21
+ subtitle?: undefined;
22
+ } | {
23
+ id: string;
24
+ href: string;
25
+ title: string;
26
+ subtitle: string;
27
+ mainIcon: string;
28
+ })[];
29
+ } | {
30
+ id: number;
31
+ name: string;
32
+ tiles: ({
33
+ id: string;
34
+ href: string;
35
+ title: string;
36
+ subtitle: string;
37
+ mainIcon: string;
38
+ secondaryIcon?: undefined;
39
+ } | {
40
+ id: string;
41
+ href: string;
42
+ title: string;
43
+ mainIcon: string;
44
+ secondaryIcon: string;
45
+ subtitle?: undefined;
46
+ })[];
47
+ })[];
package/es/index.d.ts ADDED
@@ -0,0 +1,11 @@
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 AnimatedHeader from '../AnimatedHeader/components/AnimatedHeader/AnimatedHeader';
10
+ import { BaseTile } from './components/Tiles/index.js';
11
+ export { AnimatedHeader, BaseTile };