@momo-kits/progress-info 0.169.4 → 0.169.6

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.
@@ -1,12 +1,13 @@
1
- import React, {FC} from 'react';
2
- import {FlexAlignType, View} from 'react-native';
3
- import {ProgressInfoItem, ProgressInfoProps} from './types';
4
- import {Colors, Spacing, Text} from '@momo-kits/foundation';
1
+ import React, { FC } from 'react';
2
+ import { FlexAlignType, View } from 'react-native';
3
+ import { ProgressInfoItem, ProgressInfoProps } from './types';
4
+ import { Colors, Spacing, Text } from '@momo-kits/foundation';
5
5
  import styles from './styles';
6
6
  import ProgressInfoIcon from './ProgressInfoIcon';
7
7
 
8
8
  type TextAlign = 'left' | 'right' | 'center';
9
9
 
10
+ /** Progress steps in a row: marker with connectors, title and description. */
10
11
  const ProgressInfoHorizontal: FC<ProgressInfoProps> = ({
11
12
  steps,
12
13
  size,
@@ -17,7 +18,7 @@ const ProgressInfoHorizontal: FC<ProgressInfoProps> = ({
17
18
  customIcon,
18
19
  }) => {
19
20
  const renderProgressItem = (i: ProgressInfoItem, ii: number) => {
20
- const {title, description} = steps[ii];
21
+ const { title, description } = steps[ii];
21
22
 
22
23
  let alignItems: FlexAlignType = 'center';
23
24
  let textAlign: TextAlign = 'center';
@@ -38,9 +39,9 @@ const ProgressInfoHorizontal: FC<ProgressInfoProps> = ({
38
39
  }
39
40
  }
40
41
 
41
- const haveMarginRight =
42
- ii !== steps.length - 1 && align !== 'center' && align !== 'stretch';
43
- const marginRight = haveMarginRight ? Spacing.XS : 0;
42
+ const isLastStep = ii === steps.length - 1;
43
+ const isEdgeAlign = align !== 'center' && align !== 'stretch';
44
+ const marginRight = !isLastStep && isEdgeAlign ? Spacing.XS : 0;
44
45
 
45
46
  return (
46
47
  <View
@@ -51,20 +52,23 @@ const ProgressInfoHorizontal: FC<ProgressInfoProps> = ({
51
52
  alignItems,
52
53
  marginRight,
53
54
  },
54
- ]}>
55
+ ]}
56
+ >
55
57
  {renderStepIcon(i, ii, align)}
56
58
  {!!title && showTitle && (
57
59
  <Text
58
- style={[styles.title, {textAlign}]}
59
- typography={'header_xs_semibold'}>
60
+ style={[styles.title, { textAlign }]}
61
+ typography={'header_xs_semibold'}
62
+ >
60
63
  {title}
61
64
  </Text>
62
65
  )}
63
66
  {!!description && showDescription && (
64
67
  <Text
65
- style={{textAlign}}
68
+ style={{ textAlign }}
66
69
  color={Colors.black_12}
67
- typography={'description_default_regular'}>
70
+ typography={'description_default_regular'}
71
+ >
68
72
  {description}
69
73
  </Text>
70
74
  )}
@@ -74,13 +78,12 @@ const ProgressInfoHorizontal: FC<ProgressInfoProps> = ({
74
78
  const renderStepIcon = (
75
79
  i: ProgressInfoItem,
76
80
  ii: number,
77
- stepAlign: string = 'center'
81
+ stepAlign: string = 'center',
78
82
  ) => {
79
- const lineLeftHide =
80
- (stepAlign === 'stretch' && ii === 0) || stepAlign === 'left';
81
- const lineRightHide =
82
- (stepAlign === 'stretch' && ii === steps.length - 1) ||
83
- stepAlign === 'right';
83
+ const isStretch = stepAlign === 'stretch';
84
+ const isLastStep = ii === steps.length - 1;
85
+ const lineLeftHide = (isStretch && ii === 0) || stepAlign === 'left';
86
+ const lineRightHide = (isStretch && isLastStep) || stepAlign === 'right';
84
87
 
85
88
  return (
86
89
  <View style={styles.rowStep}>
@@ -10,6 +10,7 @@ import { StyleSheet, View, ViewStyle } from 'react-native';
10
10
  import styles from './styles';
11
11
  import { ProgressInfoItemIcon } from './types';
12
12
 
13
+ /** Step marker showing the step number, a custom icon or a dot. */
13
14
  const ProgressInfoIcon: FC<ProgressInfoItemIcon> = ({
14
15
  size = 'large',
15
16
  backgroundColor,
@@ -40,7 +41,6 @@ const ProgressInfoIcon: FC<ProgressInfoItemIcon> = ({
40
41
  }
41
42
 
42
43
  const renderIcon = () => {
43
- // useNumber is true, render number
44
44
  if (useNumber) {
45
45
  return (
46
46
  <Text
@@ -53,7 +53,6 @@ const ProgressInfoIcon: FC<ProgressInfoItemIcon> = ({
53
53
  );
54
54
  }
55
55
 
56
- // customIcon is true, render customIcon
57
56
  if (customIcon) {
58
57
  return (
59
58
  <Icon
@@ -63,12 +62,7 @@ const ProgressInfoIcon: FC<ProgressInfoItemIcon> = ({
63
62
  />
64
63
  );
65
64
  }
66
- // render default Icon
67
- return (
68
- <View
69
- style={[styles.currIcon, { width: contentIconSize }]}
70
- />
71
- );
65
+ return <View style={[styles.currIcon, { width: contentIconSize }]} />;
72
66
  };
73
67
 
74
68
  return (
@@ -1,10 +1,11 @@
1
- import React, {FC, useContext} from 'react';
2
- import {View} from 'react-native';
3
- import {ProgressInfoItem, ProgressInfoProps} from './types';
4
- import {ApplicationContext, Colors, Text} from '@momo-kits/foundation';
1
+ import React, { FC, useContext } from 'react';
2
+ import { View } from 'react-native';
3
+ import { ProgressInfoItem, ProgressInfoProps } from './types';
4
+ import { ApplicationContext, Colors, Text } from '@momo-kits/foundation';
5
5
  import ProgressInfoIcon from './ProgressInfoIcon';
6
6
  import styles from './styles';
7
7
 
8
+ /** Progress steps in a column: marker and connector, title, description. */
8
9
  const ProgressInfoVertical: FC<ProgressInfoProps> = ({
9
10
  steps,
10
11
  size,
@@ -13,10 +14,10 @@ const ProgressInfoVertical: FC<ProgressInfoProps> = ({
13
14
  showTitle = true,
14
15
  customIcon,
15
16
  }) => {
16
- const {theme} = useContext(ApplicationContext);
17
+ const { theme } = useContext(ApplicationContext);
17
18
 
18
19
  const renderStepItem = (i: ProgressInfoItem, ii: number) => {
19
- const {description, title} = steps[ii];
20
+ const { description, title } = steps[ii];
20
21
 
21
22
  const lineColor = theme.colors.primary + '33';
22
23
 
@@ -32,7 +33,9 @@ const ProgressInfoVertical: FC<ProgressInfoProps> = ({
32
33
  index={ii}
33
34
  />
34
35
  {ii !== steps.length - 1 && (
35
- <View style={[styles.lineVertical, {backgroundColor: lineColor}]} />
36
+ <View
37
+ style={[styles.lineVertical, { backgroundColor: lineColor }]}
38
+ />
36
39
  )}
37
40
  </View>
38
41
  <View style={styles.flex1}>
@@ -41,7 +44,8 @@ const ProgressInfoVertical: FC<ProgressInfoProps> = ({
41
44
  <Text
42
45
  numberOfLines={2}
43
46
  style={styles.verticalTitle}
44
- typography={'header_xs_semibold'}>
47
+ typography={'header_xs_semibold'}
48
+ >
45
49
  {title}
46
50
  </Text>
47
51
  )}
@@ -49,7 +53,8 @@ const ProgressInfoVertical: FC<ProgressInfoProps> = ({
49
53
  {showDescription && (
50
54
  <Text
51
55
  color={Colors.black_12}
52
- typography={'description_default_regular'}>
56
+ typography={'description_default_regular'}
57
+ >
53
58
  {description}
54
59
  </Text>
55
60
  )}
package/index.tsx CHANGED
@@ -1,8 +1,9 @@
1
- import React, {FC} from 'react';
2
- import {ProgressInfoItem, ProgressInfoProps} from './types';
1
+ import React, { FC } from 'react';
2
+ import { ProgressInfoItem, ProgressInfoProps } from './types';
3
3
  import ProgressInfoHorizontal from './ProgressInfoHorizontal';
4
4
  import ProgressInfoVertical from './ProgressInfoVertical';
5
5
 
6
+ /** Read-only step guide; renders the horizontal or vertical layout. */
6
7
  const ProgressInfo: FC<ProgressInfoProps> = ({
7
8
  horizontal = false,
8
9
  ...props
@@ -18,5 +19,5 @@ const ProgressInfo: FC<ProgressInfoProps> = ({
18
19
  );
19
20
  };
20
21
 
21
- export {ProgressInfo};
22
- export type {ProgressInfoProps, ProgressInfoItem};
22
+ export { ProgressInfo };
23
+ export type { ProgressInfoProps, ProgressInfoItem };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@momo-kits/progress-info",
3
- "version": "0.169.4",
3
+ "version": "0.169.6",
4
4
  "private": false,
5
5
  "main": "index.tsx",
6
6
  "dependencies": {},
package/types.ts CHANGED
@@ -1,4 +1,4 @@
1
- import {ViewStyle} from 'react-native';
1
+ import { ViewStyle } from 'react-native';
2
2
 
3
3
  export type ProgressInfoItem = {
4
4
  /**
@@ -14,8 +14,8 @@ export type ProgressInfoItem = {
14
14
  };
15
15
 
16
16
  /**
17
- * Properties for the StepIcon component, which displays an icon
18
- * representing a step within the Steps component.
17
+ * Properties for the ProgressInfoIcon component, which displays the marker
18
+ * of a step within the ProgressInfo component.
19
19
  */
20
20
  export type ProgressInfoItemIcon = {
21
21
  /**
@@ -36,7 +36,7 @@ export type ProgressInfoItemIcon = {
36
36
  borderColor?: string;
37
37
 
38
38
  /**
39
- * Optional. Custom styles to apply to the StepIcon component.
39
+ * Optional. Custom styles to apply to the ProgressInfoIcon component.
40
40
  * Can be used to adjust the visual presentation or layout.
41
41
  */
42
42
  style?: ViewStyle;