@jobber/components-native 0.50.0 → 0.51.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/dist/package.json +2 -2
- package/dist/src/ProgressBar/ProgressBar.js +4 -3
- package/dist/src/ProgressBar/ProgressBar.style.js +13 -0
- package/dist/src/ProgressBar/ProgressBarStepped.js +21 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/ProgressBar/ProgressBar.d.ts +1 -1
- package/dist/types/src/ProgressBar/ProgressBar.style.d.ts +13 -0
- package/dist/types/src/ProgressBar/ProgressBarStepped.d.ts +10 -0
- package/dist/types/src/ProgressBar/types.d.ts +7 -1
- package/package.json +2 -2
- package/src/ProgressBar/ProgressBar.style.ts +13 -0
- package/src/ProgressBar/ProgressBar.test.tsx +40 -1
- package/src/ProgressBar/ProgressBar.tsx +35 -21
- package/src/ProgressBar/ProgressBarStepped.tsx +47 -0
- package/src/ProgressBar/types.ts +8 -1
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
"react-native-reanimated": "^2.17.0",
|
|
85
85
|
"react-native-safe-area-context": "^4.5.2"
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "7096004da05ede6fff2bfaaed572b3e91a9ee1d9"
|
|
88
88
|
}
|
|
@@ -2,17 +2,18 @@ import React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { styles } from "./ProgressBar.style";
|
|
4
4
|
import { ProgressBarInner, calculateWidth } from "./ProgressBarInner";
|
|
5
|
+
import { ProgressBarStepped } from "./ProgressBarStepped";
|
|
5
6
|
import { tokens } from "../utils/design";
|
|
6
7
|
import { useAtlantisI18n } from "../hooks/useAtlantisI18n";
|
|
7
|
-
export function ProgressBar({ loading, total, current, inProgress = 0, reverseTheme = false, header, }) {
|
|
8
|
+
export function ProgressBar({ loading, total, current, inProgress = 0, reverseTheme = false, header, variation = "progress", }) {
|
|
8
9
|
const { t } = useAtlantisI18n();
|
|
9
10
|
return (React.createElement(View, { accessible: true, accessibilityRole: "progressbar", accessibilityLabel: getA11yLabel() },
|
|
10
11
|
header,
|
|
11
|
-
React.createElement(View, { style: styles.progressBarContainer },
|
|
12
|
+
variation === "stepped" ? (React.createElement(ProgressBarStepped, { total: total, current: current, color: reverseTheme ? undefined : tokens["color-surface--background"], loading: loading, inProgress: inProgress })) : (React.createElement(View, { style: styles.progressBarContainer },
|
|
12
13
|
React.createElement(ProgressBarInner, { width: 100, animationDuration: 0, color: reverseTheme ? undefined : tokens["color-surface--background"] }),
|
|
13
14
|
!loading && (React.createElement(React.Fragment, null,
|
|
14
15
|
inProgress && inProgress > 0 ? (React.createElement(ProgressBarInner, { width: calculateWidth(total, current + inProgress), color: tokens["color-informative"], animationDuration: 800 })) : (React.createElement(React.Fragment, null)),
|
|
15
|
-
React.createElement(ProgressBarInner, { width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600 }))))));
|
|
16
|
+
React.createElement(ProgressBarInner, { width: calculateWidth(total, current), color: tokens["color-interactive"], animationDuration: 600 })))))));
|
|
16
17
|
function getA11yLabel() {
|
|
17
18
|
const a11yLabelValues = {
|
|
18
19
|
current: String(current),
|
|
@@ -21,4 +21,17 @@ export const styles = StyleSheet.create({
|
|
|
21
21
|
height: "100%",
|
|
22
22
|
borderRadius: 100,
|
|
23
23
|
},
|
|
24
|
+
step: {
|
|
25
|
+
flex: 1,
|
|
26
|
+
marginRight: tokens["space-small"],
|
|
27
|
+
height: "100%",
|
|
28
|
+
borderRadius: 100,
|
|
29
|
+
borderColor: "rgba(255,255,255,0.3)",
|
|
30
|
+
},
|
|
31
|
+
completedStep: {
|
|
32
|
+
backgroundColor: tokens["color-interactive"],
|
|
33
|
+
},
|
|
34
|
+
inProgressStep: {
|
|
35
|
+
backgroundColor: tokens["color-informative"],
|
|
36
|
+
},
|
|
24
37
|
});
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { styles } from "./ProgressBar.style";
|
|
4
|
+
export function ProgressBarStepped({ total, current, color, loading, inProgress, }) {
|
|
5
|
+
return (React.createElement(View, { style: [styles.progressBarContainer, { height: 10 }] }, Array.from({ length: total }).map((_, index) => {
|
|
6
|
+
const step = index + 1;
|
|
7
|
+
const isCompleted = step <= current;
|
|
8
|
+
const lastStep = step === total;
|
|
9
|
+
const inProgressSteps = current + (inProgress || 0);
|
|
10
|
+
return (React.createElement(View, { key: step, style: [
|
|
11
|
+
styles.step,
|
|
12
|
+
Object.assign({}, (color && { backgroundColor: color })),
|
|
13
|
+
!loading && isCompleted && styles.completedStep,
|
|
14
|
+
!loading &&
|
|
15
|
+
!isCompleted &&
|
|
16
|
+
step <= inProgressSteps &&
|
|
17
|
+
styles.inProgressStep,
|
|
18
|
+
lastStep && { marginRight: 0 },
|
|
19
|
+
], testID: "progress-step" }));
|
|
20
|
+
})));
|
|
21
|
+
}
|