@widergy/mobile-ui 1.25.0 → 1.26.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.
- package/CHANGELOG.md +14 -0
- package/lib/components/UTButtonGroup/README.md +1 -1
- package/lib/components/UTButtonGroup/index.js +7 -2
- package/lib/components/UTIcon/README.md +12 -9
- package/lib/components/UTIcon/index.js +32 -5
- package/lib/components/UTIcon/styles.js +34 -0
- package/lib/components/UTIcon/utils.js +29 -5
- package/lib/components/UTTextInput/versions/V0/flavors/OutlinedInput/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,17 @@
|
|
|
1
|
+
# [1.26.0](https://github.com/widergy/mobile-ui/compare/v1.25.1...v1.26.0) (2024-09-25)
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
### Features
|
|
5
|
+
|
|
6
|
+
* ut icon updates ([#358](https://github.com/widergy/mobile-ui/issues/358)) ([30af561](https://github.com/widergy/mobile-ui/commit/30af5617d47e62ccbba7bf175a3a5127e0f5db7e))
|
|
7
|
+
|
|
8
|
+
## [1.25.1](https://github.com/widergy/mobile-ui/compare/v1.25.0...v1.25.1) (2024-09-23)
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* type prop name changed ([#359](https://github.com/widergy/mobile-ui/issues/359)) ([f1644bd](https://github.com/widergy/mobile-ui/commit/f1644bdf762dafc5e5e6831693f7e6fdb8c83ab1))
|
|
14
|
+
|
|
1
15
|
# [1.25.0](https://github.com/widergy/mobile-ui/compare/v1.24.1...v1.25.0) (2024-09-19)
|
|
2
16
|
|
|
3
17
|
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
| ------------ | :---------------- | ----------- | ---------------------------------------------------------------------------------------- |
|
|
8
8
|
| actions | array | | Array of actions to render. Each action must include:`Icon`, `id` and `onPress` props. |
|
|
9
9
|
| colorTheme | string | 'primary' | The color theme to use. One of:`primary`, `secondary`, `negative`. |
|
|
10
|
-
|
|
|
10
|
+
| shape | string | 'square' | Type of the button. One of:`square`, `circle`. |
|
|
11
11
|
| selected | string / number | | Id of the active button. |
|
|
@@ -9,7 +9,12 @@ import UTButton from '../UTButton';
|
|
|
9
9
|
import { BACKGROUND_COLOR_MAPPER, DEFAULT_COLOR_THEME, DEFAULT_TYPE } from './constants';
|
|
10
10
|
import { getTypeStyles, ownStyles } from './styles';
|
|
11
11
|
|
|
12
|
-
const UTButtonGroup = ({
|
|
12
|
+
const UTButtonGroup = ({
|
|
13
|
+
actions,
|
|
14
|
+
colorTheme = DEFAULT_COLOR_THEME,
|
|
15
|
+
selected,
|
|
16
|
+
shape: type = DEFAULT_TYPE
|
|
17
|
+
}) => {
|
|
13
18
|
const theme = useTheme();
|
|
14
19
|
const backgroundColor =
|
|
15
20
|
BACKGROUND_COLOR_MAPPER(theme)[colorTheme] || BACKGROUND_COLOR_MAPPER(theme).primary;
|
|
@@ -49,7 +54,7 @@ UTButtonGroup.propTypes = {
|
|
|
49
54
|
).isRequired,
|
|
50
55
|
colorTheme: string,
|
|
51
56
|
selected: oneOfType([number, string]).isRequired,
|
|
52
|
-
|
|
57
|
+
shape: string
|
|
53
58
|
};
|
|
54
59
|
|
|
55
60
|
export default UTButtonGroup;
|
|
@@ -13,14 +13,17 @@ For a comprehensive list of available icons and their design specifications, ref
|
|
|
13
13
|
|
|
14
14
|
## Props
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
|
18
|
-
|
|
|
19
|
-
|
|
|
20
|
-
|
|
|
21
|
-
|
|
|
22
|
-
|
|
|
23
|
-
|
|
|
16
|
+
|
|
17
|
+
| Name | Type | Default | Description |
|
|
18
|
+
| :----------- | --------- | ----------- | ----------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
|
+
| area | boolean | false | Padding around the icon is added when it is true. |
|
|
20
|
+
| colorTheme | string | 'dark' | The icon color, must be from the theme palette. |
|
|
21
|
+
| fillTheme | string | | The internal fill color must be from the theme palette. |
|
|
22
|
+
| name | string | | The name of the icon from the Tabler Icons library. |
|
|
23
|
+
| shade | string | | The shade of the color theme to use. |
|
|
24
|
+
| size | number | | The size of the icon. |
|
|
25
|
+
| style | object | | Custom styles to apply to the icon. |
|
|
26
|
+
| variant | string | 'default' | It depends on the `area` property and defines whether it should be displayed filled (`default`) or just with a border (`outlined`) around the icon. |
|
|
24
27
|
|
|
25
28
|
## Icon Names
|
|
26
29
|
|
|
@@ -97,7 +100,7 @@ Clarifications:
|
|
|
97
100
|
|
|
98
101
|
- Note that not all icons look good with an internal fill color.
|
|
99
102
|
|
|
100
|
-
## Fill Shade
|
|
103
|
+
## Fill Shade (optional)
|
|
101
104
|
|
|
102
105
|
The `fillShade` prop must be one of these:
|
|
103
106
|
|
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { number, object, oneOfType, string } from 'prop-types';
|
|
2
|
+
import { bool, number, object, oneOfType, string } from 'prop-types';
|
|
3
|
+
import { View } from 'react-native';
|
|
3
4
|
import * as TablerIcons from '@tabler/icons-react-native';
|
|
4
5
|
|
|
5
6
|
import { useTheme } from '../../theming';
|
|
6
7
|
|
|
7
8
|
import { ENERGY_ICONS } from './constants';
|
|
8
|
-
import { getIconProps } from './utils';
|
|
9
|
+
import { getIconProps, getVariantStyle } from './utils';
|
|
10
|
+
import ownStyles from './styles';
|
|
9
11
|
|
|
10
|
-
const UTIcon = ({
|
|
12
|
+
const UTIcon = ({
|
|
13
|
+
area,
|
|
14
|
+
color,
|
|
15
|
+
colorTheme = 'dark',
|
|
16
|
+
fillShade,
|
|
17
|
+
fillTheme,
|
|
18
|
+
name,
|
|
19
|
+
shade,
|
|
20
|
+
size,
|
|
21
|
+
style,
|
|
22
|
+
variant = 'default'
|
|
23
|
+
}) => {
|
|
11
24
|
const theme = useTheme();
|
|
12
25
|
|
|
13
26
|
const IconComponent = ENERGY_ICONS[name] || TablerIcons[name];
|
|
@@ -25,10 +38,23 @@ const UTIcon = ({ color, colorTheme = 'dark', fillShade, fillTheme, name, shade,
|
|
|
25
38
|
theme
|
|
26
39
|
});
|
|
27
40
|
|
|
28
|
-
return
|
|
41
|
+
return (
|
|
42
|
+
<View
|
|
43
|
+
style={
|
|
44
|
+
area && [
|
|
45
|
+
ownStyles.withArea,
|
|
46
|
+
ownStyles[`size${size}`],
|
|
47
|
+
getVariantStyle({ color: colorTheme || color, shade, theme, variant })
|
|
48
|
+
]
|
|
49
|
+
}
|
|
50
|
+
>
|
|
51
|
+
<IconComponent {...iconProps} />
|
|
52
|
+
</View>
|
|
53
|
+
);
|
|
29
54
|
};
|
|
30
55
|
|
|
31
56
|
UTIcon.propTypes = {
|
|
57
|
+
area: bool,
|
|
32
58
|
/**
|
|
33
59
|
* @deprecated The "color" prop is deprecated and will be removed in a future release. Please use "colorTheme" instead.
|
|
34
60
|
*/
|
|
@@ -39,7 +65,8 @@ UTIcon.propTypes = {
|
|
|
39
65
|
name: string,
|
|
40
66
|
shade: string,
|
|
41
67
|
size: oneOfType([number, string]),
|
|
42
|
-
style: object
|
|
68
|
+
style: object,
|
|
69
|
+
variant: string
|
|
43
70
|
};
|
|
44
71
|
|
|
45
72
|
export default UTIcon;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native';
|
|
2
|
+
|
|
3
|
+
const paddingSmall = 2;
|
|
4
|
+
const paddingMedium = 4;
|
|
5
|
+
const paddingLarge = 10;
|
|
6
|
+
const paddingXlarge = 12;
|
|
7
|
+
const paddingXxlarge = 21;
|
|
8
|
+
|
|
9
|
+
const generateSizeStyles = () => {
|
|
10
|
+
const sizes = [
|
|
11
|
+
{ range: [0, 23], padding: paddingSmall },
|
|
12
|
+
{ range: [24, 27], padding: paddingMedium },
|
|
13
|
+
{ range: [28, 31], padding: paddingLarge },
|
|
14
|
+
{ range: [32, 55], padding: paddingXlarge },
|
|
15
|
+
{ range: [56, 100], padding: paddingXxlarge }
|
|
16
|
+
];
|
|
17
|
+
|
|
18
|
+
return sizes.reduce((styles, { range, padding }) => {
|
|
19
|
+
const [start, end] = range;
|
|
20
|
+
const sizeStyles = Array.from({ length: end - start + 1 }, (_, i) => i + start).reduce(
|
|
21
|
+
(acc, size) => ({ ...acc, [`size${size}`]: { padding } }),
|
|
22
|
+
{}
|
|
23
|
+
);
|
|
24
|
+
return { ...styles, ...sizeStyles };
|
|
25
|
+
}, {});
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
export default StyleSheet.create({
|
|
29
|
+
withArea: {
|
|
30
|
+
backgroundColor: 'transparent',
|
|
31
|
+
borderRadius: 100
|
|
32
|
+
},
|
|
33
|
+
...generateSizeStyles()
|
|
34
|
+
});
|
|
@@ -4,15 +4,15 @@ import { retrieveColor } from './theme';
|
|
|
4
4
|
export const isUTIcon = icon => typeof icon === 'string';
|
|
5
5
|
|
|
6
6
|
export const getIconProps = ({
|
|
7
|
-
name,
|
|
8
|
-
theme,
|
|
9
7
|
color,
|
|
10
8
|
colorTheme,
|
|
11
|
-
shade,
|
|
12
|
-
fillTheme,
|
|
13
9
|
fillShade,
|
|
10
|
+
fillTheme,
|
|
11
|
+
name,
|
|
12
|
+
shade,
|
|
14
13
|
size,
|
|
15
|
-
style
|
|
14
|
+
style,
|
|
15
|
+
theme
|
|
16
16
|
}) => {
|
|
17
17
|
const themeColor = retrieveColor({ colorTheme: color || colorTheme, theme, shade });
|
|
18
18
|
const filled = name.endsWith('Filled');
|
|
@@ -34,3 +34,27 @@ export const getIconProps = ({
|
|
|
34
34
|
...(isEnergyIcon || isBrandIcon ? customIconProps : defaultIconProps)
|
|
35
35
|
};
|
|
36
36
|
};
|
|
37
|
+
|
|
38
|
+
export const getVariantStyle = ({ color, shade, theme, variant }) => {
|
|
39
|
+
const borderColor = retrieveColor({ colorTheme: color, theme, shade });
|
|
40
|
+
|
|
41
|
+
const defaultBackgrounds = {
|
|
42
|
+
accent: theme.Palette.actions?.accent['01'] || theme.Palette.accent['01'],
|
|
43
|
+
dark: theme.Palette.light['03'],
|
|
44
|
+
error: theme.Palette.error['01'],
|
|
45
|
+
gray: theme.Palette.light['03'],
|
|
46
|
+
information: theme.Palette.information['01'],
|
|
47
|
+
light: theme.Palette.light['03'],
|
|
48
|
+
negative: theme.Palette.actions?.negative['01'] || theme.Palette.negative['01'],
|
|
49
|
+
neutral: theme.Palette.actions?.neutral['01'] || theme.Palette.neutral['01'],
|
|
50
|
+
success: theme.Palette.success['01'],
|
|
51
|
+
warning: theme.Palette.warning['01']
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
const variantStyles = {
|
|
55
|
+
default: { backgroundColor: defaultBackgrounds[color] },
|
|
56
|
+
outlined: { borderColor, borderWidth: 2 }
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
return variantStyles[variant];
|
|
60
|
+
};
|
package/package.json
CHANGED