@widergy/energy-ui 3.161.0 → 3.162.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.
@@ -0,0 +1,148 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getSecondaryLabelColorTheme = exports.getLabelStyles = exports.getLabelColorTheme = exports.getDefaultIconTheme = exports.getDefaultIconSize = exports.getDefaultButtonColorTheme = void 0;
7
+ var _constants = require("./constants");
8
+ /**
9
+ * Returns the default UTIcon colorTheme and shade for the banner icon based on the
10
+ * banner's colorTheme and variant. Matches the mobile implementation.
11
+ * @param {string} colorTheme - Banner color theme.
12
+ * @param {string} variant - Banner variant ('light' | 'dark').
13
+ * @returns {{ colorTheme: string, shade: string }}
14
+ */
15
+ const getDefaultIconTheme = (colorTheme, variant) => {
16
+ var _COLOR_THEMES$ERROR$C;
17
+ if (variant === _constants.VARIANTS.DARK) {
18
+ return colorTheme === _constants.COLOR_THEMES.NEGATIVE ? {
19
+ colorTheme: 'dark',
20
+ shade: '05'
21
+ } : {
22
+ colorTheme: 'light',
23
+ shade: '01'
24
+ };
25
+ }
26
+ return (_COLOR_THEMES$ERROR$C = {
27
+ [_constants.COLOR_THEMES.ERROR]: {
28
+ colorTheme: 'error',
29
+ shade: '04'
30
+ },
31
+ [_constants.COLOR_THEMES.GRAY]: {
32
+ colorTheme: 'accent',
33
+ shade: '04'
34
+ },
35
+ [_constants.COLOR_THEMES.INFORMATION]: {
36
+ colorTheme: 'information',
37
+ shade: '04'
38
+ },
39
+ [_constants.COLOR_THEMES.NEGATIVE]: {
40
+ colorTheme: 'light',
41
+ shade: '01'
42
+ },
43
+ [_constants.COLOR_THEMES.PRIMARY]: {
44
+ colorTheme: 'accent',
45
+ shade: '04'
46
+ },
47
+ [_constants.COLOR_THEMES.SUCCESS]: {
48
+ colorTheme: 'success',
49
+ shade: '04'
50
+ },
51
+ [_constants.COLOR_THEMES.WARNING]: {
52
+ colorTheme: 'warning',
53
+ shade: '04'
54
+ },
55
+ [_constants.COLOR_THEMES.WHITE]: {
56
+ colorTheme: 'accent',
57
+ shade: '04'
58
+ }
59
+ }[colorTheme]) !== null && _COLOR_THEMES$ERROR$C !== void 0 ? _COLOR_THEMES$ERROR$C : {
60
+ colorTheme: 'accent',
61
+ shade: '04'
62
+ };
63
+ };
64
+
65
+ /**
66
+ * Returns the default icon size in pixels based on the banner size.
67
+ * @param {string} size - One of SIZES values.
68
+ * @returns {number}
69
+ */
70
+ exports.getDefaultIconTheme = getDefaultIconTheme;
71
+ const getDefaultIconSize = size => size === _constants.SIZES.LARGE ? 24 : 20;
72
+
73
+ /**
74
+ * Returns the default colorTheme for buttons and the close button based on the
75
+ * banner variant. Dark variant uses 'negative'; light variant uses standard colors.
76
+ * @param {string} variant - Banner variant ('light' | 'dark').
77
+ * @returns {{ button: string, onClose: string, secondaryButton: string }}
78
+ */
79
+ exports.getDefaultIconSize = getDefaultIconSize;
80
+ const getDefaultButtonColorTheme = variant => {
81
+ const isDark = variant === _constants.VARIANTS.DARK;
82
+ return {
83
+ button: isDark ? 'negative' : 'secondary',
84
+ onClose: isDark ? 'negative' : 'gray',
85
+ secondaryButton: isDark ? 'negative' : 'secondary'
86
+ };
87
+ };
88
+
89
+ /**
90
+ * Returns the UTLabel variant and weight for the main text (children) based on
91
+ * the banner size.
92
+ * @param {string} size - One of SIZES values.
93
+ * @returns {{ variant: string, weight: string }}
94
+ */
95
+ exports.getDefaultButtonColorTheme = getDefaultButtonColorTheme;
96
+ const getLabelStyles = size => {
97
+ var _SIZES$LARGE$SIZES$ME;
98
+ return (_SIZES$LARGE$SIZES$ME = {
99
+ [_constants.SIZES.LARGE]: {
100
+ titleVariant: 'title3',
101
+ descriptionVariant: 'body'
102
+ },
103
+ [_constants.SIZES.MEDIUM]: {
104
+ titleVariant: 'subtitle1',
105
+ descriptionVariant: 'small'
106
+ },
107
+ [_constants.SIZES.SMALL]: {
108
+ titleVariant: 'small',
109
+ descriptionVariant: 'small'
110
+ }
111
+ }[size]) !== null && _SIZES$LARGE$SIZES$ME !== void 0 ? _SIZES$LARGE$SIZES$ME : {
112
+ titleVariant: 'small',
113
+ descriptionVariant: 'small'
114
+ };
115
+ };
116
+
117
+ /**
118
+ * Returns the UTLabel colorTheme for the banner's main text content based on the
119
+ * banner's colorTheme and variant. Negative+light and any dark variant use light
120
+ * (white) text; all other combinations use dark text.
121
+ * @param {string} colorTheme - Banner color theme.
122
+ * @param {string} variant - Banner variant ('light' | 'dark').
123
+ * @returns {string} UTLabel colorTheme value.
124
+ */
125
+ exports.getLabelStyles = getLabelStyles;
126
+ const getLabelColorTheme = (colorTheme, variant) => {
127
+ if (colorTheme === _constants.COLOR_THEMES.NEGATIVE) {
128
+ return variant === _constants.VARIANTS.LIGHT ? 'light' : 'dark';
129
+ }
130
+ return variant === _constants.VARIANTS.LIGHT ? 'dark' : 'light';
131
+ };
132
+
133
+ /**
134
+ * Returns the UTLabel colorTheme for the banner's secondary text content based on the
135
+ * banner's colorTheme and variant. Negative+light and any dark variant use light
136
+ * (white) text; all other combinations use gray text.
137
+ * @param {string} colorTheme - Banner color theme.
138
+ * @param {string} variant - Banner variant ('light' | 'gray').
139
+ * @returns {string} UTLabel colorTheme value.
140
+ */
141
+ exports.getLabelColorTheme = getLabelColorTheme;
142
+ const getSecondaryLabelColorTheme = (colorTheme, variant) => {
143
+ if (colorTheme === _constants.COLOR_THEMES.NEGATIVE) {
144
+ return variant === _constants.VARIANTS.LIGHT ? 'light' : 'gray';
145
+ }
146
+ return variant === _constants.VARIANTS.LIGHT ? 'gray' : 'light';
147
+ };
148
+ exports.getSecondaryLabelColorTheme = getSecondaryLabelColorTheme;
@@ -176,7 +176,7 @@ const UTGraph = _ref => {
176
176
  crossAxisLeft,
177
177
  crossAxisRight
178
178
  } = _ref2;
