@jobber/components-native 0.7.0 → 0.8.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/src/StatusLabel/StatusLabel.js +21 -0
- package/dist/src/StatusLabel/StatusLabel.style.js +27 -0
- package/dist/src/StatusLabel/index.js +1 -0
- package/dist/src/Typography/Typography.style.js +101 -164
- package/dist/src/Typography/webFonts.js +34 -0
- package/dist/src/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/StatusLabel/StatusLabel.d.ts +22 -0
- package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +23 -0
- package/dist/types/src/StatusLabel/index.d.ts +2 -0
- package/dist/types/src/Typography/Typography.style.d.ts +6 -6
- package/dist/types/src/Typography/webFonts.d.ts +4 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/StatusLabel/StatusLabel.style.ts +30 -0
- package/src/StatusLabel/StatusLabel.test.tsx +68 -0
- package/src/StatusLabel/StatusLabel.tsx +73 -0
- package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +554 -0
- package/src/StatusLabel/index.ts +2 -0
- package/src/Typography/Typography.style.ts +33 -18
- package/src/Typography/webFonts.ts +43 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
export type StatusType = "success" | "warning" | "critical" | "inactive" | "informative";
|
|
3
|
+
export interface StatusLabelType {
|
|
4
|
+
readonly statusLabel: string;
|
|
5
|
+
readonly statusType?: StatusType;
|
|
6
|
+
}
|
|
7
|
+
interface StatusLabelProps {
|
|
8
|
+
/**
|
|
9
|
+
* Text to display.
|
|
10
|
+
*/
|
|
11
|
+
readonly text: string;
|
|
12
|
+
/**
|
|
13
|
+
* Alignment of text
|
|
14
|
+
*/
|
|
15
|
+
readonly alignment?: "start" | "end";
|
|
16
|
+
/**
|
|
17
|
+
* Status color of the square beside text
|
|
18
|
+
*/
|
|
19
|
+
readonly status?: StatusType;
|
|
20
|
+
}
|
|
21
|
+
export declare function StatusLabel({ text, alignment, status, }: StatusLabelProps): JSX.Element;
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export declare const styles: {
|
|
2
|
+
statusLabelRow: {
|
|
3
|
+
flexDirection: "row";
|
|
4
|
+
justifyContent: "flex-end";
|
|
5
|
+
flexWrap: "nowrap";
|
|
6
|
+
};
|
|
7
|
+
statusLabelText: {
|
|
8
|
+
flexShrink: number;
|
|
9
|
+
};
|
|
10
|
+
statusLabelIcon: {
|
|
11
|
+
borderRadius: number;
|
|
12
|
+
backgroundColor: string;
|
|
13
|
+
width: number;
|
|
14
|
+
height: number;
|
|
15
|
+
marginTop: number;
|
|
16
|
+
};
|
|
17
|
+
labelTextStartAligned: {
|
|
18
|
+
flexDirection: "row-reverse";
|
|
19
|
+
};
|
|
20
|
+
innerPad: {
|
|
21
|
+
width: number;
|
|
22
|
+
};
|
|
23
|
+
};
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import { TextStyle } from "react-native";
|
|
2
|
+
/**
|
|
3
|
+
* Reusable typography tokens to ensure consistency for any client facing texts.
|
|
4
|
+
*/
|
|
5
|
+
export declare const typographyTokens: {
|
|
6
|
+
[index: string]: TextStyle;
|
|
7
|
+
};
|
|
2
8
|
/**
|
|
3
9
|
* `StyleSheet` for Typography.tsx.
|
|
4
10
|
*
|
|
@@ -9,12 +15,6 @@ import { TextStyle } from "react-native";
|
|
|
9
15
|
* import { typographyStyles } from "@jobber/components-native"
|
|
10
16
|
* ```
|
|
11
17
|
*/
|
|
12
|
-
/**
|
|
13
|
-
* Reusable typography tokens to ensure consistency for any client facing texts.
|
|
14
|
-
*/
|
|
15
|
-
export declare const typographyTokens: {
|
|
16
|
-
[index: string]: TextStyle;
|
|
17
|
-
};
|
|
18
18
|
export declare const typographyStyles: {
|
|
19
19
|
[index: string]: TextStyle;
|
|
20
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "dist/src/index.js",
|
|
6
6
|
"module": "dist/src/index.js",
|
|
@@ -44,5 +44,5 @@
|
|
|
44
44
|
"react": "^18",
|
|
45
45
|
"react-native": ">=0.69.2"
|
|
46
46
|
},
|
|
47
|
-
"gitHead": "
|
|
47
|
+
"gitHead": "098e6c092be15121c96d37b3f959a05ea06c9e1d"
|
|
48
48
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
|
|
4
|
+
const statusLabelIconDiameter = tokens["space-base"] - tokens["space-smaller"]; //12px
|
|
5
|
+
|
|
6
|
+
const indicatorOffset = tokens["space-smallest"] + tokens["space-minuscule"];
|
|
7
|
+
|
|
8
|
+
export const styles = StyleSheet.create({
|
|
9
|
+
statusLabelRow: {
|
|
10
|
+
flexDirection: "row",
|
|
11
|
+
justifyContent: "flex-end",
|
|
12
|
+
flexWrap: "nowrap",
|
|
13
|
+
},
|
|
14
|
+
statusLabelText: {
|
|
15
|
+
flexShrink: 1,
|
|
16
|
+
},
|
|
17
|
+
statusLabelIcon: {
|
|
18
|
+
borderRadius: tokens["radius-base"],
|
|
19
|
+
backgroundColor: tokens["color-success"],
|
|
20
|
+
width: statusLabelIconDiameter,
|
|
21
|
+
height: statusLabelIconDiameter,
|
|
22
|
+
marginTop: indicatorOffset,
|
|
23
|
+
},
|
|
24
|
+
labelTextStartAligned: {
|
|
25
|
+
flexDirection: "row-reverse",
|
|
26
|
+
},
|
|
27
|
+
innerPad: {
|
|
28
|
+
width: tokens["space-small"],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { render } from "@testing-library/react-native";
|
|
3
|
+
import { StatusLabel } from "./StatusLabel";
|
|
4
|
+
|
|
5
|
+
describe("StatusLabel", () => {
|
|
6
|
+
describe("alignment", () => {
|
|
7
|
+
describe('when alignment prop set to default ("start")', () => {
|
|
8
|
+
it("should match snapshot", () => {
|
|
9
|
+
const view = render(<StatusLabel text="Start Aligned" />).toJSON();
|
|
10
|
+
expect(view).toMatchSnapshot();
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
describe('when alignment prop set to "end"', () => {
|
|
15
|
+
it("should match snapshot", () => {
|
|
16
|
+
const view = render(
|
|
17
|
+
<StatusLabel text="End Aligned" alignment="end" />,
|
|
18
|
+
).toJSON();
|
|
19
|
+
expect(view).toMatchSnapshot();
|
|
20
|
+
});
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
describe("status", () => {
|
|
25
|
+
describe('when status prop set to default ("success")', () => {
|
|
26
|
+
it("should match snapshot", () => {
|
|
27
|
+
const view = render(<StatusLabel text="Success" />).toJSON();
|
|
28
|
+
expect(view).toMatchSnapshot();
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('when status prop set to "warning"', () => {
|
|
33
|
+
it("should match snapshot", () => {
|
|
34
|
+
const view = render(
|
|
35
|
+
<StatusLabel text="Warning" status="warning" />,
|
|
36
|
+
).toJSON();
|
|
37
|
+
expect(view).toMatchSnapshot();
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
describe('when status prop set to "critical"', () => {
|
|
42
|
+
it("should match snapshot", () => {
|
|
43
|
+
const view = render(
|
|
44
|
+
<StatusLabel text="Critical" status="critical" />,
|
|
45
|
+
).toJSON();
|
|
46
|
+
expect(view).toMatchSnapshot();
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
describe('when status prop set to "inactive"', () => {
|
|
51
|
+
it("should match snapshot", () => {
|
|
52
|
+
const view = render(
|
|
53
|
+
<StatusLabel text="Inactive" status="inactive" />,
|
|
54
|
+
).toJSON();
|
|
55
|
+
expect(view).toMatchSnapshot();
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('when status prop set to "informative"', () => {
|
|
60
|
+
it("should match snapshot", () => {
|
|
61
|
+
const view = render(
|
|
62
|
+
<StatusLabel text="Informative" status="informative" />,
|
|
63
|
+
).toJSON();
|
|
64
|
+
expect(view).toMatchSnapshot();
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
});
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { styles } from "./StatusLabel.style";
|
|
4
|
+
import { tokens } from "../utils/design";
|
|
5
|
+
import { Text } from "../Text";
|
|
6
|
+
|
|
7
|
+
export type StatusType =
|
|
8
|
+
| "success"
|
|
9
|
+
| "warning"
|
|
10
|
+
| "critical"
|
|
11
|
+
| "inactive"
|
|
12
|
+
| "informative";
|
|
13
|
+
|
|
14
|
+
export interface StatusLabelType {
|
|
15
|
+
readonly statusLabel: string;
|
|
16
|
+
readonly statusType?: StatusType;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
interface StatusLabelProps {
|
|
20
|
+
/**
|
|
21
|
+
* Text to display.
|
|
22
|
+
*/
|
|
23
|
+
readonly text: string;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* Alignment of text
|
|
27
|
+
*/
|
|
28
|
+
readonly alignment?: "start" | "end";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Status color of the square beside text
|
|
32
|
+
*/
|
|
33
|
+
readonly status?: StatusType;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function StatusLabel({
|
|
37
|
+
text,
|
|
38
|
+
alignment = "end",
|
|
39
|
+
status = "success",
|
|
40
|
+
}: StatusLabelProps): JSX.Element {
|
|
41
|
+
return (
|
|
42
|
+
<View
|
|
43
|
+
style={[
|
|
44
|
+
styles.statusLabelRow,
|
|
45
|
+
alignment === "start" && styles.labelTextStartAligned,
|
|
46
|
+
]}
|
|
47
|
+
>
|
|
48
|
+
<View style={styles.statusLabelText}>
|
|
49
|
+
<Text align={alignment} level="textSupporting" variation="subdued">
|
|
50
|
+
{text}
|
|
51
|
+
</Text>
|
|
52
|
+
</View>
|
|
53
|
+
<View style={styles.innerPad} />
|
|
54
|
+
<StatusLabelIcon status={status} />
|
|
55
|
+
</View>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
interface StatusLabelIconProps {
|
|
60
|
+
status: StatusType;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function StatusLabelIcon({ status }: StatusLabelIconProps) {
|
|
64
|
+
return (
|
|
65
|
+
<View
|
|
66
|
+
testID={`${status}LabelIcon`}
|
|
67
|
+
style={[
|
|
68
|
+
styles.statusLabelIcon,
|
|
69
|
+
{ backgroundColor: tokens[`color-${status}`] },
|
|
70
|
+
]}
|
|
71
|
+
/>
|
|
72
|
+
);
|
|
73
|
+
}
|