@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.54.4",
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": "4780cde621bb770d24f6bd324ee868b302afc579"
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
- return (React.createElement(Pressable, { style: [styles.container, BannerTypeStyles[type].styles], accessibilityRole: "alert", onPress: action === null || action === void 0 ? void 0 : action.onPress },
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
- icon && React.createElement(BannerIcon, { icon: icon }),
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(BannerChildren, null, children)),
18
- text && (React.createElement(View, { style: styles.textContainer },
19
- React.createElement(Text, { level: "textSupporting" }, text))),
20
- details && React.createElement(TextList, { items: details, level: "textSupporting" }))),
21
- action && React.createElement(ActionLabel, { align: "start" }, action.label))));
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: "textSupporting" }, children);
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
- error: {
8
- backgroundColor: tokens["color-critical--surface"],
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
- bannerIcon: {
30
- paddingRight: tokens["space-small"],
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
- import { styles } from "../../Banner.style";
6
- export function BannerIcon({ icon }) {
7
- return (React.createElement(View, { style: styles.bannerIcon },
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
+ });
@@ -2,8 +2,8 @@ import { StyleSheet } from "react-native";
2
2
  import { tokens } from "../utils/design";
3
3
  export const styles = StyleSheet.create({
4
4
  details: {
5
+ width: "100%",
5
6
  flexDirection: "column",
6
- marginTop: tokens["space-small"],
7
7
  },
8
8
  detail: {
9
9
  flexDirection: "row",