179
- return /*#__PURE__*/_react.default.createElement(_react.Fragment, null, /*#__PURE__*/_react.default.createElement(_Bars.default, {
179
+ return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement(_Bars.default, {
180
180
  crossAxisLeft: crossAxisLeft,
181
181
  crossAxisRight: crossAxisRight,
182
182
  dataset: dataset,
@@ -154,8 +154,9 @@ const UTHeader = _ref => {
154
154
  height: BANNER_ICON_SIZE,
155
155
  width: BANNER_ICON_SIZE
156
156
  },
157
- Icon: banner.Icon
158
- }, banner.text)));
157
+ Icon: banner.Icon,
158
+ title: banner.text
159
+ })));
159
160
  };
160
161
  UTHeader.propTypes = {
161
162
  actions: (0, _propTypes.arrayOf)(_propTypes.object),
@@ -53,6 +53,7 @@ const ID_CONSTANTS = exports.ID_CONSTANTS = {
53
53
  PINNED: 'pinned',
54
54
  POPPER: 'popper',
55
55
  SEARCH_BUTTON: 'searchButton',
56
+ SECONDARY_ACTION: 'secondaryAction',
56
57
  SEARCH_BUTTON_TOOLTIP: 'searchButtonTooltip',
57
58
  SEARCH_FIELD: 'searchField',
58
59
  SELECTION_COMPONENT: 'selectionComponent',
@@ -60,6 +61,7 @@ const ID_CONSTANTS = exports.ID_CONSTANTS = {
60
61
  SIDEBAR_BUTTON: 'sidebarButton',
61
62
  STATUS_MESSAGE: 'statusMessage',
62
63
  TABLE: 'table',
64
+ TERTIARY_ACTION: 'tertiaryAction',
63
65
  TABLE_ROW: 'tableRow',
64
66
  TITLE: 'title',
65
67
  USER_FILTER: 'userFilter',
@@ -2,14 +2,47 @@
2
2
 
3
3
  ### Description
4
4
 
5
- This component displays a banner with information
5
+ Displays a banner with contextual information. Supports multiple color themes, sizes, icon/button placement, and optional close action.
6
6
 
7
7
  ## Props
8
8
 
9
- | Name | Type | Default | Description |
10
- | ---------- | ---------------- | ------- | --------------------------------------------------------------------------- |
11
- | children | element | | The contents that will be rendered inside the component. |
12
- | classes | object of string | | Classes returned by UTBanner's own [theme](./theme.js#L40) `retrieveStyle`. |
13
- | classNames | object of string | | Additional classes. |
14
- | Icon | element | | Icon to be displayed at the left side of the banner. |
15
- | iconProps | object | | Props to be passed onto the rendered icon. |
9
+ | Name | Type | Default | Description |
10
+ | ----------------- | --------------------------------------------------------------------------------- | -------------- | --------------------------------------------------------------------------- |
11
+ | button | object (UTButton props) | | Primary action button. All UTButton props are accepted. |
12
+ | buttonPlacement | `'horizontal'` \| `'vertical'` | `'horizontal'` | Alignment between the text group and the buttons group. |
13
+ | category | string | | Optional category label shown above the main text (xsmall, uppercase, gray). |
14
+ | children | node | | Main text content rendered inside the banner. |
15
+ | classes | object of string | | Classes returned by UTBanner's own [theme](./theme.js) `retrieveStyle`. |
16
+ | classNames | object of string | | Additional classes merged with the themed classes. |
17
+ | colorTheme | `'error'` \| `'gray'` \| `'information'` \| `'negative'` \| `'primary'` \| `'success'` \| `'warning'` \| `'white'` | `'gray'` | Color theme that determines the banner background. |
18
+ | helpText | string | | Optional secondary text shown below the main content (small, gray). |
19
+ | Icon | element type | | Icon component rendered at the start of the banner. |
20
+ | iconPlacement | `'horizontal'` \| `'vertical'` | `'horizontal'` | Alignment between the icon and the text group. |
21
+ | iconProps | object | | Props passed to the `Icon` component. |
22
+ | onClose | func | | If provided, renders a close button (gray, small, IconX) at the end. |
23
+ | secondaryButton | object (UTButton props) | | Secondary action button. Renders as `variant="text"` by default. |
24
+ | size | `'small'` \| `'medium'` \| `'large'` | `'medium'` | Controls padding, gap, and icon size. |
25
+ | variant | `'light'` \| `'dark'` | `'light'` | Light or dark tint of the color theme. |
26
+
27
+ ## Usage examples
28
+
29
+ ```jsx
30
+ // Basic
31
+ <UTBanner>Your account has been updated.</UTBanner>
32
+
33
+ // With color theme and close
34
+ <UTBanner colorTheme="success" onClose={() => dismiss()}>
35
+ Your changes were saved successfully.
36
+ </UTBanner>
37
+
38
+ // With category, helpText and actions
39
+ <UTBanner
40
+ category="Alert"
41
+ colorTheme="warning"
42
+ helpText="Contact support if the issue persists."
43
+ button={{ children: 'Retry', onClick: handleRetry }}
44
+ secondaryButton={{ children: 'Dismiss', onClick: handleDismiss }}
45
+ >
46
+ Something went wrong while loading your data.
47
+ </UTBanner>
48
+ ```
@@ -0,0 +1,30 @@
1
+ export const SIZES = {
2
+ SMALL: 'small',
3
+ MEDIUM: 'medium',
4
+ LARGE: 'large'
5
+ };
6
+ export const COLOR_THEMES = {
7
+ ERROR: 'error',
8
+ GRAY: 'gray',
9
+ INFORMATION: 'information',
10
+ NEGATIVE: 'negative',
11
+ PRIMARY: 'primary',
12
+ SUCCESS: 'success',
13
+ WARNING: 'warning',
14
+ WHITE: 'white'
15
+ };
16
+ export const VARIANTS = {
17
+ DARK: 'dark',
18
+ LIGHT: 'light'
19
+ };
20
+ export const PLACEMENTS = {
21
+ HORIZONTAL: 'horizontal',
22
+ VERTICAL: 'vertical'
23
+ };
24
+ export const DEFAULT_PROPS = {
25
+ buttonPlacement: PLACEMENTS.HORIZONTAL,
26
+ colorTheme: COLOR_THEMES.GRAY,
27
+ iconPlacement: PLACEMENTS.HORIZONTAL,
28
+ size: SIZES.MEDIUM,
29
+ variant: VARIANTS.LIGHT
30
+ };
@@ -1,29 +1,133 @@
1
- import React, { useMemo } from 'react';
2
- import { object, objectOf, string } from 'prop-types';
1
+ function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
+ import React from 'react';
3
+ import { elementType, func, object, objectOf, oneOf, oneOfType, string } from 'prop-types';
4
+ import UTButton from '../UTButton';
5
+ import UTIcon from '../UTIcon';
3
6
  import UTLabel from '../UTLabel';
4
- import { mergeClasses } from '../../utils/classesUtils';
5
- import WithTheme from '../WithTheme';
7
+ import { capitalize, isUTIcon } from '../../utils/componentUtils';
8
+ import { mergeMultipleClassNames } from '../../utils/classesUtils';
9
+ import { ID_CONSTANTS } from '../../constants/testIds';
6
10
  import styles from './styles.module.scss';
7
- import { retrieveStyle } from './theme';
11
+ import { buttonType } from './types';
12
+ import { getDefaultButtonColorTheme, getDefaultIconSize, getDefaultIconTheme, getLabelColorTheme, getLabelStyles, getSecondaryLabelColorTheme } from './utils';
13
+ import { COLOR_THEMES, DEFAULT_PROPS, PLACEMENTS, SIZES, VARIANTS } from './constants';
8
14
  const UTBanner = _ref => {
9
15
  let {
10
- classes: themeClasses = {},
16
+ button,
17
+ buttonPlacement = DEFAULT_PROPS.buttonPlacement,
18
+ category,
11
19
  classNames,
12
- children,
20
+ colorTheme = DEFAULT_PROPS.colorTheme,
21
+ dataTestId,
22
+ description,
23
+ helpText,
24
+ Icon,
25
+ iconPlacement = DEFAULT_PROPS.iconPlacement,
13
26
  iconProps,
14
- Icon
27
+ onClose,
28
+ secondaryButton,
29
+ size = DEFAULT_PROPS.size,
30
+ title,
31
+ variant = DEFAULT_PROPS.variant
15
32
  } = _ref;
16
- const classes = useMemo(() => mergeClasses(themeClasses, classNames), [classNames]);
33
+ const isVerticalButton = buttonPlacement === PLACEMENTS.VERTICAL;
34
+ const isVerticalIcon = iconPlacement === PLACEMENTS.VERTICAL;
35
+ const labelColorTheme = getLabelColorTheme(colorTheme, variant);
36
+ const secondaryLabelColorTheme = getSecondaryLabelColorTheme(colorTheme, variant);
37
+ const {
38
+ titleVariant,
39
+ descriptionVariant
40
+ } = getLabelStyles(size);
41
+ const iconTheme = getDefaultIconTheme(colorTheme, variant);
42
+ const iconSize = getDefaultIconSize(size);
43
+ const buttonColorTheme = getDefaultButtonColorTheme(variant);
44
+ const gapClass = styles["gap".concat(capitalize(size))];
45
+ const paddingClass = styles["padding".concat(capitalize(size))];
46
+ const colorClass = styles["".concat(colorTheme).concat(capitalize(variant))];
47
+ const dynamicClasses = {
48
+ bannerContainer: [colorClass, paddingClass, gapClass].filter(Boolean).join(' '),
49
+ contentContainer: [isVerticalButton ? styles.contentVertical : styles.contentHorizontal, gapClass].filter(Boolean).join(' '),
50
+ iconTextContainer: [isVerticalIcon ? styles.iconVertical : styles.iconHorizontal, !isVerticalButton ? styles.iconFlex : ''].filter(Boolean).join(' '),
51
+ textContainer: !isVerticalIcon ? styles.textFlex : '',
52
+ buttonsContainer: isVerticalButton ? styles.buttonsVertical : ''
53
+ };
54
+ const normalizedClassNames = classNames ? {
55
+ ...classNames,
56
+ bannerContainer: classNames.infoContainer
57
+ } : undefined;
58
+ const classes = mergeMultipleClassNames(styles, dynamicClasses, normalizedClassNames);
17
59
  return /*#__PURE__*/React.createElement("div", {
18
- className: "".concat(styles.bannerContainer, " ").concat(classes.infoContainer)
19
- }, Icon && /*#__PURE__*/React.createElement(Icon, iconProps), /*#__PURE__*/React.createElement(UTLabel, {
60
+ className: classes.bannerContainer,
61
+ "data-testid": dataTestId
62
+ }, /*#__PURE__*/React.createElement("div", {
63
+ className: classes.contentContainer
64
+ }, /*#__PURE__*/React.createElement("div", {
65
+ className: classes.iconTextContainer
66
+ }, !!Icon && isUTIcon(Icon) ? /*#__PURE__*/React.createElement(UTIcon, _extends({
67
+ colorTheme: iconTheme.colorTheme,
68
+ dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.ICON) : undefined,
69
+ name: Icon,
70
+ shade: iconTheme.shade,
71
+ size: iconSize
72
+ }, iconProps)) : !!Icon && /*#__PURE__*/React.createElement(Icon, _extends({}, iconProps, {
73
+ "data-testId": dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.ICON) : undefined
74
+ })), /*#__PURE__*/React.createElement("div", {
75
+ className: classes.textContainer
76
+ }, !!category && /*#__PURE__*/React.createElement(UTLabel, {
77
+ className: styles.uppercase,
78
+ colorTheme: secondaryLabelColorTheme,
79
+ dataTestId: dataTestId ? "".concat(dataTestId, ".category.").concat(ID_CONSTANTS.LABEL) : undefined,
80
+ variant: "xsmall",
81
+ weight: "medium"
82
+ }, category), !!title && /*#__PURE__*/React.createElement(UTLabel, {
83
+ colorTheme: labelColorTheme,
84
+ dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.TITLE, ".").concat(ID_CONSTANTS.LABEL) : undefined,
85
+ variant: titleVariant,
86
+ weight: "medium"
87
+ }, title), !!description && /*#__PURE__*/React.createElement(UTLabel, {
88
+ colorTheme: labelColorTheme,
89
+ dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.DESCRIPTION, ".").concat(ID_CONSTANTS.LABEL) : undefined,
90
+ variant: descriptionVariant
91
+ }, description), !!helpText && /*#__PURE__*/React.createElement(UTLabel, {
92
+ colorTheme: secondaryLabelColorTheme,
93
+ dataTestId: dataTestId ? "".concat(dataTestId, ".").concat(ID_CONSTANTS.HELP_TEXT, ".").concat(ID_CONSTANTS.LABEL) : undefined,
20
94
  variant: "small"
21
- }, children));
95
+ }, helpText))), !!(button || secondaryButton) && /*#__PURE__*/React.createElement("div", {
96
+ className: classes.buttonsContainer
97
+ }, !!button && /*#__PURE__*/React.createElement(UTButton, _extends({
98
+ colorTheme: buttonColorTheme.button
99
+ }, button, {
100
+ dataTestId: dataTestId ? "".concat(dataTestId, ".button.").concat(ID_CONSTANTS.SECONDARY_ACTION) : undefined
101
+ }), button.title), !!secondaryButton && /*#__PURE__*/React.createElement(UTButton, _extends({
102
+ colorTheme: buttonColorTheme.secondaryButton,
103
+ variant: "text"
104
+ }, secondaryButton, {
105
+ dataTestId: dataTestId ? "".concat(dataTestId, ".secondaryButton.").concat(ID_CONSTANTS.TERTIARY_ACTION) : undefined
106
+ }), secondaryButton.title))), !!onClose && /*#__PURE__*/React.createElement(UTButton, {
107
+ colorTheme: buttonColorTheme.onClose,
108
+ dataTestId: dataTestId ? "".concat(dataTestId, ".close") : undefined,
109
+ Icon: "IconX",
110
+ onClick: onClose,
111
+ size: "small",
112
+ variant: "text"
113
+ }));
22
114
  };
23
115
  UTBanner.propTypes = {
24
- classes: objectOf(string),
116
+ button: buttonType,
117
+ buttonPlacement: oneOf(Object.values(PLACEMENTS)),
118
+ category: string,
25
119
  classNames: objectOf(string),
26
- Icon: object,
27
- iconProps: object
120
+ colorTheme: oneOf(Object.values(COLOR_THEMES)),
121
+ dataTestId: string,
122
+ description: string,
123
+ helpText: string,
124
+ Icon: oneOfType([elementType, string]),
125
+ iconPlacement: oneOf(Object.values(PLACEMENTS)),
126
+ iconProps: object,
127
+ onClose: func,
128
+ secondaryButton: buttonType,
129
+ size: oneOf(Object.values(SIZES)),
130
+ title: string,
131
+ variant: oneOf(Object.values(VARIANTS))
28
132
  };
29
- export default WithTheme(retrieveStyle)(UTBanner);
133
+ export default UTBanner;
@@ -0,0 +1,157 @@
1
+ /* eslint-disable no-alert */
2
+ import UTBanner from '..';
3
+ import { COLOR_THEMES, PLACEMENTS, SIZES, VARIANTS } from '../constants';
4
+ export default {
5
+ args: {
6
+ buttonPlacement: PLACEMENTS.HORIZONTAL,
7
+ colorTheme: COLOR_THEMES.GRAY,
8
+ iconPlacement: PLACEMENTS.HORIZONTAL,
9
+ size: SIZES.MEDIUM,
10
+ title: 'Your account information has been updated successfully.',
11
+ variant: VARIANTS.LIGHT
12
+ },
13
+ argTypes: {
14
+ button: {
15
+ control: 'object',
16
+ description: 'Primary action button. Accepts all UTButton props.',
17
+ table: {
18
+ type: {
19
+ summary: 'object'
20
+ }
21
+ }
22
+ },
23
+ buttonPlacement: {
24
+ control: {
25
+ type: 'select'
26
+ },
27
+ options: Object.values(PLACEMENTS)
28
+ },
29
+ category: {
30
+ control: 'text',
31
+ description: 'Optional category label shown above the title (xsmall, uppercase, gray).'
32
+ },
33
+ colorTheme: {
34
+ control: {
35
+ type: 'select'
36
+ },
37
+ options: Object.values(COLOR_THEMES)
38
+ },
39
+ description: {
40
+ control: 'text',
41
+ description: 'Optional body text shown below the title (small).'
42
+ },
43
+ helpText: {
44
+ control: 'text',
45
+ description: 'Optional secondary text shown below the description (small, gray).'
46
+ },
47
+ iconPlacement: {
48
+ control: {
49
+ type: 'select'
50
+ },
51
+ options: Object.values(PLACEMENTS)
52
+ },
53
+ Icon: {
54
+ control: 'text',
55
+ description: 'Nombre del ícono (string) o componente React. Ej: "IconAlertCircle".'
56
+ },
57
+ iconProps: {
58
+ control: false
59
+ },
60
+ onClose: {
61
+ control: false
62
+ },
63
+ secondaryButton: {
64
+ control: 'object',
65
+ description: 'Secondary action button. Renders as variant="text" by default.'
66
+ },
67
+ size: {
68
+ control: {
69
+ type: 'select'
70
+ },
71
+ options: Object.values(SIZES)
72
+ },
73
+ title: {
74
+ control: 'text',
75
+ description: 'Main text of the banner.'
76
+ },
77
+ variant: {
78
+ control: {
79
+ type: 'select'
80
+ },
81
+ options: Object.values(VARIANTS)
82
+ }
83
+ },
84
+ component: UTBanner,
85
+ title: 'Energy-UI/UTBanner'
86
+ };
87
+ export const Playground = {};
88
+ export const WithClose = {
89
+ args: {
90
+ colorTheme: COLOR_THEMES.WARNING,
91
+ onClose: () => alert('closed'),
92
+ title: 'Session will expire in 5 minutes.'
93
+ },
94
+ name: 'With Close Button'
95
+ };
96
+ export const WithActions = {
97
+ args: {
98
+ button: {
99
+ title: 'Retry',
100
+ onClick: () => alert('retry')
101
+ },
102
+ colorTheme: COLOR_THEMES.ERROR,
103
+ secondaryButton: {
104
+ title: 'Dismiss',
105
+ onClick: () => alert('dismiss')
106
+ },
107
+ title: 'Something went wrong while loading your data.'
108
+ },
109
+ name: 'With Actions'
110
+ };
111
+ export const WithCategoryAndHelpText = {
112
+ args: {
113
+ category: 'Notice',
114
+ colorTheme: COLOR_THEMES.INFORMATION,
115
+ helpText: 'Contact billing if you have any questions.',
116
+ title: 'Your invoice is due in 3 days.'
117
+ },
118
+ name: 'With Category and Help Text'
119
+ };
120
+ export const WithDescription = {
121
+ args: {
122
+ colorTheme: COLOR_THEMES.INFORMATION,
123
+ description: 'This action cannot be undone. All associated data will be permanently removed.',
124
+ title: 'Are you sure you want to delete this account?'
125
+ },
126
+ name: 'With Description'
127
+ };
128
+ export const VerticalLayout = {
129
+ args: {
130
+ button: {
131
+ title: 'View Details',
132
+ onClick: () => alert('details')
133
+ },
134
+ buttonPlacement: PLACEMENTS.VERTICAL,
135
+ category: 'Update',
136
+ colorTheme: COLOR_THEMES.PRIMARY,
137
+ description: 'This update includes performance improvements and bug fixes.',
138
+ helpText: 'Restart the app to apply changes.',
139
+ iconPlacement: PLACEMENTS.VERTICAL,
140
+ secondaryButton: {
141
+ title: 'Later',
142
+ onClick: () => alert('later')
143
+ },
144
+ size: SIZES.LARGE,
145
+ title: 'A new version is available.'
146
+ },
147
+ name: 'Vertical Layout'
148
+ };
149
+ export const DarkVariant = {
150
+ args: {
151
+ colorTheme: COLOR_THEMES.NEGATIVE,
152
+ onClose: () => alert('closed'),
153
+ title: 'Critical maintenance scheduled for tonight.',
154
+ variant: VARIANTS.DARK
155
+ },
156
+ name: 'Dark Variant'
157
+ };