@widergy/mobile-ui 1.25.1 → 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 CHANGED
@@ -1,3 +1,10 @@
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
+
1
8
  ## [1.25.1](https://github.com/widergy/mobile-ui/compare/v1.25.0...v1.25.1) (2024-09-23)
2
9
 
3
10
 
@@ -13,14 +13,17 @@ For a comprehensive list of available icons and their design specifications, ref
13
13
 
14
14
  ## Props
15
15
 
16
- | Name | Type | Default | Description |
17
- | ---------- | ------ | ------- | ------------------------------------------------------- |
18
- | colorTheme | string | 'dark' | The icon color, must be from the theme palette. |
19
- | fillTheme | string | | The internal fill color must be from the theme palette. |
20
- | name | string | | The name of the icon from the Tabler Icons library. |
21
- | shade | string | | The shade of the color theme to use. |
22
- | size | number | | The size of the icon. |
23
- | style | object | | Custom styles to apply to the icon. |
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 (opcional)
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 = ({ color, colorTheme = 'dark', fillShade, fillTheme, name, shade, size, style }) => {
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 <IconComponent {...iconProps} />;
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
+ };
@@ -81,7 +81,7 @@ const OutlinedInput = ({
81
81
  : focused
82
82
  ? 2
83
83
  : disabled
84
- ? (themeStyles?.inactive?.disabledBorderWidth ?? 1)
84
+ ? themeStyles?.inactive?.disabledBorderWidth ?? 1
85
85
  : 1,
86
86
  borderColor: active ? activeColor : inactiveColor
87
87
  },
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@widergy/mobile-ui",
3
3
  "description": "Widergy Mobile Components",
4
4
  "author": "widergy",
5
- "version": "1.25.1",
5
+ "version": "1.26.0",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [