@jobber/components-native 0.54.4 → 0.55.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/Banner/Banner.js +32 -11
- package/dist/src/Banner/Banner.style.js +13 -11
- package/dist/src/Banner/components/BannerIcon/BannerIcon.js +4 -5
- package/dist/src/Banner/components/BannerIcon/BannerIcon.style.js +17 -0
- package/dist/src/TextList/TextList.style.js +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/Banner/Banner.style.d.ts +12 -10
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.d.ts +4 -2
- package/dist/types/src/Banner/components/BannerIcon/BannerIcon.style.d.ts +15 -0
- package/dist/types/src/Banner/types.d.ts +2 -2
- package/dist/types/src/TextList/TextList.style.d.ts +1 -1
- package/package.json +2 -2
- package/src/Banner/Banner.style.ts +13 -11
- package/src/Banner/Banner.test.tsx +144 -36
- package/src/Banner/Banner.tsx +57 -20
- package/src/Banner/components/BannerIcon/BannerIcon.style.ts +18 -0
- package/src/Banner/components/BannerIcon/BannerIcon.tsx +8 -6
- package/src/Banner/types.ts +2 -2
- package/src/TextList/TextList.style.ts +1 -1
- package/src/TextList/__snapshots__/TextList.test.tsx.snap +1 -1
- package/dist/src/Banner/constants.js +0 -12
- package/dist/types/src/Banner/constants.d.ts +0 -2
- package/src/Banner/constants.ts +0 -14
package/dist/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.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": "825421391c3feb7c30550303949e6f6f0c36535a"
|
|
88
88
|
}
|
|
@@ -1,30 +1,51 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Pressable, View } from "react-native";
|
|
3
|
-
import { BannerTypeStyles } from "./constants";
|
|
2
|
+
import { Pressable, Text as RNText, View } from "react-native";
|
|
4
3
|
import { styles } from "./Banner.style";
|
|
5
4
|
import { BannerIcon } from "./components/BannerIcon/BannerIcon";
|
|
6
5
|
import { Content } from "../Content";
|
|
7
6
|
import { Text } from "../Text";
|
|
8
7
|
import { TextList } from "../TextList";
|
|
9
8
|
import { ActionLabel } from "../ActionLabel";
|
|
9
|
+
import { Typography } from "../Typography";
|
|
10
10
|
export function Banner({ action, details, text, type, children, icon, }) {
|
|
11
|
-
|
|
11
|
+
const bannerIcon = icon || getBannerIcon(type);
|
|
12
|
+
const shouldFlow = Boolean(React.Children.count(children) === 1 && !text && !details) ||
|
|
13
|
+
Boolean(text && !details && !children);
|
|
14
|
+
return (React.createElement(Pressable, { style: [styles.container], accessibilityRole: "alert", onPress: action === null || action === void 0 ? void 0 : action.onPress },
|
|
12
15
|
React.createElement(Content, { childSpacing: "small" },
|
|
13
16
|
React.createElement(View, { style: styles.bannerContent },
|
|
14
|
-
|
|
17
|
+
bannerIcon && React.createElement(BannerIcon, { icon: bannerIcon, type: type }),
|
|
15
18
|
React.createElement(View, { style: styles.contentContainer },
|
|
16
19
|
React.createElement(View, { style: styles.childrenContainer },
|
|
17
|
-
React.createElement(
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
React.createElement(WrappingElement, { shouldFlow: shouldFlow },
|
|
21
|
+
React.createElement(BannerChildren, null, children),
|
|
22
|
+
text && React.createElement(Text, { level: "text" }, text),
|
|
23
|
+
details && React.createElement(TextList, { items: details, level: "text" }),
|
|
24
|
+
action && (React.createElement(RNText, null,
|
|
25
|
+
shouldFlow && React.createElement(Typography, { color: "subdued" }, " | "),
|
|
26
|
+
React.createElement(ActionLabel, { align: "start" }, action.label))))))))));
|
|
22
27
|
}
|
|
23
|
-
function BannerChildren({ children
|
|
28
|
+
function BannerChildren({ children }) {
|
|
24
29
|
if (!children)
|
|
25
30
|
return React.createElement(React.Fragment, null);
|
|
26
31
|
if (children && typeof children === "string") {
|
|
27
|
-
return React.createElement(Text, { level: "
|
|
32
|
+
return React.createElement(Text, { level: "text" }, children);
|
|
28
33
|
}
|
|
29
34
|
return React.createElement(React.Fragment, null, children);
|
|
30
35
|
}
|
|
36
|
+
function WrappingElement({ shouldFlow, children, }) {
|
|
37
|
+
if (shouldFlow) {
|
|
38
|
+
return React.createElement(RNText, { testID: "ATL-Banner-RNText" }, children);
|
|
39
|
+
}
|
|
40
|
+
return (React.createElement(View, { testID: "ATL-Banner-View", style: styles.contentSpacing }, children));
|
|
41
|
+
}
|
|
42
|
+
function getBannerIcon(type) {
|
|
43
|
+
switch (type) {
|
|
44
|
+
case "notice":
|
|
45
|
+
return "starburst";
|
|
46
|
+
case "warning":
|
|
47
|
+
return "help";
|
|
48
|
+
case "error":
|
|
49
|
+
return "alert";
|
|
50
|
+
}
|
|
51
|
+
}
|
|
@@ -3,19 +3,15 @@ import { tokens } from "../utils/design";
|
|
|
3
3
|
export const styles = StyleSheet.create({
|
|
4
4
|
container: {
|
|
5
5
|
width: "100%",
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
warning: {
|
|
11
|
-
backgroundColor: tokens["color-warning--surface"],
|
|
12
|
-
},
|
|
13
|
-
notice: {
|
|
14
|
-
backgroundColor: tokens["color-informative--surface"],
|
|
6
|
+
borderColor: tokens["color-border"],
|
|
7
|
+
borderStyle: "solid",
|
|
8
|
+
borderBottomWidth: tokens["border-base"],
|
|
9
|
+
backgroundColor: tokens["color-surface"],
|
|
15
10
|
},
|
|
16
11
|
bannerContent: {
|
|
17
12
|
flexDirection: "row",
|
|
18
13
|
alignItems: "flex-start",
|
|
14
|
+
gap: tokens["space-small"] + tokens["space-smaller"],
|
|
19
15
|
},
|
|
20
16
|
contentContainer: {
|
|
21
17
|
flex: 1,
|
|
@@ -26,7 +22,13 @@ export const styles = StyleSheet.create({
|
|
|
26
22
|
textContainer: {
|
|
27
23
|
marginTop: tokens["space-minuscule"],
|
|
28
24
|
},
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
fullWidth: {
|
|
26
|
+
width: "100%",
|
|
27
|
+
},
|
|
28
|
+
bannerChildrenContent: {
|
|
29
|
+
marginBottom: tokens["space-small"],
|
|
30
|
+
},
|
|
31
|
+
contentSpacing: {
|
|
32
|
+
gap: tokens["space-small"],
|
|
31
33
|
},
|
|
32
34
|
});
|
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { tokens } from "@jobber/design";
|
|
3
2
|
import { View } from "react-native";
|
|
3
|
+
import { styles } from "./BannerIcon.style";
|
|
4
4
|
import { Icon } from "../../../Icon";
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
React.createElement(Icon, { name: icon, customColor: tokens["color-text"] })));
|
|
5
|
+
export function BannerIcon({ icon, type }) {
|
|
6
|
+
return (React.createElement(View, { style: [styles.bannerIcon, styles[type]], testID: "ATL-Banner-Icon" },
|
|
7
|
+
React.createElement(Icon, { name: icon, color: "white", size: "small" })));
|
|
9
8
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../../../utils/design";
|
|
3
|
+
export const styles = StyleSheet.create({
|
|
4
|
+
bannerIcon: {
|
|
5
|
+
borderRadius: tokens["radius-circle"],
|
|
6
|
+
padding: tokens["space-smaller"],
|
|
7
|
+
},
|
|
8
|
+
error: {
|
|
9
|
+
backgroundColor: tokens["color-destructive"],
|
|
10
|
+
},
|
|
11
|
+
warning: {
|
|
12
|
+
backgroundColor: tokens["color-warning"],
|
|
13
|
+
},
|
|
14
|
+
notice: {
|
|
15
|
+
backgroundColor: tokens["color-informative"],
|
|
16
|
+
},
|
|
17
|
+
});
|