@jobber/components-native 0.84.3 → 0.84.4-match-mobi-55ef4ec.7
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/StatusIndicator/StatusIndicator.js +11 -0
- package/dist/src/StatusIndicator/StatusIndicator.style.js +12 -0
- package/dist/src/StatusIndicator/StatusIndicator.type.js +1 -0
- package/dist/src/StatusIndicator/index.js +1 -0
- package/dist/src/StatusLabel/StatusLabel.js +6 -12
- package/dist/src/StatusLabel/StatusLabel.style.js +9 -13
- package/dist/src/index.js +1 -0
- package/dist/src/utils/meta/meta.json +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/StatusIndicator/StatusIndicator.d.ts +6 -0
- package/dist/types/src/StatusIndicator/StatusIndicator.style.d.ts +8 -0
- package/dist/types/src/StatusIndicator/StatusIndicator.type.d.ts +1 -0
- package/dist/types/src/StatusIndicator/index.d.ts +2 -0
- package/dist/types/src/StatusLabel/StatusLabel.d.ts +3 -3
- package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +9 -10
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/StatusIndicator/StatusIndicator.style.ts +14 -0
- package/src/StatusIndicator/StatusIndicator.test.tsx +42 -0
- package/src/StatusIndicator/StatusIndicator.tsx +23 -0
- package/src/StatusIndicator/StatusIndicator.type.ts +6 -0
- package/src/StatusIndicator/__snapshots__/StatusIndicator.test.tsx.snap +96 -0
- package/src/StatusIndicator/index.ts +2 -0
- package/src/StatusLabel/StatusLabel.style.ts +9 -16
- package/src/StatusLabel/StatusLabel.tsx +15 -28
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +126 -105
- package/src/index.ts +1 -0
- package/src/utils/meta/meta.json +1 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { StatusIndicatorType } from "./StatusIndicator.type";
|
|
3
|
+
export interface StatusIndicatorProps {
|
|
4
|
+
readonly status: StatusIndicatorType;
|
|
5
|
+
}
|
|
6
|
+
export declare function StatusIndicator({ status }: StatusIndicatorProps): React.JSX.Element;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type StatusIndicatorType = "success" | "warning" | "critical" | "inactive" | "informative";
|
|
@@ -5,15 +5,15 @@ export interface StatusLabelType {
|
|
|
5
5
|
}
|
|
6
6
|
interface StatusLabelProps {
|
|
7
7
|
/**
|
|
8
|
-
* Text to display
|
|
8
|
+
* Text to display
|
|
9
9
|
*/
|
|
10
10
|
readonly text: string;
|
|
11
11
|
/**
|
|
12
|
-
* Alignment of text
|
|
12
|
+
* Alignment of text and StatusIndicator
|
|
13
13
|
*/
|
|
14
14
|
readonly alignment?: "start" | "end";
|
|
15
15
|
/**
|
|
16
|
-
* Status color of
|
|
16
|
+
* Status color of label container, label, and StatusIndicator
|
|
17
17
|
*/
|
|
18
18
|
readonly status?: StatusType;
|
|
19
19
|
}
|
|
@@ -2,22 +2,21 @@ export declare const useStyles: () => {
|
|
|
2
2
|
statusLabelRow: {
|
|
3
3
|
flexDirection: "row";
|
|
4
4
|
justifyContent: "flex-end";
|
|
5
|
+
alignItems: "center";
|
|
5
6
|
flexWrap: "nowrap";
|
|
7
|
+
flexGrow: number;
|
|
8
|
+
flexShrink: number;
|
|
9
|
+
gap: number;
|
|
10
|
+
backgroundColor: string;
|
|
11
|
+
borderRadius: number;
|
|
12
|
+
paddingVertical: number;
|
|
13
|
+
paddingHorizontal: number;
|
|
6
14
|
};
|
|
7
15
|
statusLabelText: {
|
|
8
16
|
flexShrink: number;
|
|
9
|
-
|
|
10
|
-
statusLabelIcon: {
|
|
11
|
-
borderRadius: number;
|
|
12
|
-
backgroundColor: string;
|
|
13
|
-
width: number;
|
|
14
|
-
height: number;
|
|
15
|
-
marginTop: number;
|
|
17
|
+
marginBottom: number;
|
|
16
18
|
};
|
|
17
19
|
labelTextStartAligned: {
|
|
18
20
|
flexDirection: "row-reverse";
|
|
19
21
|
};
|
|
20
|
-
innerPad: {
|
|
21
|
-
width: number;
|
|
22
|
-
};
|
|
23
22
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.84.
|
|
3
|
+
"version": "0.84.4-match-mobi-55ef4ec.7+55ef4ec91",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -85,5 +85,5 @@
|
|
|
85
85
|
"react-native-safe-area-context": "^5.4.0",
|
|
86
86
|
"react-native-svg": ">=12.0.0"
|
|
87
87
|
},
|
|
88
|
-
"gitHead": "
|
|
88
|
+
"gitHead": "55ef4ec916758fd15610ded5298d293958e665fa"
|
|
89
89
|
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
2
|
+
|
|
3
|
+
export const useStyles = buildThemedStyles(tokens => {
|
|
4
|
+
const statusIndicatorDiameter = 8;
|
|
5
|
+
|
|
6
|
+
return {
|
|
7
|
+
statusIndicator: {
|
|
8
|
+
borderRadius: tokens["radius-circle"],
|
|
9
|
+
backgroundColor: tokens["color-success"],
|
|
10
|
+
width: statusIndicatorDiameter,
|
|
11
|
+
height: statusIndicatorDiameter,
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
});
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
import { StatusIndicator } from "./StatusIndicator";
|
|
4
|
+
|
|
5
|
+
describe("StatusIndicator", () => {
|
|
6
|
+
describe("status", () => {
|
|
7
|
+
describe('when status prop set to default ("success")', () => {
|
|
8
|
+
it("should match snapshot", () => {
|
|
9
|
+
const view = render(<StatusIndicator status="success" />).toJSON();
|
|
10
|
+
expect(view).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('when status prop set to "warning"', () => {
|
|
15
|
+
it("should match snapshot", () => {
|
|
16
|
+
const view = render(<StatusIndicator status="warning" />).toJSON();
|
|
17
|
+
expect(view).toMatchSnapshot();
|
|
18
|
+
});
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
describe('when status prop set to "critical"', () => {
|
|
22
|
+
it("should match snapshot", () => {
|
|
23
|
+
const view = render(<StatusIndicator status="critical" />).toJSON();
|
|
24
|
+
expect(view).toMatchSnapshot();
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
describe('when status prop set to "inactive"', () => {
|
|
29
|
+
it("should match snapshot", () => {
|
|
30
|
+
const view = render(<StatusIndicator status="inactive" />).toJSON();
|
|
31
|
+
expect(view).toMatchSnapshot();
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
describe('when status prop set to "informative"', () => {
|
|
36
|
+
it("should match snapshot", () => {
|
|
37
|
+
const view = render(<StatusIndicator status="informative" />).toJSON();
|
|
38
|
+
expect(view).toMatchSnapshot();
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { useStyles } from "./StatusIndicator.style";
|
|
4
|
+
import type { StatusIndicatorType } from "./StatusIndicator.type";
|
|
5
|
+
import { tokens } from "../utils/design";
|
|
6
|
+
|
|
7
|
+
export interface StatusIndicatorProps {
|
|
8
|
+
readonly status: StatusIndicatorType;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function StatusIndicator({ status }: StatusIndicatorProps) {
|
|
12
|
+
const styles = useStyles();
|
|
13
|
+
|
|
14
|
+
return (
|
|
15
|
+
<View
|
|
16
|
+
testID={`${status}Indicator`}
|
|
17
|
+
style={[
|
|
18
|
+
styles.statusIndicator,
|
|
19
|
+
{ backgroundColor: tokens[`color-${status}`] },
|
|
20
|
+
]}
|
|
21
|
+
/>
|
|
22
|
+
);
|
|
23
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
|
2
|
+
|
|
3
|
+
exports[`StatusIndicator status when status prop set to "critical" should match snapshot 1`] = `
|
|
4
|
+
<View
|
|
5
|
+
style={
|
|
6
|
+
[
|
|
7
|
+
{
|
|
8
|
+
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
9
|
+
"borderRadius": 100,
|
|
10
|
+
"height": 8,
|
|
11
|
+
"width": 8,
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
"backgroundColor": "hsl(6, 64%, 51%)",
|
|
15
|
+
},
|
|
16
|
+
]
|
|
17
|
+
}
|
|
18
|
+
testID="criticalIndicator"
|
|
19
|
+
/>
|
|
20
|
+
`;
|
|
21
|
+
|
|
22
|
+
exports[`StatusIndicator status when status prop set to "inactive" should match snapshot 1`] = `
|
|
23
|
+
<View
|
|
24
|
+
style={
|
|
25
|
+
[
|
|
26
|
+
{
|
|
27
|
+
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
28
|
+
"borderRadius": 100,
|
|
29
|
+
"height": 8,
|
|
30
|
+
"width": 8,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"backgroundColor": "hsl(198, 25%, 33%)",
|
|
34
|
+
},
|
|
35
|
+
]
|
|
36
|
+
}
|
|
37
|
+
testID="inactiveIndicator"
|
|
38
|
+
/>
|
|
39
|
+
`;
|
|
40
|
+
|
|
41
|
+
exports[`StatusIndicator status when status prop set to "informative" should match snapshot 1`] = `
|
|
42
|
+
<View
|
|
43
|
+
style={
|
|
44
|
+
[
|
|
45
|
+
{
|
|
46
|
+
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
47
|
+
"borderRadius": 100,
|
|
48
|
+
"height": 8,
|
|
49
|
+
"width": 8,
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
"backgroundColor": "hsl(207, 79%, 57%)",
|
|
53
|
+
},
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
testID="informativeIndicator"
|
|
57
|
+
/>
|
|
58
|
+
`;
|
|
59
|
+
|
|
60
|
+
exports[`StatusIndicator status when status prop set to "warning" should match snapshot 1`] = `
|
|
61
|
+
<View
|
|
62
|
+
style={
|
|
63
|
+
[
|
|
64
|
+
{
|
|
65
|
+
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
66
|
+
"borderRadius": 100,
|
|
67
|
+
"height": 8,
|
|
68
|
+
"width": 8,
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
"backgroundColor": "hsl(51, 64%, 49%)",
|
|
72
|
+
},
|
|
73
|
+
]
|
|
74
|
+
}
|
|
75
|
+
testID="warningIndicator"
|
|
76
|
+
/>
|
|
77
|
+
`;
|
|
78
|
+
|
|
79
|
+
exports[`StatusIndicator status when status prop set to default ("success") should match snapshot 1`] = `
|
|
80
|
+
<View
|
|
81
|
+
style={
|
|
82
|
+
[
|
|
83
|
+
{
|
|
84
|
+
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
85
|
+
"borderRadius": 100,
|
|
86
|
+
"height": 8,
|
|
87
|
+
"width": 8,
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"backgroundColor": "hsl(107, 58%, 33%)",
|
|
91
|
+
},
|
|
92
|
+
]
|
|
93
|
+
}
|
|
94
|
+
testID="successIndicator"
|
|
95
|
+
/>
|
|
96
|
+
`;
|
|
@@ -1,33 +1,26 @@
|
|
|
1
1
|
import { buildThemedStyles } from "../AtlantisThemeContext";
|
|
2
2
|
|
|
3
|
-
const statusLabelRadius = 3; // Needs to be hardcoded to 3 as this shouldn't change with the tokens
|
|
4
|
-
|
|
5
3
|
export const useStyles = buildThemedStyles(tokens => {
|
|
6
|
-
const statusLabelIconDiameter =
|
|
7
|
-
tokens["space-base"] - tokens["space-smaller"]; //12px
|
|
8
|
-
const indicatorOffset = tokens["space-smallest"] + tokens["space-minuscule"];
|
|
9
|
-
|
|
10
4
|
return {
|
|
11
5
|
statusLabelRow: {
|
|
12
6
|
flexDirection: "row",
|
|
13
7
|
justifyContent: "flex-end",
|
|
8
|
+
alignItems: "center",
|
|
14
9
|
flexWrap: "nowrap",
|
|
10
|
+
flexGrow: 0,
|
|
11
|
+
flexShrink: 1,
|
|
12
|
+
gap: tokens["space-smaller"],
|
|
13
|
+
backgroundColor: tokens["color-success--surface"],
|
|
14
|
+
borderRadius: tokens["radius-large"],
|
|
15
|
+
paddingVertical: tokens["space-smaller"],
|
|
16
|
+
paddingHorizontal: tokens["space-small"],
|
|
15
17
|
},
|
|
16
18
|
statusLabelText: {
|
|
17
19
|
flexShrink: 1,
|
|
18
|
-
|
|
19
|
-
statusLabelIcon: {
|
|
20
|
-
borderRadius: statusLabelRadius,
|
|
21
|
-
backgroundColor: tokens["color-success"],
|
|
22
|
-
width: statusLabelIconDiameter,
|
|
23
|
-
height: statusLabelIconDiameter,
|
|
24
|
-
marginTop: indicatorOffset,
|
|
20
|
+
marginBottom: -1,
|
|
25
21
|
},
|
|
26
22
|
labelTextStartAligned: {
|
|
27
23
|
flexDirection: "row-reverse",
|
|
28
24
|
},
|
|
29
|
-
innerPad: {
|
|
30
|
-
width: tokens["space-small"],
|
|
31
|
-
},
|
|
32
25
|
};
|
|
33
26
|
});
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { useStyles } from "./StatusLabel.style";
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
4
|
+
import { Typography } from "../Typography";
|
|
5
|
+
import { StatusIndicator } from "../StatusIndicator";
|
|
6
|
+
import { tokens } from "../utils/design";
|
|
6
7
|
|
|
7
8
|
export type StatusType =
|
|
8
9
|
| "success"
|
|
@@ -18,17 +19,17 @@ export interface StatusLabelType {
|
|
|
18
19
|
|
|
19
20
|
interface StatusLabelProps {
|
|
20
21
|
/**
|
|
21
|
-
* Text to display
|
|
22
|
+
* Text to display
|
|
22
23
|
*/
|
|
23
24
|
readonly text: string;
|
|
24
25
|
|
|
25
26
|
/**
|
|
26
|
-
* Alignment of text
|
|
27
|
+
* Alignment of text and StatusIndicator
|
|
27
28
|
*/
|
|
28
29
|
readonly alignment?: "start" | "end";
|
|
29
30
|
|
|
30
31
|
/**
|
|
31
|
-
* Status color of
|
|
32
|
+
* Status color of label container, label, and StatusIndicator
|
|
32
33
|
*/
|
|
33
34
|
readonly status?: StatusType;
|
|
34
35
|
}
|
|
@@ -44,35 +45,21 @@ export function StatusLabel({
|
|
|
44
45
|
<View
|
|
45
46
|
style={[
|
|
46
47
|
styles.statusLabelRow,
|
|
48
|
+
{ backgroundColor: tokens[`color-${status}--surface`] },
|
|
47
49
|
alignment === "start" && styles.labelTextStartAligned,
|
|
48
50
|
]}
|
|
49
51
|
>
|
|
50
52
|
<View style={styles.statusLabelText}>
|
|
51
|
-
<
|
|
53
|
+
<Typography
|
|
54
|
+
align={alignment}
|
|
55
|
+
size="smaller"
|
|
56
|
+
fontWeight="medium"
|
|
57
|
+
color={`${status}OnSurface`}
|
|
58
|
+
>
|
|
52
59
|
{text}
|
|
53
|
-
</
|
|
60
|
+
</Typography>
|
|
54
61
|
</View>
|
|
55
|
-
<
|
|
56
|
-
<StatusLabelIcon status={status} styles={styles} />
|
|
62
|
+
<StatusIndicator status={status} />
|
|
57
63
|
</View>
|
|
58
64
|
);
|
|
59
65
|
}
|
|
60
|
-
|
|
61
|
-
interface StatusLabelIconProps {
|
|
62
|
-
readonly status: StatusType;
|
|
63
|
-
readonly styles: ReturnType<typeof useStyles>;
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
function StatusLabelIcon({ status, styles }: StatusLabelIconProps) {
|
|
67
|
-
const { tokens } = useAtlantisTheme();
|
|
68
|
-
|
|
69
|
-
return (
|
|
70
|
-
<View
|
|
71
|
-
testID={`${status}LabelIcon`}
|
|
72
|
-
style={[
|
|
73
|
-
styles.statusLabelIcon,
|
|
74
|
-
{ backgroundColor: tokens[`color-${status}`] },
|
|
75
|
-
]}
|
|
76
|
-
/>
|
|
77
|
-
);
|
|
78
|
-
}
|