@widergy/mobile-ui 2.9.2 → 2.9.3
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
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
## [2.9.3](https://github.com/widergy/mobile-ui/compare/v2.9.2...v2.9.3) (2026-03-30)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* [UGGC-84] standarize utbanner colortheme variant and button ([#489](https://github.com/widergy/mobile-ui/issues/489)) ([912ca0f](https://github.com/widergy/mobile-ui/commit/912ca0f73d0b90376f09ee0d00e3d1d67cc8ef6b))
|
|
7
|
+
|
|
1
8
|
## [2.9.2](https://github.com/widergy/mobile-ui/compare/v2.9.1...v2.9.2) (2026-03-26)
|
|
2
9
|
|
|
3
10
|
|
|
@@ -3,3 +3,19 @@ export const SIZES = {
|
|
|
3
3
|
MEDIUM: 'medium',
|
|
4
4
|
LARGE: 'large'
|
|
5
5
|
};
|
|
6
|
+
|
|
7
|
+
export const COLOR_THEMES = {
|
|
8
|
+
NEGATIVE: 'negative',
|
|
9
|
+
PRIMARY: 'primary',
|
|
10
|
+
GRAY: 'gray',
|
|
11
|
+
WHITE: 'white',
|
|
12
|
+
ERROR: 'error',
|
|
13
|
+
WARNING: 'warning',
|
|
14
|
+
SUCCESS: 'success',
|
|
15
|
+
INFORMATION: 'information'
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export const VARIANTS = {
|
|
19
|
+
LIGHT: 'light',
|
|
20
|
+
DARK: 'dark'
|
|
21
|
+
};
|
|
@@ -3,64 +3,94 @@ import { View } from 'react-native';
|
|
|
3
3
|
|
|
4
4
|
import UTIcon from '../UTIcon';
|
|
5
5
|
import UTLabel from '../UTLabel';
|
|
6
|
+
import UTButton from '../UTButton';
|
|
6
7
|
import { useTheme } from '../../theming';
|
|
7
8
|
import { TEST_ID_CONSTANTS } from '../../constants/testIds';
|
|
8
9
|
|
|
9
|
-
import {
|
|
10
|
+
import { propTypes } from './proptypes';
|
|
10
11
|
import { retrieveStyle } from './theme';
|
|
12
|
+
import { COLOR_THEMES, SIZES, VARIANTS } from './constants';
|
|
11
13
|
|
|
12
|
-
const { icon: iconTestId, label: labelTestId } = TEST_ID_CONSTANTS;
|
|
14
|
+
const { icon: iconTestId, label: labelTestId, secondaryAction: buttonTestId } = TEST_ID_CONSTANTS;
|
|
13
15
|
|
|
14
|
-
const UTBanner = ({
|
|
16
|
+
const UTBanner = ({
|
|
17
|
+
button,
|
|
18
|
+
colorTheme = COLOR_THEMES.WHITE,
|
|
19
|
+
dataTestId,
|
|
20
|
+
description,
|
|
21
|
+
icon,
|
|
22
|
+
size = SIZES.MEDIUM,
|
|
23
|
+
style,
|
|
24
|
+
text,
|
|
25
|
+
title,
|
|
26
|
+
variant = VARIANTS.LIGHT,
|
|
27
|
+
withMarkdown
|
|
28
|
+
}) => {
|
|
15
29
|
const theme = useTheme();
|
|
16
30
|
|
|
17
31
|
const displayTitle = title || text; // Backwards compatibility
|
|
18
32
|
|
|
19
|
-
const { bannerStyles, iconStyles, titleStyles, descriptionStyles, textContainerStyles } =
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
33
|
+
const { bannerStyles, iconStyles, titleStyles, descriptionStyles, textContainerStyles, buttonStyles } =
|
|
34
|
+
retrieveStyle({
|
|
35
|
+
colorTheme,
|
|
36
|
+
size,
|
|
37
|
+
style,
|
|
38
|
+
theme,
|
|
39
|
+
variant
|
|
40
|
+
});
|
|
24
41
|
|
|
25
42
|
return (
|
|
26
43
|
<View style={bannerStyles} testID={dataTestId}>
|
|
27
44
|
{icon && (
|
|
28
45
|
<UTIcon
|
|
29
|
-
name={icon.name}
|
|
30
46
|
colorTheme={icon.colorTheme}
|
|
31
|
-
size={iconStyles.size}
|
|
32
47
|
dataTestId={dataTestId ? `${dataTestId}.${iconTestId}` : undefined}
|
|
48
|
+
name={icon.name}
|
|
49
|
+
size={iconStyles.size}
|
|
33
50
|
/>
|
|
34
51
|
)}
|
|
35
52
|
<View style={textContainerStyles}>
|
|
36
53
|
{displayTitle && (
|
|
37
54
|
<UTLabel
|
|
38
|
-
|
|
55
|
+
colorTheme={titleStyles.colorTheme}
|
|
56
|
+
dataTestId={dataTestId ? `${dataTestId}.title.${labelTestId}` : undefined}
|
|
57
|
+
style={titleStyles.style}
|
|
39
58
|
variant={titleStyles.variant}
|
|
40
59
|
weight={titleStyles.weight}
|
|
41
|
-
|
|
42
|
-
dataTestId={dataTestId ? `${dataTestId}.title.${labelTestId}` : undefined}
|
|
60
|
+
withMarkdown={withMarkdown}
|
|
43
61
|
>
|
|
44
62
|
{displayTitle}
|
|
45
63
|
</UTLabel>
|
|
46
64
|
)}
|
|
47
65
|
{description && (
|
|
48
66
|
<UTLabel
|
|
49
|
-
|
|
67
|
+
colorTheme={descriptionStyles.colorTheme}
|
|
68
|
+
dataTestId={dataTestId ? `${dataTestId}.description.${labelTestId}` : undefined}
|
|
69
|
+
style={descriptionStyles.style}
|
|
50
70
|
variant={descriptionStyles.variant}
|
|
51
71
|
weight={descriptionStyles.weight}
|
|
52
|
-
|
|
53
|
-
dataTestId={dataTestId ? `${dataTestId}.description.${labelTestId}` : undefined}
|
|
72
|
+
withMarkdown={withMarkdown}
|
|
54
73
|
>
|
|
55
74
|
{description}
|
|
56
75
|
</UTLabel>
|
|
57
76
|
)}
|
|
58
77
|
</View>
|
|
78
|
+
{button && (
|
|
79
|
+
<UTButton
|
|
80
|
+
colorTheme={button.colorTheme}
|
|
81
|
+
dataTestId={dataTestId ? `${dataTestId}.button.${buttonTestId}` : undefined}
|
|
82
|
+
onPress={button.onPress}
|
|
83
|
+
size={button.size}
|
|
84
|
+
style={buttonStyles}
|
|
85
|
+
variant={button.variant}
|
|
86
|
+
>
|
|
87
|
+
{button.title}
|
|
88
|
+
</UTButton>
|
|
89
|
+
)}
|
|
59
90
|
</View>
|
|
60
91
|
);
|
|
61
92
|
};
|
|
62
93
|
|
|
63
|
-
UTBanner.defaultProps = defaultProps;
|
|
64
94
|
UTBanner.propTypes = propTypes;
|
|
65
95
|
|
|
66
96
|
export default UTBanner;
|
|
@@ -1,11 +1,5 @@
|
|
|
1
1
|
import { bool, object, shape, string } from 'prop-types';
|
|
2
2
|
|
|
3
|
-
import { SIZES } from './constants';
|
|
4
|
-
|
|
5
|
-
export const defaultProps = {
|
|
6
|
-
size: SIZES.MEDIUM
|
|
7
|
-
};
|
|
8
|
-
|
|
9
3
|
export const propTypes = {
|
|
10
4
|
/** @deprecated Use `title` instead. Will be removed in next major version. */
|
|
11
5
|
text: string,
|
|
@@ -13,6 +7,8 @@ export const propTypes = {
|
|
|
13
7
|
description: string,
|
|
14
8
|
icon: shape({ name: string, colorTheme: string }),
|
|
15
9
|
size: string,
|
|
10
|
+
colorTheme: string,
|
|
11
|
+
variant: string,
|
|
16
12
|
withMarkdown: bool,
|
|
17
13
|
dataTestId: string,
|
|
18
14
|
style: shape({
|
|
@@ -1,8 +1,49 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { COLOR_THEMES, SIZES, VARIANTS } from './constants';
|
|
2
2
|
|
|
3
|
-
const
|
|
3
|
+
const getBannerBackgroundColor = (colorTheme, variant, theme) =>
|
|
4
|
+
({
|
|
5
|
+
[COLOR_THEMES.NEGATIVE]: {
|
|
6
|
+
[VARIANTS.LIGHT]: theme.Palette?.negative['02'],
|
|
7
|
+
[VARIANTS.DARK]: theme.Palette?.negative['04']
|
|
8
|
+
},
|
|
9
|
+
[COLOR_THEMES.PRIMARY]: {
|
|
10
|
+
[VARIANTS.LIGHT]: theme.Palette?.accent['01'],
|
|
11
|
+
[VARIANTS.DARK]: theme.Palette?.accent['04']
|
|
12
|
+
},
|
|
13
|
+
[COLOR_THEMES.GRAY]: {
|
|
14
|
+
[VARIANTS.LIGHT]: theme.Palette?.light['02'],
|
|
15
|
+
[VARIANTS.DARK]: theme.Palette?.gray['05']
|
|
16
|
+
},
|
|
17
|
+
[COLOR_THEMES.WHITE]: {
|
|
18
|
+
[VARIANTS.LIGHT]: theme.Palette?.light['01'],
|
|
19
|
+
[VARIANTS.DARK]: theme.Palette?.dark['04']
|
|
20
|
+
},
|
|
21
|
+
[COLOR_THEMES.ERROR]: {
|
|
22
|
+
[VARIANTS.LIGHT]: theme.Palette?.error['01'],
|
|
23
|
+
[VARIANTS.DARK]: theme.Palette?.error['04']
|
|
24
|
+
},
|
|
25
|
+
[COLOR_THEMES.WARNING]: {
|
|
26
|
+
[VARIANTS.LIGHT]: theme.Palette?.warning['01'],
|
|
27
|
+
[VARIANTS.DARK]: theme.Palette?.warning['04']
|
|
28
|
+
},
|
|
29
|
+
[COLOR_THEMES.SUCCESS]: {
|
|
30
|
+
[VARIANTS.LIGHT]: theme.Palette?.success['01'],
|
|
31
|
+
[VARIANTS.DARK]: theme.Palette?.success['04']
|
|
32
|
+
},
|
|
33
|
+
[COLOR_THEMES.INFORMATION]: {
|
|
34
|
+
[VARIANTS.LIGHT]: theme.Palette?.information['01'],
|
|
35
|
+
[VARIANTS.DARK]: theme.Palette?.information['04']
|
|
36
|
+
}
|
|
37
|
+
})[colorTheme]?.[variant];
|
|
38
|
+
|
|
39
|
+
const getLabelColorTheme = (colorTheme, variant) => {
|
|
40
|
+
if (colorTheme === COLOR_THEMES.NEGATIVE) return variant === VARIANTS.LIGHT ? 'light' : 'dark';
|
|
41
|
+
return variant === VARIANTS.LIGHT ? 'dark' : 'light';
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
const baseBannerTheme = (theme, colorTheme, variant) => ({
|
|
4
45
|
banner: {
|
|
5
|
-
backgroundColor: theme
|
|
46
|
+
backgroundColor: getBannerBackgroundColor(colorTheme, variant, theme),
|
|
6
47
|
borderRadius: 8,
|
|
7
48
|
flexDirection: 'row',
|
|
8
49
|
padding: 16,
|
|
@@ -64,12 +105,13 @@ const sizeBannerTheme = size => {
|
|
|
64
105
|
}
|
|
65
106
|
};
|
|
66
107
|
|
|
67
|
-
return definition[size] || definition[
|
|
108
|
+
return definition[size] || definition[SIZES.MEDIUM];
|
|
68
109
|
};
|
|
69
110
|
|
|
70
|
-
export const retrieveStyle = ({ style = {}, size, theme }) => {
|
|
71
|
-
const baseTheme = baseBannerTheme(theme);
|
|
111
|
+
export const retrieveStyle = ({ style = {}, size, theme, colorTheme, variant }) => {
|
|
112
|
+
const baseTheme = baseBannerTheme(theme, colorTheme, variant);
|
|
72
113
|
const sizeTheme = sizeBannerTheme(size);
|
|
114
|
+
const labelColorTheme = getLabelColorTheme(colorTheme, variant);
|
|
73
115
|
|
|
74
116
|
const bannerStyles = {
|
|
75
117
|
...baseTheme.banner,
|
|
@@ -82,12 +124,14 @@ export const retrieveStyle = ({ style = {}, size, theme }) => {
|
|
|
82
124
|
};
|
|
83
125
|
|
|
84
126
|
const titleStyles = {
|
|
127
|
+
colorTheme: labelColorTheme,
|
|
85
128
|
variant: sizeTheme.title?.variant,
|
|
86
129
|
weight: sizeTheme.title?.weight,
|
|
87
130
|
style: style.title
|
|
88
131
|
};
|
|
89
132
|
|
|
90
133
|
const descriptionStyles = {
|
|
134
|
+
colorTheme: labelColorTheme,
|
|
91
135
|
variant: sizeTheme.description?.variant,
|
|
92
136
|
weight: sizeTheme.description?.weight,
|
|
93
137
|
style: style.description
|
|
@@ -98,5 +142,11 @@ export const retrieveStyle = ({ style = {}, size, theme }) => {
|
|
|
98
142
|
...sizeTheme.textContainer
|
|
99
143
|
};
|
|
100
144
|
|
|
101
|
-
|
|
145
|
+
const buttonStyles = {
|
|
146
|
+
root: {
|
|
147
|
+
alignSelf: 'flex-start'
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return { bannerStyles, iconStyles, titleStyles, descriptionStyles, textContainerStyles, buttonStyles };
|
|
102
152
|
};
|
package/package.json
CHANGED