@widergy/mobile-ui 1.10.4 → 1.11.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 +14 -0
- package/lib/components/UTBadge/README.md +45 -0
- package/lib/components/UTBadge/constants.js +13 -0
- package/lib/components/UTBadge/index.js +36 -0
- package/lib/components/UTBadge/theme.js +53 -0
- package/lib/components/UTButton/README.md +7 -4
- package/lib/components/UTButton/index.js +16 -15
- package/lib/components/UTButton/theme.js +8 -8
- package/lib/components/UTLabel/constants.js +1 -1
- package/lib/components/UTLabel/index.js +6 -7
- package/lib/components/UTLabel/theme.js +1 -2
- package/lib/components/UTProductItem/index.js +22 -3
- package/lib/components/UTProductItem/styles.js +15 -3
- package/lib/index.js +1 -0
- package/lib/theming/DefaultTheme.js +35 -53
- package/lib/utils/styleUtils/index.js +1 -14
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
## [1.11.1](https://github.com/widergy/mobile-ui/compare/v1.11.0...v1.11.1) (2024-06-03)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Bug Fixes
|
|
5
|
+
|
|
6
|
+
* add UTBadge ([#290](https://github.com/widergy/mobile-ui/issues/290)) ([d89f04e](https://github.com/widergy/mobile-ui/commit/d89f04e9f80d010a39f4ca0090ab7c2fbf2dcbec))
|
|
7
|
+
|
|
8
|
+
# [1.11.0](https://github.com/widergy/mobile-ui/compare/v1.10.4...v1.11.0) (2024-06-03)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Features
|
|
12
|
+
|
|
13
|
+
* quantity prop for utproductitem ([#288](https://github.com/widergy/mobile-ui/issues/288)) ([dc80116](https://github.com/widergy/mobile-ui/commit/dc80116a2f552b9086dde49ca358dc119a2fe09e))
|
|
14
|
+
|
|
1
15
|
## [1.10.4](https://github.com/widergy/mobile-ui/compare/v1.10.3...v1.10.4) (2024-05-31)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
# UTBadge
|
|
2
|
+
|
|
3
|
+
### Description
|
|
4
|
+
|
|
5
|
+
Basic badge component for displaying labels with various color themes.
|
|
6
|
+
|
|
7
|
+
### Color Themes
|
|
8
|
+
|
|
9
|
+
The color themes are defined by the UX team and are:
|
|
10
|
+
|
|
11
|
+
- `alert`: Consumes the error variant.
|
|
12
|
+
- `identity`: Consumes the accent variant.
|
|
13
|
+
- `identitySecondary`: Consumes the neutral variant.
|
|
14
|
+
- `negative`: Consumes the negative variant.
|
|
15
|
+
- `information`: Consumes the information variant.
|
|
16
|
+
- `warning`: Consumes the warning variant.
|
|
17
|
+
- `success`: Consumes the success variant.
|
|
18
|
+
|
|
19
|
+
These color themes will change how the badge looks.
|
|
20
|
+
|
|
21
|
+
### Props
|
|
22
|
+
|
|
23
|
+
| Name | Type | Default | Description |
|
|
24
|
+
| ---------- | ------ | ------- | -------------------------------------------------------------------------------------------------------------------------- |
|
|
25
|
+
| children | string | | The text content to be displayed inside the badge. |
|
|
26
|
+
| colorTheme | string | 'alert' | The color theme to use. One of: `alert`, `identity`, `identitySecondary`, `negative`, `information`, `warning`, `success`. |
|
|
27
|
+
| style | | | The style to be aplied to the Badge |
|
|
28
|
+
|
|
29
|
+
### Example
|
|
30
|
+
|
|
31
|
+
```jsx
|
|
32
|
+
import React from 'react';
|
|
33
|
+
import UTBadge from '@widergy/energy-ui';
|
|
34
|
+
|
|
35
|
+
const App = () => (
|
|
36
|
+
<div>
|
|
37
|
+
<UTBadge />
|
|
38
|
+
<UTBadge colorTheme="identity">0</UTBadge>
|
|
39
|
+
<UTBadge colorTheme="information">999+</UTBadge>
|
|
40
|
+
<UTBadge colorTheme="success">Success Badge</UTBadge>
|
|
41
|
+
</div>
|
|
42
|
+
);
|
|
43
|
+
|
|
44
|
+
export default App;
|
|
45
|
+
```
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export const COLORS_MAPPER = {
|
|
2
|
+
alert: 'error',
|
|
3
|
+
identity: 'accent',
|
|
4
|
+
identitySecondary: 'neutral',
|
|
5
|
+
information: 'information',
|
|
6
|
+
negative: 'negative',
|
|
7
|
+
success: 'success',
|
|
8
|
+
warning: 'warning'
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const DEFAULT_PROPS = {
|
|
12
|
+
colorTheme: 'alert'
|
|
13
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { string } from 'prop-types';
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
5
|
+
|
|
6
|
+
import { themeType, withTheme } from '../../theming';
|
|
7
|
+
import UTLabel from '../UTLabel';
|
|
8
|
+
|
|
9
|
+
import { DEFAULT_PROPS } from './constants';
|
|
10
|
+
import { retrieveStyle } from './theme';
|
|
11
|
+
|
|
12
|
+
const UTBadge = ({ children, colorTheme, style, theme }) => {
|
|
13
|
+
const classes = retrieveStyle({ theme, children, colorTheme });
|
|
14
|
+
const Component = children ? UTLabel : View;
|
|
15
|
+
return (
|
|
16
|
+
<Component
|
|
17
|
+
colorTheme={classes.textColorTheme}
|
|
18
|
+
style={[classes.root, style]}
|
|
19
|
+
variant="xsmall"
|
|
20
|
+
weight="medium"
|
|
21
|
+
>
|
|
22
|
+
{children}
|
|
23
|
+
</Component>
|
|
24
|
+
);
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
UTBadge.defaultProps = DEFAULT_PROPS;
|
|
28
|
+
|
|
29
|
+
UTBadge.propTypes = {
|
|
30
|
+
children: string,
|
|
31
|
+
colorTheme: string,
|
|
32
|
+
style: ViewPropTypes.style,
|
|
33
|
+
theme: themeType
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export default withTheme(UTBadge);
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { COLORS_MAPPER, DEFAULT_PROPS } from './constants';
|
|
2
|
+
|
|
3
|
+
export const variantsColorTheme = (theme, colorTheme) => {
|
|
4
|
+
const colorName = COLORS_MAPPER[colorTheme] || COLORS_MAPPER[DEFAULT_PROPS.colorTheme];
|
|
5
|
+
const paletteTheme = theme.Palette[colorName];
|
|
6
|
+
|
|
7
|
+
const backgroundColorMapper = {
|
|
8
|
+
alert: paletteTheme['04'],
|
|
9
|
+
information: paletteTheme['05'],
|
|
10
|
+
warning: paletteTheme['05'],
|
|
11
|
+
success: paletteTheme['05'],
|
|
12
|
+
identity: paletteTheme['05'],
|
|
13
|
+
identitySecondary: paletteTheme['05'],
|
|
14
|
+
negative: paletteTheme['04']
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
backgroundColor: backgroundColorMapper[colorTheme]
|
|
19
|
+
};
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
const baseButtonTheme = () => ({
|
|
23
|
+
noChildren: {
|
|
24
|
+
height: 10,
|
|
25
|
+
width: 10
|
|
26
|
+
},
|
|
27
|
+
root: {
|
|
28
|
+
alignItems: 'center',
|
|
29
|
+
borderRadius: 100,
|
|
30
|
+
justifyContent: 'center',
|
|
31
|
+
margin: 10
|
|
32
|
+
},
|
|
33
|
+
text: {
|
|
34
|
+
alignSelf: 'flex-start',
|
|
35
|
+
height: 20,
|
|
36
|
+
paddingHorizontal: 6
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
export const retrieveStyle = ({ theme, colorTheme, children }) => {
|
|
41
|
+
const baseTheme = baseButtonTheme();
|
|
42
|
+
const textTheme = children ? baseTheme.text : baseTheme.noChildren;
|
|
43
|
+
const variantTheme = variantsColorTheme(theme, colorTheme);
|
|
44
|
+
|
|
45
|
+
return {
|
|
46
|
+
root: {
|
|
47
|
+
...baseTheme.root,
|
|
48
|
+
...textTheme,
|
|
49
|
+
...variantTheme
|
|
50
|
+
},
|
|
51
|
+
textColorTheme: colorTheme === 'negative' ? 'dark' : 'negative'
|
|
52
|
+
};
|
|
53
|
+
};
|
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
# UTButton
|
|
2
2
|
|
|
3
3
|
### Description
|
|
4
|
+
|
|
4
5
|
Basic button component.
|
|
5
6
|
|
|
6
7
|
### Variants
|
|
8
|
+
|
|
7
9
|
These variants were defined by the UX team and are:
|
|
8
10
|
|
|
9
11
|
- `filled`
|
|
@@ -14,15 +16,16 @@ These variants were defined by the UX team and are:
|
|
|
14
16
|
All these variants are defined in the component theme.
|
|
15
17
|
|
|
16
18
|
### Color Themes
|
|
17
|
-
|
|
19
|
+
|
|
20
|
+
The color themes are defined by the component consumer and will vary accordingly.They define a set of variables (colors and opacities) that then combined with the variant will change how the buttons looks.
|
|
18
21
|
The components supports an infinite amount of color themes but requieres the consumer to pass at least a `primary` one that works as a default.
|
|
19
22
|
|
|
20
23
|
### Props
|
|
21
24
|
|
|
22
25
|
| Name | Type | Default | Description |
|
|
23
|
-
|
|
26
|
+
| -------------------- | ----------------------------------------------------- | --------- | ------------------------------------------------------------------------------ |
|
|
24
27
|
| children | node | | The component contents. |
|
|
25
|
-
|
|
|
28
|
+
| styles | object | | Overrides the default button theme. |
|
|
26
29
|
| colorTheme | string | 'primary' | The color theme to use. |
|
|
27
30
|
| disabled | bool | false | If `true` the button is unclickable. |
|
|
28
31
|
| Icon | node | | An Icon component that can be displayed within the button. |
|
|
@@ -31,4 +34,4 @@ The components supports an infinite amount of color themes but requieres the con
|
|
|
31
34
|
| onClick | func | | Callback fired when the user clicks the component. |
|
|
32
35
|
| showTextOnResponsive | bool | false | If `true` and Icon is not `null` the contents of the button are not displayed. |
|
|
33
36
|
| size | 'small' \| 'medium' \| 'large' | 'medium' | The size of the component. |
|
|
34
|
-
| variant | 'filled' \| 'outlined' \| 'text' \| 'semitransparent' | 'filled' | The variant to use. |
|
|
37
|
+
| variant | 'filled' \| 'outlined' \| 'text' \| 'semitransparent' | 'filled' | The variant to use. |
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { bool, func, elementType,
|
|
2
|
+
import { bool, func, elementType, string } from 'prop-types';
|
|
3
3
|
import { Pressable, Text, View } from 'react-native';
|
|
4
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
4
5
|
|
|
5
|
-
import { withTheme } from '../../theming';
|
|
6
|
+
import { themeType, withTheme } from '../../theming';
|
|
6
7
|
import UTIcon from '../UTIcon';
|
|
7
8
|
import UTLoading from '../UTLoading';
|
|
8
9
|
|
|
9
10
|
import { DEFAULT_PROPS, ICON_PLACEMENTS } from './constants';
|
|
10
|
-
import { retrieveStyle } from './theme';
|
|
11
11
|
import { isUTIcon } from './utils';
|
|
12
|
+
import { retrieveStyle } from './theme';
|
|
12
13
|
|
|
13
14
|
const UTButton = ({
|
|
14
15
|
children,
|
|
15
|
-
classNames,
|
|
16
16
|
colorTheme,
|
|
17
17
|
disabled,
|
|
18
18
|
Icon,
|
|
@@ -20,17 +20,18 @@ const UTButton = ({
|
|
|
20
20
|
loading,
|
|
21
21
|
onPress,
|
|
22
22
|
size,
|
|
23
|
+
style,
|
|
23
24
|
theme,
|
|
24
25
|
variant
|
|
25
26
|
}) => {
|
|
26
27
|
const {
|
|
27
28
|
buttonStyles: themeButtonStyles,
|
|
28
29
|
childrenContainerStyles: themeChildrenContainerStyles,
|
|
29
|
-
|
|
30
|
+
disabledStyles,
|
|
30
31
|
iconStyles: themeIconStyles,
|
|
31
32
|
textStyles: themeTextStyles
|
|
32
33
|
} = retrieveStyle({
|
|
33
|
-
|
|
34
|
+
style,
|
|
34
35
|
colorTheme,
|
|
35
36
|
iconPlacement,
|
|
36
37
|
size,
|
|
@@ -38,34 +39,34 @@ const UTButton = ({
|
|
|
38
39
|
variant
|
|
39
40
|
});
|
|
40
41
|
|
|
41
|
-
const
|
|
42
|
+
const iconStyle = children ? themeIconStyles.icon : themeIconStyles.iconOnly;
|
|
42
43
|
|
|
43
|
-
const
|
|
44
|
+
const buttonStyles = ({ pressed }) => [
|
|
44
45
|
themeButtonStyles,
|
|
45
46
|
(disabled || loading) && disabledStyles,
|
|
46
47
|
pressed ? themeButtonStyles.pressed : themeButtonStyles.notPressed
|
|
47
48
|
];
|
|
48
49
|
|
|
49
|
-
const
|
|
50
|
+
const textStyles = themeTextStyles;
|
|
50
51
|
|
|
51
52
|
const IconToShow =
|
|
52
53
|
Icon &&
|
|
53
54
|
(isUTIcon(Icon) ? (
|
|
54
|
-
<UTIcon color={themeTextStyles.color} style={
|
|
55
|
+
<UTIcon color={themeTextStyles.color} style={iconStyle} size={iconStyle.fontSize} name={Icon} />
|
|
55
56
|
) : (
|
|
56
|
-
<Icon style={
|
|
57
|
+
<Icon style={iconStyle} fill={themeTextStyles.color} />
|
|
57
58
|
));
|
|
58
59
|
|
|
59
60
|
const RenderedChildren = (
|
|
60
61
|
<View style={themeChildrenContainerStyles}>
|
|
61
62
|
{iconPlacement === ICON_PLACEMENTS.left && IconToShow}
|
|
62
|
-
{children && <Text style={
|
|
63
|
+
{children && <Text style={textStyles}>{children}</Text>}
|
|
63
64
|
{iconPlacement !== ICON_PLACEMENTS.left && IconToShow}
|
|
64
65
|
</View>
|
|
65
66
|
);
|
|
66
67
|
|
|
67
68
|
return (
|
|
68
|
-
<Pressable disabled={disabled || loading} onPress={onPress} style={
|
|
69
|
+
<Pressable disabled={disabled || loading} onPress={onPress} style={buttonStyles}>
|
|
69
70
|
<UTLoading color={themeTextStyles.color} loading={loading} size={24} thickness={2}>
|
|
70
71
|
{RenderedChildren}
|
|
71
72
|
</UTLoading>
|
|
@@ -76,7 +77,6 @@ const UTButton = ({
|
|
|
76
77
|
UTButton.defaultProps = DEFAULT_PROPS;
|
|
77
78
|
|
|
78
79
|
UTButton.propTypes = {
|
|
79
|
-
classNames: objectOf(string),
|
|
80
80
|
colorTheme: string,
|
|
81
81
|
disabled: bool,
|
|
82
82
|
Icon: elementType,
|
|
@@ -84,7 +84,8 @@ UTButton.propTypes = {
|
|
|
84
84
|
loading: bool,
|
|
85
85
|
onPress: func,
|
|
86
86
|
size: string,
|
|
87
|
-
|
|
87
|
+
style: ViewPropTypes.style,
|
|
88
|
+
theme: themeType,
|
|
88
89
|
variant: string
|
|
89
90
|
};
|
|
90
91
|
|
|
@@ -38,9 +38,9 @@ const baseButtonTheme = theme => ({
|
|
|
38
38
|
|
|
39
39
|
const variantsColorTheme = (theme, colorTheme, variant) => {
|
|
40
40
|
const actionColorName = COLORS_MAPPER[colorTheme] || COLORS_MAPPER[DEFAULT_PROPS.colorTheme];
|
|
41
|
-
const actionTheme = theme.Palette
|
|
42
|
-
const negativeTheme = theme.Palette
|
|
43
|
-
const neutralTheme = theme.Palette
|
|
41
|
+
const actionTheme = theme.Palette[actionColorName];
|
|
42
|
+
const negativeTheme = theme.Palette[COLORS_MAPPER.negative];
|
|
43
|
+
const neutralTheme = theme.Palette[COLORS_MAPPER.secondary];
|
|
44
44
|
const shadow = getShadow(ELEVATION);
|
|
45
45
|
const pressedShadow = getShadow(PRESSED_ELEVATION);
|
|
46
46
|
|
|
@@ -195,7 +195,7 @@ const iconButtonPlacementTheme = iconPlacement => {
|
|
|
195
195
|
return definition[iconPlacement] || {};
|
|
196
196
|
};
|
|
197
197
|
|
|
198
|
-
export const retrieveStyle = ({
|
|
198
|
+
export const retrieveStyle = ({ style = {}, colorTheme, variant, theme, size, iconPlacement }) => {
|
|
199
199
|
const baseTheme = baseButtonTheme(theme);
|
|
200
200
|
const variantTheme = variantsColorTheme(theme, colorTheme, variant);
|
|
201
201
|
const sizeTheme = sizeButtonTheme(size);
|
|
@@ -205,7 +205,7 @@ export const retrieveStyle = ({ classNames = {}, colorTheme, variant, theme, siz
|
|
|
205
205
|
...baseTheme.button,
|
|
206
206
|
...variantTheme.button,
|
|
207
207
|
...sizeTheme.button,
|
|
208
|
-
...
|
|
208
|
+
...style.root
|
|
209
209
|
};
|
|
210
210
|
|
|
211
211
|
const textStyles = {
|
|
@@ -215,11 +215,11 @@ export const retrieveStyle = ({ classNames = {}, colorTheme, variant, theme, siz
|
|
|
215
215
|
};
|
|
216
216
|
|
|
217
217
|
const iconStyles = {
|
|
218
|
-
icon: { ...baseTheme.icon, ...sizeTheme.icon, ...iconPlacementTheme, ...
|
|
219
|
-
iconOnly: { ...baseTheme.iconOnly, ...sizeTheme.iconOnly, ...
|
|
218
|
+
icon: { ...baseTheme.icon, ...sizeTheme.icon, ...iconPlacementTheme, ...style.icon },
|
|
219
|
+
iconOnly: { ...baseTheme.iconOnly, ...sizeTheme.iconOnly, ...style.icon }
|
|
220
220
|
};
|
|
221
221
|
|
|
222
|
-
const childrenContainerStyles = { ...baseTheme.childrenContainer, ...
|
|
222
|
+
const childrenContainerStyles = { ...baseTheme.childrenContainer, ...style.childrenContainer };
|
|
223
223
|
|
|
224
224
|
const { disabled } = variantTheme;
|
|
225
225
|
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
/* eslint-disable react/no-children-prop */
|
|
2
1
|
import React from 'react';
|
|
2
|
+
import { any, bool, func, objectOf, string } from 'prop-types';
|
|
3
3
|
import { Text } from 'react-native';
|
|
4
|
+
import { ViewPropTypes } from 'deprecated-react-native-prop-types';
|
|
4
5
|
import Markdown from 'react-native-markdown-display';
|
|
5
|
-
import { any, bool, func, object, objectOf, string } from 'prop-types';
|
|
6
6
|
|
|
7
7
|
import { themeType, withTheme } from '../../theming';
|
|
8
8
|
|
|
9
9
|
import { DEFAULT_PROPS } from './constants';
|
|
10
|
-
import { retrieveStyle } from './theme';
|
|
11
10
|
import { markdownFormat } from './utils';
|
|
11
|
+
import { retrieveStyle } from './theme';
|
|
12
12
|
|
|
13
13
|
const UTLabel = ({
|
|
14
14
|
children,
|
|
15
|
-
className,
|
|
16
15
|
colorTheme,
|
|
17
16
|
field,
|
|
18
17
|
markdownRenderers,
|
|
19
18
|
shade,
|
|
19
|
+
style,
|
|
20
20
|
theme,
|
|
21
21
|
variant,
|
|
22
22
|
weight,
|
|
@@ -25,7 +25,7 @@ const UTLabel = ({
|
|
|
25
25
|
if (!children) return null;
|
|
26
26
|
|
|
27
27
|
const themeStyles = retrieveStyle({ colorTheme, field, shade, theme, variant, weight });
|
|
28
|
-
const labelStyles = [themeStyles,
|
|
28
|
+
const labelStyles = [themeStyles, style];
|
|
29
29
|
|
|
30
30
|
const LabelRenderer = withMarkdown ? Markdown : Text;
|
|
31
31
|
|
|
@@ -39,13 +39,12 @@ const UTLabel = ({
|
|
|
39
39
|
UTLabel.defaultProps = DEFAULT_PROPS;
|
|
40
40
|
|
|
41
41
|
UTLabel.propTypes = {
|
|
42
|
-
// eslint-disable-next-line react/forbid-prop-types
|
|
43
|
-
className: object,
|
|
44
42
|
colorTheme: string,
|
|
45
43
|
// eslint-disable-next-line react/forbid-prop-types
|
|
46
44
|
field: any,
|
|
47
45
|
markdownRenderers: objectOf(func),
|
|
48
46
|
shade: string,
|
|
47
|
+
style: ViewPropTypes.style,
|
|
49
48
|
theme: themeType,
|
|
50
49
|
variant: string,
|
|
51
50
|
weight: string,
|
|
@@ -8,8 +8,7 @@ const getDefaultColorShade = colorTheme =>
|
|
|
8
8
|
: SHADES.shade05;
|
|
9
9
|
|
|
10
10
|
const variantsColorTheme = (colorTheme, shade, theme) => {
|
|
11
|
-
const colorThemeDefinition =
|
|
12
|
-
theme.Palette[colorTheme] || theme.Palette.actions[colorTheme] || theme.Palette[DEFAULT_PROPS.colorTheme];
|
|
11
|
+
const colorThemeDefinition = theme.Palette[colorTheme] || theme.Palette[DEFAULT_PROPS.colorTheme];
|
|
13
12
|
const colorShade = Object.values(SHADES).includes(shade) ? shade : getDefaultColorShade(colorTheme);
|
|
14
13
|
return colorThemeDefinition[colorShade] || '#000';
|
|
15
14
|
};
|
|
@@ -6,7 +6,7 @@ import isEmpty from 'lodash/isEmpty';
|
|
|
6
6
|
|
|
7
7
|
import ImageIcon from '../ImageIcon';
|
|
8
8
|
import { useTheme } from '../../theming';
|
|
9
|
-
import
|
|
9
|
+
import UTLabel from '../UTLabel';
|
|
10
10
|
|
|
11
11
|
import { leftSectionComponents } from './utils';
|
|
12
12
|
import QuantitySelector from './components/QuantitySelector';
|
|
@@ -18,9 +18,12 @@ const UTProductItem = ({
|
|
|
18
18
|
additionalInfo,
|
|
19
19
|
amount,
|
|
20
20
|
counter,
|
|
21
|
+
counterLabelProps = {},
|
|
21
22
|
discount,
|
|
22
23
|
imageProps,
|
|
23
24
|
previousAmount,
|
|
25
|
+
quantity,
|
|
26
|
+
quantityLabelProps = {},
|
|
24
27
|
secondaryAction,
|
|
25
28
|
selectedQuantity,
|
|
26
29
|
style,
|
|
@@ -50,9 +53,22 @@ const UTProductItem = ({
|
|
|
50
53
|
</View>
|
|
51
54
|
<View style={[themedStyles.rightSection, !isEmpty(counter) && themedStyles.spaceBetween]}>
|
|
52
55
|
{!isEmpty(counter) && (
|
|
53
|
-
<
|
|
56
|
+
<UTLabel
|
|
57
|
+
variant="small"
|
|
58
|
+
className={themedStyles.counter}
|
|
59
|
+
{...counterLabelProps}
|
|
60
|
+
>{`${counter.current}/${counter.limit}`}</UTLabel>
|
|
54
61
|
)}
|
|
55
|
-
<
|
|
62
|
+
<View style={themedStyles.quantitiesContainer}>
|
|
63
|
+
{quantity && (
|
|
64
|
+
<View style={themedStyles.quantityContainer}>
|
|
65
|
+
<UTLabel colorTheme="light" variant="subtitle1" {...quantityLabelProps}>
|
|
66
|
+
{quantity}
|
|
67
|
+
</UTLabel>
|
|
68
|
+
</View>
|
|
69
|
+
)}
|
|
70
|
+
<QuantitySelector {...{ action, secondaryAction, selectedQuantity, themedStyles }} />
|
|
71
|
+
</View>
|
|
56
72
|
</View>
|
|
57
73
|
</View>
|
|
58
74
|
);
|
|
@@ -63,9 +79,12 @@ UTProductItem.propTypes = {
|
|
|
63
79
|
additionalInfo: string,
|
|
64
80
|
amount: number,
|
|
65
81
|
counter: shape({ current: number, limit: number }),
|
|
82
|
+
counterLabelProps: shape({}),
|
|
66
83
|
discount: number,
|
|
67
84
|
imageProps: shape({ image: oneOf([string, element]), withUri: bool }),
|
|
68
85
|
previousAmount: number,
|
|
86
|
+
quantity: number,
|
|
87
|
+
quantityLabelProps: shape({}),
|
|
69
88
|
secondaryAction: ActionPropTypes,
|
|
70
89
|
selectedQuantity: number,
|
|
71
90
|
title: string
|
|
@@ -27,6 +27,7 @@ export const getUTProductItemStyles = (theme = {}) =>
|
|
|
27
27
|
},
|
|
28
28
|
counter: {
|
|
29
29
|
backgroundColor: theme.counterBackground || '#EBF8FD',
|
|
30
|
+
overflow: 'hidden',
|
|
30
31
|
borderRadius: 4,
|
|
31
32
|
color: theme.counterColor || '#035B83',
|
|
32
33
|
paddingHorizontal: 8,
|
|
@@ -51,18 +52,29 @@ export const getUTProductItemStyles = (theme = {}) =>
|
|
|
51
52
|
},
|
|
52
53
|
leftSection: {
|
|
53
54
|
alignItems: 'center',
|
|
54
|
-
|
|
55
|
+
flexGrow: 1,
|
|
55
56
|
flexDirection: 'row'
|
|
56
57
|
},
|
|
57
58
|
mainInfo: {
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
flexGrow: 1,
|
|
60
|
+
flexBasis: 160
|
|
60
61
|
},
|
|
61
62
|
previousAmount: {
|
|
62
63
|
color: theme.previousAmountColor || 'gray',
|
|
63
64
|
textDecorationLine: 'line-through',
|
|
64
65
|
textDecorationStyle: 'solid'
|
|
65
66
|
},
|
|
67
|
+
quantitiesContainer: {
|
|
68
|
+
flexDirection: 'row',
|
|
69
|
+
alignItems: 'center'
|
|
70
|
+
},
|
|
71
|
+
quantityContainer: {
|
|
72
|
+
backgroundColor: theme.quantityBackground || 'darkblue',
|
|
73
|
+
paddingHorizontal: 8,
|
|
74
|
+
paddingVertical: 4,
|
|
75
|
+
borderRadius: 4,
|
|
76
|
+
marginRight: 12
|
|
77
|
+
},
|
|
66
78
|
rightSection: {
|
|
67
79
|
alignItems: 'flex-end',
|
|
68
80
|
display: 'flex',
|
package/lib/index.js
CHANGED
|
@@ -65,6 +65,7 @@ export { default as UTLoading } from './components/UTLoading';
|
|
|
65
65
|
// Text
|
|
66
66
|
export { default as Label } from './components/Label';
|
|
67
67
|
export { default as UTLabel } from './components/UTLabel';
|
|
68
|
+
export { default as UTBadge } from './components/UTBadge';
|
|
68
69
|
export { default as TransitionText } from './components/TransitionText';
|
|
69
70
|
// Theming
|
|
70
71
|
export * from './theming';
|
|
@@ -34,44 +34,6 @@ const colors = {
|
|
|
34
34
|
semanticSuccess05: '#245702'
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
-
const actions = {
|
|
38
|
-
accent: {
|
|
39
|
-
'01': colors.actionAccent01,
|
|
40
|
-
'02': colors.actionAccent02,
|
|
41
|
-
'03': colors.actionAccent03,
|
|
42
|
-
'04': colors.actionAccent04,
|
|
43
|
-
'05': colors.actionAccent05
|
|
44
|
-
},
|
|
45
|
-
neutral: {
|
|
46
|
-
'01': colors.actionNeutral01,
|
|
47
|
-
'02': colors.actionNeutral02,
|
|
48
|
-
'03': colors.actionNeutral03,
|
|
49
|
-
'04': colors.actionNeutral04,
|
|
50
|
-
'05': colors.actionNeutral05
|
|
51
|
-
},
|
|
52
|
-
error: {
|
|
53
|
-
'01': colors.actionError01,
|
|
54
|
-
'02': colors.actionError02,
|
|
55
|
-
'03': colors.actionError03,
|
|
56
|
-
'04': colors.actionError04,
|
|
57
|
-
'05': colors.actionError05
|
|
58
|
-
},
|
|
59
|
-
success: {
|
|
60
|
-
'01': colors.semanticSuccess01,
|
|
61
|
-
'02': colors.semanticSuccess02,
|
|
62
|
-
'03': colors.semanticSuccess03,
|
|
63
|
-
'04': colors.semanticSuccess04,
|
|
64
|
-
'05': colors.semanticSuccess05
|
|
65
|
-
},
|
|
66
|
-
negative: {
|
|
67
|
-
'01': colors.actionNegative01,
|
|
68
|
-
'02': colors.actionNegative02,
|
|
69
|
-
'03': colors.actionNegative03,
|
|
70
|
-
'04': colors.actionNegative04,
|
|
71
|
-
'05': colors.actionNegative05
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
37
|
const DefaultTheme = {
|
|
76
38
|
alert: {
|
|
77
39
|
info: '#0065A3',
|
|
@@ -206,20 +168,6 @@ const DefaultTheme = {
|
|
|
206
168
|
'04': '#E7E7E7',
|
|
207
169
|
'05': '#C9C9C9'
|
|
208
170
|
},
|
|
209
|
-
success: {
|
|
210
|
-
'01': '#EEF9E6',
|
|
211
|
-
'02': '#D3F0C0',
|
|
212
|
-
'03': '#80D249',
|
|
213
|
-
'04': '#3F8411',
|
|
214
|
-
'05': '#245702'
|
|
215
|
-
},
|
|
216
|
-
error: {
|
|
217
|
-
'01': '#FFF0EB',
|
|
218
|
-
'02': '#FED9CE',
|
|
219
|
-
'03': '#FD906F',
|
|
220
|
-
'04': '#D03607',
|
|
221
|
-
'05': '#852001'
|
|
222
|
-
},
|
|
223
171
|
warning: {
|
|
224
172
|
'01': '#FFF9E6',
|
|
225
173
|
'02': '#FFEFC1',
|
|
@@ -234,7 +182,41 @@ const DefaultTheme = {
|
|
|
234
182
|
'04': '#037C96',
|
|
235
183
|
'05': '#025F73'
|
|
236
184
|
},
|
|
237
|
-
|
|
185
|
+
accent: {
|
|
186
|
+
'01': colors.actionAccent01,
|
|
187
|
+
'02': colors.actionAccent02,
|
|
188
|
+
'03': colors.actionAccent03,
|
|
189
|
+
'04': colors.actionAccent04,
|
|
190
|
+
'05': colors.actionAccent05
|
|
191
|
+
},
|
|
192
|
+
neutral: {
|
|
193
|
+
'01': colors.actionNeutral01,
|
|
194
|
+
'02': colors.actionNeutral02,
|
|
195
|
+
'03': colors.actionNeutral03,
|
|
196
|
+
'04': colors.actionNeutral04,
|
|
197
|
+
'05': colors.actionNeutral05
|
|
198
|
+
},
|
|
199
|
+
error: {
|
|
200
|
+
'01': colors.actionError01,
|
|
201
|
+
'02': colors.actionError02,
|
|
202
|
+
'03': colors.actionError03,
|
|
203
|
+
'04': colors.actionError04,
|
|
204
|
+
'05': colors.actionError05
|
|
205
|
+
},
|
|
206
|
+
success: {
|
|
207
|
+
'01': colors.semanticSuccess01,
|
|
208
|
+
'02': colors.semanticSuccess02,
|
|
209
|
+
'03': colors.semanticSuccess03,
|
|
210
|
+
'04': colors.semanticSuccess04,
|
|
211
|
+
'05': colors.semanticSuccess05
|
|
212
|
+
},
|
|
213
|
+
negative: {
|
|
214
|
+
'01': colors.actionNegative01,
|
|
215
|
+
'02': colors.actionNegative02,
|
|
216
|
+
'03': colors.actionNegative03,
|
|
217
|
+
'04': colors.actionNegative04,
|
|
218
|
+
'05': colors.actionNegative05
|
|
219
|
+
}
|
|
238
220
|
}
|
|
239
221
|
};
|
|
240
222
|
|
|
@@ -47,21 +47,8 @@ export const getCustomStyles = (variants, props, styles, stylePrefix = '') =>
|
|
|
47
47
|
.map(variant => (props[variant] ? styles[`${variant}${stylePrefix}`] : null))
|
|
48
48
|
.filter(style => style !== null);
|
|
49
49
|
|
|
50
|
-
export const mergeClasses = (themeClasses, classNames) => {
|
|
51
|
-
if (!classNames) return themeClasses;
|
|
52
|
-
const classes = {};
|
|
53
|
-
const allClassNames = [...Object.keys(classNames), ...Object.keys(themeClasses)];
|
|
54
|
-
|
|
55
|
-
allClassNames.forEach(name => {
|
|
56
|
-
classes[name] = `${themeClasses[name] || ''} ${classNames[name] || ''}`.trim();
|
|
57
|
-
});
|
|
58
|
-
|
|
59
|
-
return classes;
|
|
60
|
-
};
|
|
61
|
-
|
|
62
50
|
export default {
|
|
63
51
|
calculateShadow,
|
|
64
52
|
generateLayoutMeasuresObject,
|
|
65
|
-
getCustomStyles
|
|
66
|
-
mergeClasses
|
|
53
|
+
getCustomStyles
|
|
67
54
|
};
|
package/package.json
CHANGED