@widergy/mobile-ui 1.23.2 → 1.24.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 CHANGED
@@ -1,3 +1,17 @@
1
+ ## [1.24.1](https://github.com/widergy/mobile-ui/compare/v1.24.0...v1.24.1) (2024-09-17)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * rounded progress utworkflow ([#357](https://github.com/widergy/mobile-ui/issues/357)) ([2518e3e](https://github.com/widergy/mobile-ui/commit/2518e3ea23a39652662c1c069592c5e4a55d4198))
7
+
8
+ # [1.24.0](https://github.com/widergy/mobile-ui/compare/v1.23.2...v1.24.0) (2024-09-17)
9
+
10
+
11
+ ### Features
12
+
13
+ * ut button group ([#356](https://github.com/widergy/mobile-ui/issues/356)) ([ebdb6a2](https://github.com/widergy/mobile-ui/commit/ebdb6a2d69ee182f2a1794aa7bb55eea6ce8e261))
14
+
1
15
  ## [1.23.2](https://github.com/widergy/mobile-ui/compare/v1.23.1...v1.23.2) (2024-09-12)
2
16
 
3
17
 
@@ -0,0 +1,11 @@
1
+ # UTButton
2
+
3
+ ## Props
4
+
5
+
6
+ | Name | Type | Default | Description |
7
+ | ------------ | :---------------- | ----------- | ---------------------------------------------------------------------------------------- |
8
+ | actions | array | | Array of actions to render. Each action must include:`Icon`, `id` and `onPress` props. |
9
+ | colorTheme | string | 'primary' | The color theme to use. One of:`primary`, `secondary`, `negative`. |
10
+ | type | string | 'square' | Type of the button. One of:`square`, `circle`. |
11
+ | selected | string / number | | Id of the active button. |
@@ -0,0 +1,18 @@
1
+ export const BACKGROUND_COLOR_MAPPER = theme => {
2
+ const negativeTheme = theme.Palette.negative;
3
+ const lightTheme = theme.Palette.light;
4
+
5
+ const lightBackground = { backgroundColor: lightTheme['03'] };
6
+ const negativeBackground = { backgroundColor: negativeTheme['02'] };
7
+
8
+ return {
9
+ primary: lightBackground,
10
+ negative: negativeBackground,
11
+ neutral: lightBackground
12
+ };
13
+ };
14
+
15
+ export const CIRCLE_TYPE = 'circle';
16
+ export const SQUARE_TYPE = 'square';
17
+ export const DEFAULT_TYPE = SQUARE_TYPE;
18
+ export const DEFAULT_COLOR_THEME = 'primary';
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import { View } from 'react-native';
3
+ import { arrayOf, element, func, number, oneOfType, shape, string } from 'prop-types';
4
+
5
+ import { useTheme } from '../../theming';
6
+ import { mergeMultipleStyles } from '../../utils/styleUtils';
7
+ import UTButton from '../UTButton';
8
+
9
+ import { BACKGROUND_COLOR_MAPPER, DEFAULT_COLOR_THEME, DEFAULT_TYPE } from './constants';
10
+ import { getTypeStyles, ownStyles } from './styles';
11
+
12
+ const UTButtonGroup = ({ actions, colorTheme = DEFAULT_COLOR_THEME, selected, type = DEFAULT_TYPE }) => {
13
+ const theme = useTheme();
14
+ const backgroundColor =
15
+ BACKGROUND_COLOR_MAPPER(theme)[colorTheme] || BACKGROUND_COLOR_MAPPER(theme).primary;
16
+ const themedStyles = mergeMultipleStyles(ownStyles, getTypeStyles(type), theme?.UTButtonGroup);
17
+
18
+ return (
19
+ <View style={[themedStyles.container, backgroundColor]}>
20
+ {actions.map(({ Icon, id, onPress }, index) => (
21
+ <UTButton
22
+ colorTheme={colorTheme}
23
+ Icon={Icon}
24
+ key={id}
25
+ onPress={onPress}
26
+ size="large"
27
+ style={{
28
+ root: {
29
+ ...themedStyles.buttonRoot,
30
+ ...(index === 0 ? themedStyles.firstButton : {}),
31
+ ...(index === actions.length - 1 ? themedStyles.lastButton : {}),
32
+ ...themedStyles.button
33
+ }
34
+ }}
35
+ variant={selected === id ? 'filled' : 'text'}
36
+ />
37
+ ))}
38
+ </View>
39
+ );
40
+ };
41
+
42
+ UTButtonGroup.propTypes = {
43
+ actions: arrayOf(
44
+ shape({
45
+ Icon: oneOfType([string, element]),
46
+ id: oneOfType([number, string]),
47
+ onClick: func
48
+ })
49
+ ).isRequired,
50
+ colorTheme: string,
51
+ selected: oneOfType([number, string]).isRequired,
52
+ type: string
53
+ };
54
+
55
+ export default UTButtonGroup;
@@ -0,0 +1,41 @@
1
+ import { StyleSheet } from 'react-native';
2
+
3
+ import { CIRCLE_TYPE, SQUARE_TYPE } from './constants';
4
+
5
+ const BORDER_RADIUS_DEFAULT = 8;
6
+ const BORDER_RADIUS_SQUARE = BORDER_RADIUS_DEFAULT - 1;
7
+ const BORDER_RADIUS_ROUNDED = 100;
8
+
9
+ export const getTypeStyles = type =>
10
+ ({
11
+ [CIRCLE_TYPE]: {
12
+ container: {
13
+ borderRadius: BORDER_RADIUS_ROUNDED
14
+ },
15
+ button: {
16
+ borderRadius: BORDER_RADIUS_ROUNDED
17
+ }
18
+ },
19
+ [SQUARE_TYPE]: {
20
+ container: {
21
+ borderRadius: BORDER_RADIUS_DEFAULT
22
+ },
23
+ firstButton: {
24
+ borderTopLeftRadius: BORDER_RADIUS_SQUARE,
25
+ borderBottomLeftRadius: BORDER_RADIUS_SQUARE
26
+ },
27
+ lastButton: {
28
+ borderTopRightRadius: BORDER_RADIUS_SQUARE,
29
+ borderBottomRightRadius: BORDER_RADIUS_SQUARE
30
+ }
31
+ }
32
+ })[type];
33
+
34
+ export const ownStyles = StyleSheet.create({
35
+ container: {
36
+ flexDirection: 'row'
37
+ },
38
+ buttonRoot: {
39
+ borderRadius: 0
40
+ }
41
+ });
@@ -61,6 +61,10 @@ const UTTopbar = ({
61
61
  styles={{
62
62
  barContainer: {
63
63
  height: BAR_HEIGHT
64
+ },
65
+ progressBar: {
66
+ borderTopRightRadius: currentStep === stepsCount ? 0 : 4,
67
+ borderBottomRightRadius: currentStep === stepsCount ? 0 : 4
64
68
  }
65
69
  }}
66
70
  />
package/lib/index.js CHANGED
@@ -39,6 +39,7 @@ export { default as UTAutocomplete } from './components/UTAutocomplete';
39
39
  export { default as UTBadge } from './components/UTBadge';
40
40
  export { default as UTBottomSheet } from './components/UTBottomSheet';
41
41
  export { default as UTButton } from './components/UTButton';
42
+ export { default as UTButtonGroup } from './components/UTButtonGroup';
42
43
  export { default as UTCBUInput } from './components/UTCBUInput';
43
44
  export { default as UTCheckBox } from './components/UTCheckBox';
44
45
  export { default as UTCheckList } from './components/UTCheckList';
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.23.2",
5
+ "version": "1.24.1",
6
6
  "repository": "https://github.com/widergy/mobile-ui.git",
7
7
  "main": "lib/index.js",
8
8
  "files": [