@widergy/mobile-ui 2.16.0 → 2.17.1
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/CHANGELOG.md +18 -3
- package/lib/components/UTBanner/README.md +124 -11
- package/lib/components/UTBanner/constants.js +5 -0
- package/lib/components/UTBanner/index.js +119 -52
- package/lib/components/UTBanner/proptypes.js +36 -13
- package/lib/components/UTBanner/theme.js +137 -11
- package/lib/components/UTBottomSheet/index.js +35 -32
- package/lib/components/UTBottomSheet/styles.js +4 -3
- package/lib/components/UTDatePicker/README.md +73 -0
- package/lib/components/UTDatePicker/components/Calendar/constants.js +3 -0
- package/lib/components/UTDatePicker/components/Calendar/index.js +197 -0
- package/lib/components/UTDatePicker/components/Day/index.js +44 -0
- package/lib/components/UTDatePicker/components/Day/styles.js +8 -0
- package/lib/components/UTDatePicker/components/PickerColumn/index.js +57 -0
- package/lib/components/UTDatePicker/constants.js +48 -0
- package/lib/components/UTDatePicker/index.js +135 -0
- package/lib/components/UTDatePicker/layout.js +108 -0
- package/lib/components/UTDatePicker/proptypes.js +20 -0
- package/lib/components/UTDatePicker/styles.js +63 -0
- package/lib/components/UTDatePicker/theme.js +18 -0
- package/lib/components/UTDatePicker/utils.js +52 -0
- package/lib/constants/testIds.js +13 -0
- package/lib/index.js +1 -0
- package/package.json +5 -4
package/CHANGELOG.md
CHANGED
|
@@ -1,9 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
## [2.17.1](https://github.com/widergy/mobile-ui/compare/v2.17.0...v2.17.1) (2026-06-05)
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
###
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* [DIS-1103] ut date picker ([#507](https://github.com/widergy/mobile-ui/issues/507)) ([ffd6db3](https://github.com/widergy/mobile-ui/commit/ffd6db3c847dca170a5df955c1149a880c7f42cb))
|
|
7
|
+
|
|
8
|
+
# [2.17.0](https://github.com/widergy/mobile-ui/compare/v2.16.0...v2.17.0) (2026-06-03)
|
|
9
|
+
|
|
10
|
+
### Novedades y Mejoras
|
|
11
|
+
|
|
12
|
+
* Se amplió el componente de banner con nuevas opciones de presentación: categoría encima del título, texto de ayuda debajo de la descripción, disposición del ícono y los botones en fila o columna, un segundo botón opcional y la posibilidad de cerrarlo desde una esquina. [#505](https://github.com/widergy/Energy-UI-Mobile/pull/505) [DIS-1102](https://widergy.atlassian.net/browse/DIS-1102)
|
|
13
|
+
|
|
14
|
+
# [2.16.0](https://github.com/widergy/mobile-ui/compare/v2.15.0...v2.16.0) (2026-05-15)
|
|
15
|
+
|
|
16
|
+
### Novedades y Mejoras
|
|
5
17
|
|
|
6
|
-
*
|
|
18
|
+
* Se renovaron los íconos de tarjetas de crédito en la aplicación. [#504](https://github.com/widergy/Energy-UI-Mobile/pull/504) [CX-2232](https://widergy.atlassian.net/browse/CX-2232)
|
|
19
|
+
* Se actualizaron los estilos visuales de los botones y grupos de botones. [#503](https://github.com/widergy/Energy-UI-Mobile/pull/503)
|
|
20
|
+
* Se amplió la tarjeta de acciones rápidas para mostrar estados informativos, ajustar el tamaño de los botones y controlar la apariencia visual del pie de tarjeta. [#501](https://github.com/widergy/Energy-UI-Mobile/pull/501)
|
|
21
|
+
* Mejoras internas de la plataforma. [#500](https://github.com/widergy/Energy-UI-Mobile/pull/500) [#502](https://github.com/widergy/Energy-UI-Mobile/pull/502) [DEV-794](https://widergy.atlassian.net/browse/DEV-794)
|
|
7
22
|
|
|
8
23
|
# [2.15.0](https://github.com/widergy/mobile-ui/compare/v2.14.0...v2.15.0) (2026-05-11)
|
|
9
24
|
|
|
@@ -1,19 +1,132 @@
|
|
|
1
1
|
# UTBanner
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
## Descripción
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
Componente de notificación/alerta que muestra información contextual con soporte para ícono, textos estructurados, botones de acción y botón de cierre. Soporta múltiples combinaciones de layout mediante las props `iconPlacement` y `buttonPlacement`.
|
|
6
6
|
|
|
7
7
|
## Props
|
|
8
8
|
|
|
9
|
-
|
|
|
10
|
-
|
|
|
11
|
-
|
|
|
12
|
-
|
|
|
13
|
-
|
|
|
9
|
+
| Nombre | Tipo | Default | Descripción |
|
|
10
|
+
| ---------------- | ---------- | -------------- | ----------- |
|
|
11
|
+
| `button` | `ButtonShape` | | Configuración del botón de acción principal. Acepta todas las props de `UTButton` más `title` (string) como texto del botón. |
|
|
12
|
+
| `buttonPlacement`| `string` | `'horizontal'` | Dirección del eje entre el grupo de textos y el grupo de botones. `'horizontal'` los ubica lado a lado, `'vertical'` los apila. |
|
|
13
|
+
| `category` | `string` | | Etiqueta pequeña que se muestra sobre el título (ej: `"2 ALERTAS EN TOTAL"`). |
|
|
14
|
+
| `colorTheme` | `string` | `'white'` | Color de fondo del banner. Ver sección de variantes. |
|
|
15
|
+
| `dataTestId` | `string` | | ID base para pruebas. Se propaga con sufijos a los elementos internos. |
|
|
16
|
+
| `description` | `string` | | Texto descriptivo debajo del título. |
|
|
17
|
+
| `helpText` | `string` | | Texto de ayuda secundario, se muestra debajo de la descripción. |
|
|
18
|
+
| `icon` | `IconShape` | | Ícono a mostrar. Acepta `name` (string) y `colorTheme` (string). |
|
|
19
|
+
| `iconPlacement` | `string` | `'horizontal'` | Dirección del eje entre el ícono y el grupo de textos. `'horizontal'` los ubica lado a lado, `'vertical'` apila el ícono encima del texto. |
|
|
20
|
+
| `onClose` | `func` | | Si se pasa, muestra un botón de cierre (X) en la esquina superior derecha. |
|
|
21
|
+
| `secondaryButton`| `ButtonShape` | | Configuración del botón de acción secundario. Mismas props que `button`. |
|
|
22
|
+
| `size` | `string` | `'medium'` | Tamaño del banner: `'small'`, `'medium'`, `'large'`. |
|
|
23
|
+
| `style` | `StyleShape` | | Overrides de estilo por sección. Ver sección de estilos. |
|
|
24
|
+
| `title` | `string` | | Texto principal del banner. |
|
|
25
|
+
| `variant` | `string` | `'light'` | Variante de color: `'light'` (fondo claro) o `'dark'` (fondo oscuro). |
|
|
26
|
+
| `withMarkdown` | `bool` | | Si es `true`, renderiza `title` y `description` con soporte Markdown. |
|
|
27
|
+
| `text` | `string` | | **Deprecated.** Usar `title` en su lugar. |
|
|
14
28
|
|
|
15
|
-
|
|
29
|
+
## Tipos personalizados
|
|
16
30
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
31
|
+
### `ButtonShape`
|
|
32
|
+
|
|
33
|
+
```js
|
|
34
|
+
{
|
|
35
|
+
colorTheme: string,
|
|
36
|
+
count: number,
|
|
37
|
+
dataTestId: string,
|
|
38
|
+
disabled: bool,
|
|
39
|
+
Icon: elementType,
|
|
40
|
+
iconPlacement: string,
|
|
41
|
+
loading: bool,
|
|
42
|
+
onPress: func,
|
|
43
|
+
size: string,
|
|
44
|
+
style: object,
|
|
45
|
+
title: string, // Texto del botón (children de UTButton)
|
|
46
|
+
variant: string
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
### `IconShape`
|
|
51
|
+
|
|
52
|
+
```js
|
|
53
|
+
{
|
|
54
|
+
colorTheme: string,
|
|
55
|
+
name: string
|
|
56
|
+
}
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
### `StyleShape`
|
|
60
|
+
|
|
61
|
+
```js
|
|
62
|
+
{
|
|
63
|
+
banner: object, // Estilo del contenedor raíz
|
|
64
|
+
category: object, // Estilo del label de categoría
|
|
65
|
+
description: object, // Estilo del label de descripción
|
|
66
|
+
helpText: object, // Estilo del label de texto de ayuda
|
|
67
|
+
title: object // Estilo del label de título
|
|
68
|
+
}
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
## Variantes de `colorTheme`
|
|
72
|
+
|
|
73
|
+
| Valor | Fondo (light) | Fondo (dark) |
|
|
74
|
+
| --------------- | ------------------------------ | ------------------------- |
|
|
75
|
+
| `'white'` | `Palette.light.01` | `Palette.dark.04` |
|
|
76
|
+
| `'primary'` | `Palette.accent.01` | `Palette.accent.04` |
|
|
77
|
+
| `'gray'` | `Palette.light.02` | `Palette.gray.05` |
|
|
78
|
+
| `'negative'` | `Palette.negative.02` | `Palette.negative.04` |
|
|
79
|
+
| `'error'` | `Palette.error.01` | `Palette.error.04` |
|
|
80
|
+
| `'warning'` | `Palette.warning.01` | `Palette.warning.04` |
|
|
81
|
+
| `'success'` | `Palette.success.01` | `Palette.success.04` |
|
|
82
|
+
| `'information'` | `Palette.information.01` | `Palette.information.04` |
|
|
83
|
+
|
|
84
|
+
## Layouts disponibles (combinaciones de placement)
|
|
85
|
+
|
|
86
|
+
| `iconPlacement` | `buttonPlacement` | Descripción |
|
|
87
|
+
| --------------- | ----------------- | ----------- |
|
|
88
|
+
| `'horizontal'` | `'horizontal'` | Ícono a la izquierda, botones a la derecha del texto _(default)_ |
|
|
89
|
+
| `'horizontal'` | `'vertical'` | Ícono a la izquierda del texto, botones debajo |
|
|
90
|
+
| `'vertical'` | `'horizontal'` | Ícono arriba del texto, botones a la derecha |
|
|
91
|
+
| `'vertical'` | `'vertical'` | Ícono arriba del texto, botones debajo |
|
|
92
|
+
|
|
93
|
+
## Ejemplos de uso
|
|
94
|
+
|
|
95
|
+
### Banner básico
|
|
96
|
+
|
|
97
|
+
```jsx
|
|
98
|
+
<UTBanner
|
|
99
|
+
colorTheme="warning"
|
|
100
|
+
title="Alerta de corte programado"
|
|
101
|
+
description="Tu cuenta se encuentra afectada por un corte programado."
|
|
102
|
+
/>
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### Con categoría, helpText y botones
|
|
106
|
+
|
|
107
|
+
```jsx
|
|
108
|
+
<UTBanner
|
|
109
|
+
button={{ onPress: handleClaim, title: 'Generar reclamo', variant: 'filled' }}
|
|
110
|
+
category="2 alertas en total"
|
|
111
|
+
colorTheme="error"
|
|
112
|
+
description="Tu cuenta se encuentra afectada por un corte programado."
|
|
113
|
+
helpText="2 alertas en total"
|
|
114
|
+
icon={{ colorTheme: 'error', name: 'iconInfo' }}
|
|
115
|
+
onClose={handleClose}
|
|
116
|
+
secondaryButton={{ onPress: handleViewAlerts, title: 'Ver alertas', variant: 'text' }}
|
|
117
|
+
title="Alerta de corte programado"
|
|
118
|
+
/>
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
### Ícono vertical con botones debajo
|
|
122
|
+
|
|
123
|
+
```jsx
|
|
124
|
+
<UTBanner
|
|
125
|
+
button={{ onPress: handleAction, title: 'Acción', variant: 'filled' }}
|
|
126
|
+
buttonPlacement="vertical"
|
|
127
|
+
colorTheme="information"
|
|
128
|
+
icon={{ colorTheme: 'information', name: 'iconInfo' }}
|
|
129
|
+
iconPlacement="vertical"
|
|
130
|
+
title="Información importante"
|
|
131
|
+
/>
|
|
132
|
+
```
|
|
@@ -9,16 +9,28 @@ import { TEST_ID_CONSTANTS } from '../../constants/testIds';
|
|
|
9
9
|
|
|
10
10
|
import { propTypes } from './proptypes';
|
|
11
11
|
import { retrieveStyle } from './theme';
|
|
12
|
-
import { COLOR_THEMES, SIZES, VARIANTS } from './constants';
|
|
12
|
+
import { COLOR_THEMES, PLACEMENTS, SIZES, VARIANTS } from './constants';
|
|
13
13
|
|
|
14
|
-
const {
|
|
14
|
+
const {
|
|
15
|
+
close: closeTestId,
|
|
16
|
+
icon: iconTestId,
|
|
17
|
+
label: labelTestId,
|
|
18
|
+
secondaryAction: buttonTestId,
|
|
19
|
+
tertiaryAction: secondaryButtonTestId
|
|
20
|
+
} = TEST_ID_CONSTANTS;
|
|
15
21
|
|
|
16
22
|
const UTBanner = ({
|
|
17
23
|
button,
|
|
24
|
+
buttonPlacement = PLACEMENTS.HORIZONTAL,
|
|
25
|
+
category,
|
|
18
26
|
colorTheme = COLOR_THEMES.WHITE,
|
|
19
27
|
dataTestId,
|
|
20
28
|
description,
|
|
29
|
+
helpText,
|
|
21
30
|
icon,
|
|
31
|
+
iconPlacement = PLACEMENTS.HORIZONTAL,
|
|
32
|
+
onClose,
|
|
33
|
+
secondaryButton,
|
|
22
34
|
size = SIZES.MEDIUM,
|
|
23
35
|
style,
|
|
24
36
|
text,
|
|
@@ -30,62 +42,117 @@ const UTBanner = ({
|
|
|
30
42
|
|
|
31
43
|
const displayTitle = title || text; // Backwards compatibility
|
|
32
44
|
|
|
33
|
-
const {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
45
|
+
const {
|
|
46
|
+
bannerStyles,
|
|
47
|
+
buttonColorTheme,
|
|
48
|
+
buttonsContainerStyles,
|
|
49
|
+
categoryStyles,
|
|
50
|
+
closeButtonStyles,
|
|
51
|
+
contentStyles,
|
|
52
|
+
descriptionStyles,
|
|
53
|
+
helpTextStyles,
|
|
54
|
+
iconStyles,
|
|
55
|
+
iconTextStyles,
|
|
56
|
+
textContainerStyles,
|
|
57
|
+
titleStyles
|
|
58
|
+
} = retrieveStyle({
|
|
59
|
+
buttonPlacement,
|
|
60
|
+
colorTheme,
|
|
61
|
+
iconPlacement,
|
|
62
|
+
size,
|
|
63
|
+
style,
|
|
64
|
+
theme,
|
|
65
|
+
variant
|
|
66
|
+
});
|
|
41
67
|
|
|
42
68
|
return (
|
|
43
69
|
<View style={bannerStyles} testID={dataTestId}>
|
|
44
|
-
{
|
|
45
|
-
<
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
70
|
+
<View style={contentStyles}>
|
|
71
|
+
<View style={iconTextStyles}>
|
|
72
|
+
{!!icon && (
|
|
73
|
+
<UTIcon
|
|
74
|
+
colorTheme={iconStyles.defaultColorTheme}
|
|
75
|
+
shade={iconStyles.defaultShade}
|
|
76
|
+
size={iconStyles.size}
|
|
77
|
+
{...icon}
|
|
78
|
+
dataTestId={dataTestId ? `${dataTestId}.${iconTestId}` : undefined}
|
|
79
|
+
/>
|
|
80
|
+
)}
|
|
81
|
+
<View style={textContainerStyles}>
|
|
82
|
+
{!!category && (
|
|
83
|
+
<UTLabel
|
|
84
|
+
{...categoryStyles}
|
|
85
|
+
dataTestId={dataTestId ? `${dataTestId}.category.${labelTestId}` : undefined}
|
|
86
|
+
>
|
|
87
|
+
{category}
|
|
88
|
+
</UTLabel>
|
|
89
|
+
)}
|
|
90
|
+
{!!displayTitle && (
|
|
91
|
+
<UTLabel
|
|
92
|
+
{...titleStyles}
|
|
93
|
+
dataTestId={dataTestId ? `${dataTestId}.title.${labelTestId}` : undefined}
|
|
94
|
+
withMarkdown={withMarkdown}
|
|
95
|
+
>
|
|
96
|
+
{displayTitle}
|
|
97
|
+
</UTLabel>
|
|
98
|
+
)}
|
|
99
|
+
{!!description && (
|
|
100
|
+
<UTLabel
|
|
101
|
+
{...descriptionStyles}
|
|
102
|
+
dataTestId={dataTestId ? `${dataTestId}.description.${labelTestId}` : undefined}
|
|
103
|
+
withMarkdown={withMarkdown}
|
|
104
|
+
>
|
|
105
|
+
{description}
|
|
106
|
+
</UTLabel>
|
|
107
|
+
)}
|
|
108
|
+
{!!helpText && (
|
|
109
|
+
<UTLabel
|
|
110
|
+
{...helpTextStyles}
|
|
111
|
+
dataTestId={dataTestId ? `${dataTestId}.helpText.${labelTestId}` : undefined}
|
|
112
|
+
>
|
|
113
|
+
{helpText}
|
|
114
|
+
</UTLabel>
|
|
115
|
+
)}
|
|
116
|
+
</View>
|
|
117
|
+
</View>
|
|
118
|
+
{!!(button || secondaryButton) && (
|
|
119
|
+
<View style={buttonsContainerStyles}>
|
|
120
|
+
{!!button && (
|
|
121
|
+
<UTButton
|
|
122
|
+
colorTheme={buttonColorTheme.button}
|
|
123
|
+
{...button}
|
|
124
|
+
dataTestId={dataTestId ? `${dataTestId}.button.${buttonTestId}` : button.dataTestId}
|
|
125
|
+
>
|
|
126
|
+
{button.title}
|
|
127
|
+
</UTButton>
|
|
128
|
+
)}
|
|
129
|
+
{!!secondaryButton && (
|
|
130
|
+
<UTButton
|
|
131
|
+
colorTheme={buttonColorTheme.secondaryButton}
|
|
132
|
+
variant="text"
|
|
133
|
+
{...secondaryButton}
|
|
134
|
+
dataTestId={
|
|
135
|
+
dataTestId
|
|
136
|
+
? `${dataTestId}.secondaryButton.${secondaryButtonTestId}`
|
|
137
|
+
: secondaryButton.dataTestId
|
|
138
|
+
}
|
|
139
|
+
>
|
|
140
|
+
{secondaryButton.title}
|
|
141
|
+
</UTButton>
|
|
142
|
+
)}
|
|
143
|
+
</View>
|
|
76
144
|
)}
|
|
77
145
|
</View>
|
|
78
|
-
{
|
|
146
|
+
{!!onClose && (
|
|
79
147
|
<UTButton
|
|
80
|
-
colorTheme={
|
|
81
|
-
dataTestId={dataTestId ? `${dataTestId}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
</UTButton>
|
|
148
|
+
colorTheme={buttonColorTheme.onClose}
|
|
149
|
+
dataTestId={dataTestId ? `${dataTestId}.${closeTestId}` : undefined}
|
|
150
|
+
Icon="IconX"
|
|
151
|
+
onPress={onClose}
|
|
152
|
+
size="small"
|
|
153
|
+
style={closeButtonStyles}
|
|
154
|
+
variant="text"
|
|
155
|
+
/>
|
|
89
156
|
)}
|
|
90
157
|
</View>
|
|
91
158
|
);
|
|
@@ -1,20 +1,43 @@
|
|
|
1
|
-
import { bool, object, shape, string } from 'prop-types';
|
|
1
|
+
import { bool, elementType, func, number, object, shape, string } from 'prop-types';
|
|
2
|
+
|
|
3
|
+
const buttonShape = shape({
|
|
4
|
+
colorTheme: string,
|
|
5
|
+
count: number,
|
|
6
|
+
dataTestId: string,
|
|
7
|
+
disabled: bool,
|
|
8
|
+
Icon: elementType,
|
|
9
|
+
iconPlacement: string,
|
|
10
|
+
loading: bool,
|
|
11
|
+
onPress: func,
|
|
12
|
+
size: string,
|
|
13
|
+
style: object,
|
|
14
|
+
title: string,
|
|
15
|
+
variant: string
|
|
16
|
+
});
|
|
2
17
|
|
|
3
18
|
export const propTypes = {
|
|
19
|
+
button: buttonShape,
|
|
20
|
+
buttonPlacement: string,
|
|
21
|
+
category: string,
|
|
22
|
+
colorTheme: string,
|
|
23
|
+
dataTestId: string,
|
|
24
|
+
description: string,
|
|
25
|
+
helpText: string,
|
|
26
|
+
icon: shape({ colorTheme: string, name: string, shade: string }),
|
|
27
|
+
iconPlacement: string,
|
|
28
|
+
onClose: func,
|
|
29
|
+
secondaryButton: buttonShape,
|
|
30
|
+
size: string,
|
|
31
|
+
style: shape({
|
|
32
|
+
banner: object,
|
|
33
|
+
category: object,
|
|
34
|
+
description: object,
|
|
35
|
+
helpText: object,
|
|
36
|
+
title: object
|
|
37
|
+
}),
|
|
4
38
|
/** @deprecated Use `title` instead. Will be removed in next major version. */
|
|
5
39
|
text: string,
|
|
6
40
|
title: string,
|
|
7
|
-
description: string,
|
|
8
|
-
icon: shape({ name: string, colorTheme: string }),
|
|
9
|
-
size: string,
|
|
10
|
-
colorTheme: string,
|
|
11
41
|
variant: string,
|
|
12
|
-
withMarkdown: bool
|
|
13
|
-
dataTestId: string,
|
|
14
|
-
style: shape({
|
|
15
|
-
root: object,
|
|
16
|
-
icon: object,
|
|
17
|
-
title: object,
|
|
18
|
-
description: object
|
|
19
|
-
})
|
|
42
|
+
withMarkdown: bool
|
|
20
43
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { COLOR_THEMES, SIZES, VARIANTS } from './constants';
|
|
1
|
+
import { COLOR_THEMES, PLACEMENTS, SIZES, VARIANTS } from './constants';
|
|
2
2
|
|
|
3
3
|
const getBannerBackgroundColor = (colorTheme, variant, theme) =>
|
|
4
4
|
({
|
|
@@ -50,7 +50,7 @@ const baseBannerTheme = (theme, colorTheme, variant) => ({
|
|
|
50
50
|
gap: 16
|
|
51
51
|
},
|
|
52
52
|
textContainer: {
|
|
53
|
-
|
|
53
|
+
flexShrink: 1,
|
|
54
54
|
gap: 8
|
|
55
55
|
}
|
|
56
56
|
});
|
|
@@ -63,11 +63,18 @@ const sizeBannerTheme = size => {
|
|
|
63
63
|
gap: 24
|
|
64
64
|
},
|
|
65
65
|
icon: {
|
|
66
|
-
size:
|
|
66
|
+
size: 24
|
|
67
67
|
},
|
|
68
68
|
title: {
|
|
69
69
|
variant: 'title3',
|
|
70
70
|
weight: 'medium'
|
|
71
|
+
},
|
|
72
|
+
category: {
|
|
73
|
+
variant: 'xsmall',
|
|
74
|
+
weight: 'medium'
|
|
75
|
+
},
|
|
76
|
+
helpText: {
|
|
77
|
+
variant: 'small'
|
|
71
78
|
}
|
|
72
79
|
},
|
|
73
80
|
medium: {
|
|
@@ -76,7 +83,7 @@ const sizeBannerTheme = size => {
|
|
|
76
83
|
gap: 16
|
|
77
84
|
},
|
|
78
85
|
icon: {
|
|
79
|
-
size:
|
|
86
|
+
size: 20
|
|
80
87
|
},
|
|
81
88
|
title: {
|
|
82
89
|
variant: 'subtitle1',
|
|
@@ -84,6 +91,13 @@ const sizeBannerTheme = size => {
|
|
|
84
91
|
},
|
|
85
92
|
description: {
|
|
86
93
|
variant: 'small'
|
|
94
|
+
},
|
|
95
|
+
category: {
|
|
96
|
+
variant: 'xsmall',
|
|
97
|
+
weight: 'medium'
|
|
98
|
+
},
|
|
99
|
+
helpText: {
|
|
100
|
+
variant: 'small'
|
|
87
101
|
}
|
|
88
102
|
},
|
|
89
103
|
small: {
|
|
@@ -93,7 +107,7 @@ const sizeBannerTheme = size => {
|
|
|
93
107
|
gap: 8
|
|
94
108
|
},
|
|
95
109
|
icon: {
|
|
96
|
-
size:
|
|
110
|
+
size: 20
|
|
97
111
|
},
|
|
98
112
|
title: {
|
|
99
113
|
variant: 'small',
|
|
@@ -101,6 +115,13 @@ const sizeBannerTheme = size => {
|
|
|
101
115
|
},
|
|
102
116
|
description: {
|
|
103
117
|
variant: 'small'
|
|
118
|
+
},
|
|
119
|
+
category: {
|
|
120
|
+
variant: 'xsmall',
|
|
121
|
+
weight: 'medium'
|
|
122
|
+
},
|
|
123
|
+
helpText: {
|
|
124
|
+
variant: 'small'
|
|
104
125
|
}
|
|
105
126
|
}
|
|
106
127
|
};
|
|
@@ -108,10 +129,77 @@ const sizeBannerTheme = size => {
|
|
|
108
129
|
return definition[size] || definition[SIZES.MEDIUM];
|
|
109
130
|
};
|
|
110
131
|
|
|
111
|
-
export const
|
|
132
|
+
export const getDefaultIconTheme = (colorTheme, variant) => {
|
|
133
|
+
if (variant === VARIANTS.DARK) {
|
|
134
|
+
return colorTheme === COLOR_THEMES.NEGATIVE
|
|
135
|
+
? { colorTheme: 'dark', shade: '05' }
|
|
136
|
+
: { colorTheme: 'light', shade: '01' };
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
return (
|
|
140
|
+
{
|
|
141
|
+
[COLOR_THEMES.NEGATIVE]: { colorTheme: 'light', shade: '01' },
|
|
142
|
+
[COLOR_THEMES.WHITE]: { colorTheme: 'accent', shade: '04' },
|
|
143
|
+
[COLOR_THEMES.PRIMARY]: { colorTheme: 'accent', shade: '04' },
|
|
144
|
+
[COLOR_THEMES.GRAY]: { colorTheme: 'accent', shade: '04' },
|
|
145
|
+
[COLOR_THEMES.WARNING]: { colorTheme: 'warning', shade: '04' },
|
|
146
|
+
[COLOR_THEMES.SUCCESS]: { colorTheme: 'success', shade: '04' },
|
|
147
|
+
[COLOR_THEMES.ERROR]: { colorTheme: 'error', shade: '04' },
|
|
148
|
+
[COLOR_THEMES.INFORMATION]: { colorTheme: 'information', shade: '04' }
|
|
149
|
+
}[colorTheme] ?? { colorTheme: 'accent', shade: '04' }
|
|
150
|
+
);
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
export const getDefaultButtonColorTheme = variant => {
|
|
154
|
+
const isDark = variant === VARIANTS.DARK;
|
|
155
|
+
return {
|
|
156
|
+
button: isDark ? 'negative' : 'secondary',
|
|
157
|
+
onClose: isDark ? 'negative' : 'gray',
|
|
158
|
+
secondaryButton: isDark ? 'negative' : 'secondary'
|
|
159
|
+
};
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
export const getPlacementStyles = (iconPlacement, buttonPlacement, gap = 16) => {
|
|
163
|
+
const isVerticalButton = buttonPlacement === PLACEMENTS.VERTICAL;
|
|
164
|
+
const isVerticalIcon = iconPlacement === PLACEMENTS.VERTICAL;
|
|
165
|
+
|
|
166
|
+
return {
|
|
167
|
+
content: {
|
|
168
|
+
flex: 1,
|
|
169
|
+
flexDirection: isVerticalButton ? 'column' : 'row',
|
|
170
|
+
...(isVerticalButton ? {} : { alignItems: 'flex-start' }),
|
|
171
|
+
gap
|
|
172
|
+
},
|
|
173
|
+
iconText: {
|
|
174
|
+
...(!isVerticalButton && { flex: 1 }),
|
|
175
|
+
flexDirection: isVerticalIcon ? 'column' : 'row',
|
|
176
|
+
...(isVerticalIcon ? {} : { alignItems: 'flex-start' }),
|
|
177
|
+
flexShrink: 1,
|
|
178
|
+
gap: 12
|
|
179
|
+
},
|
|
180
|
+
buttonsContainer: {
|
|
181
|
+
flexDirection: 'row',
|
|
182
|
+
flexWrap: 'wrap',
|
|
183
|
+
gap: 8,
|
|
184
|
+
...(isVerticalButton && { alignSelf: 'flex-start' })
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export const retrieveStyle = ({
|
|
190
|
+
buttonPlacement,
|
|
191
|
+
colorTheme,
|
|
192
|
+
iconPlacement,
|
|
193
|
+
size,
|
|
194
|
+
style = {},
|
|
195
|
+
theme,
|
|
196
|
+
variant
|
|
197
|
+
}) => {
|
|
112
198
|
const baseTheme = baseBannerTheme(theme, colorTheme, variant);
|
|
113
199
|
const sizeTheme = sizeBannerTheme(size);
|
|
114
200
|
const labelColorTheme = getLabelColorTheme(colorTheme, variant);
|
|
201
|
+
const sizeGap = sizeTheme.banner?.gap ?? 16;
|
|
202
|
+
const placementStyles = getPlacementStyles(iconPlacement, buttonPlacement, sizeGap);
|
|
115
203
|
|
|
116
204
|
const bannerStyles = {
|
|
117
205
|
...baseTheme.banner,
|
|
@@ -119,10 +207,32 @@ export const retrieveStyle = ({ style = {}, size, theme, colorTheme, variant })
|
|
|
119
207
|
...style.banner
|
|
120
208
|
};
|
|
121
209
|
|
|
210
|
+
const contentStyles = placementStyles.content;
|
|
211
|
+
|
|
212
|
+
const iconTextStyles = placementStyles.iconText;
|
|
213
|
+
|
|
214
|
+
const defaultIconTheme = getDefaultIconTheme(colorTheme, variant);
|
|
215
|
+
const buttonColorTheme = getDefaultButtonColorTheme(variant);
|
|
216
|
+
|
|
122
217
|
const iconStyles = {
|
|
218
|
+
defaultColorTheme: defaultIconTheme.colorTheme,
|
|
219
|
+
defaultShade: defaultIconTheme.shade,
|
|
123
220
|
size: sizeTheme.icon?.size
|
|
124
221
|
};
|
|
125
222
|
|
|
223
|
+
const textContainerStyles = {
|
|
224
|
+
...baseTheme.textContainer,
|
|
225
|
+
...sizeTheme.textContainer,
|
|
226
|
+
...(iconPlacement !== PLACEMENTS.VERTICAL && { flex: 1 })
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
const categoryStyles = {
|
|
230
|
+
colorTheme: labelColorTheme,
|
|
231
|
+
variant: sizeTheme.category?.variant,
|
|
232
|
+
weight: sizeTheme.category?.weight,
|
|
233
|
+
style: style.category
|
|
234
|
+
};
|
|
235
|
+
|
|
126
236
|
const titleStyles = {
|
|
127
237
|
colorTheme: labelColorTheme,
|
|
128
238
|
variant: sizeTheme.title?.variant,
|
|
@@ -137,16 +247,32 @@ export const retrieveStyle = ({ style = {}, size, theme, colorTheme, variant })
|
|
|
137
247
|
style: style.description
|
|
138
248
|
};
|
|
139
249
|
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
250
|
+
const helpTextStyles = {
|
|
251
|
+
colorTheme: labelColorTheme,
|
|
252
|
+
variant: sizeTheme.helpText?.variant,
|
|
253
|
+
style: style.helpText
|
|
143
254
|
};
|
|
144
255
|
|
|
145
|
-
const
|
|
256
|
+
const buttonsContainerStyles = placementStyles.buttonsContainer;
|
|
257
|
+
|
|
258
|
+
const closeButtonStyles = {
|
|
146
259
|
root: {
|
|
147
260
|
alignSelf: 'flex-start'
|
|
148
261
|
}
|
|
149
262
|
};
|
|
150
263
|
|
|
151
|
-
return {
|
|
264
|
+
return {
|
|
265
|
+
bannerStyles,
|
|
266
|
+
buttonColorTheme,
|
|
267
|
+
buttonsContainerStyles,
|
|
268
|
+
categoryStyles,
|
|
269
|
+
closeButtonStyles,
|
|
270
|
+
contentStyles,
|
|
271
|
+
descriptionStyles,
|
|
272
|
+
helpTextStyles,
|
|
273
|
+
iconStyles,
|
|
274
|
+
iconTextStyles,
|
|
275
|
+
textContainerStyles,
|
|
276
|
+
titleStyles
|
|
277
|
+
};
|
|
152
278
|
};
|