@jobber/components-native 0.74.1-node22-3bf0edd.11 → 0.75.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/Divider/Divider.js +9 -6
- package/dist/src/Divider/{Divider.style.js → DividerHorizontal.style.js} +9 -4
- package/dist/src/Divider/DividerVertical.style.js +26 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/Divider/Divider.d.ts +12 -3
- package/dist/types/src/Divider/{Divider.style.d.ts → DividerHorizontal.style.d.ts} +7 -2
- package/dist/types/src/Divider/DividerVertical.style.d.ts +24 -0
- package/package.json +2 -2
- package/src/Divider/Divider.test.tsx +58 -19
- package/src/Divider/Divider.tsx +25 -7
- package/src/Divider/{Divider.style.ts → DividerHorizontal.style.ts} +9 -4
- package/src/Divider/DividerVertical.style.ts +27 -0
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import { styles } from "./Divider.style";
|
|
3
2
|
interface DividerProps {
|
|
4
3
|
/**
|
|
5
4
|
* The weight of the divider.
|
|
6
5
|
*
|
|
7
6
|
* @default "base"
|
|
8
7
|
*/
|
|
9
|
-
readonly size?:
|
|
8
|
+
readonly size?: "base" | "large" | "larger" | "largest";
|
|
9
|
+
/**
|
|
10
|
+
* The direction of the divider
|
|
11
|
+
*
|
|
12
|
+
* @default "horizontal"
|
|
13
|
+
*/
|
|
14
|
+
readonly direction?: "horizontal" | "vertical";
|
|
15
|
+
/**
|
|
16
|
+
* Used to locate this view in end-to-end tests.
|
|
17
|
+
*/
|
|
18
|
+
readonly testID?: string;
|
|
10
19
|
}
|
|
11
|
-
export declare function Divider({ size }: DividerProps): JSX.Element;
|
|
20
|
+
export declare function Divider({ size, direction, testID, }: DividerProps): JSX.Element;
|
|
12
21
|
export {};
|
|
@@ -1,14 +1,19 @@
|
|
|
1
|
-
export declare const
|
|
1
|
+
export declare const horizontalStyles: {
|
|
2
2
|
base: {
|
|
3
3
|
height: number;
|
|
4
4
|
margin: number;
|
|
5
|
-
|
|
5
|
+
width: "auto";
|
|
6
6
|
borderBottomColor: string;
|
|
7
|
+
borderBottomWidth: number;
|
|
7
8
|
};
|
|
8
9
|
large: {
|
|
9
10
|
borderBottomWidth: number;
|
|
10
11
|
opacity: number;
|
|
11
12
|
};
|
|
13
|
+
larger: {
|
|
14
|
+
borderBottomWidth: number;
|
|
15
|
+
opacity: number;
|
|
16
|
+
};
|
|
12
17
|
largest: {
|
|
13
18
|
borderBottomWidth: number;
|
|
14
19
|
opacity: number;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export declare const verticalStyles: {
|
|
2
|
+
base: {
|
|
3
|
+
margin: number;
|
|
4
|
+
height: "100%";
|
|
5
|
+
width: number;
|
|
6
|
+
borderRightWidth: number;
|
|
7
|
+
borderRightColor: string;
|
|
8
|
+
};
|
|
9
|
+
large: {
|
|
10
|
+
borderRightWidth: number;
|
|
11
|
+
opacity: number;
|
|
12
|
+
};
|
|
13
|
+
larger: {
|
|
14
|
+
borderRightWidth: number;
|
|
15
|
+
opacity: number;
|
|
16
|
+
};
|
|
17
|
+
largest: {
|
|
18
|
+
borderRightWidth: number;
|
|
19
|
+
opacity: number;
|
|
20
|
+
};
|
|
21
|
+
vertical: {
|
|
22
|
+
borderRightColor: string;
|
|
23
|
+
};
|
|
24
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jobber/components-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.75.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "React Native implementation of Atlantis",
|
|
6
6
|
"repository": {
|
|
@@ -79,5 +79,5 @@
|
|
|
79
79
|
"react-native-safe-area-context": "^4.5.2",
|
|
80
80
|
"react-native-svg": ">=12.0.0"
|
|
81
81
|
},
|
|
82
|
-
"gitHead": "
|
|
82
|
+
"gitHead": "7347ac364b98158eacf3e455e02ad3475aae83a9"
|
|
83
83
|
}
|
|
@@ -1,32 +1,71 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { render } from "@testing-library/react-native";
|
|
3
3
|
import { Divider } from "./Divider";
|
|
4
|
-
import {
|
|
4
|
+
import { horizontalStyles } from "./DividerHorizontal.style";
|
|
5
|
+
import { verticalStyles } from "./DividerVertical.style";
|
|
5
6
|
|
|
6
7
|
const dividerTestId = "Divider";
|
|
7
8
|
|
|
8
9
|
describe("Divider", () => {
|
|
9
|
-
it("
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
expect(
|
|
13
|
-
expect(dividerStyle).not.toContainEqual(styles.large);
|
|
14
|
-
expect(dividerStyle).not.toContainEqual(styles.largest);
|
|
10
|
+
it("uses the given testID", () => {
|
|
11
|
+
const dividerTestID = "divider-test";
|
|
12
|
+
const { getByTestId } = render(<Divider testID={dividerTestID} />);
|
|
13
|
+
expect(getByTestId(dividerTestID)).toBeDefined();
|
|
15
14
|
});
|
|
16
15
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
16
|
+
describe("Horizontal", () => {
|
|
17
|
+
it("renders a default Divider", () => {
|
|
18
|
+
const { getByTestId } = render(<Divider />);
|
|
19
|
+
const dividerStyle = getByTestId(dividerTestId).props.style;
|
|
20
|
+
expect(dividerStyle).toContainEqual(horizontalStyles.base);
|
|
21
|
+
expect(dividerStyle).not.toContainEqual(horizontalStyles.large);
|
|
22
|
+
expect(dividerStyle).not.toContainEqual(horizontalStyles.largest);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it("renders a large Divider", () => {
|
|
26
|
+
const { getByTestId } = render(<Divider size="large" />);
|
|
27
|
+
const dividerStyle = getByTestId(dividerTestId).props.style;
|
|
28
|
+
expect(dividerStyle).toContainEqual(horizontalStyles.base);
|
|
29
|
+
expect(dividerStyle).toContainEqual(horizontalStyles.large);
|
|
30
|
+
expect(dividerStyle).not.toContainEqual(horizontalStyles.largest);
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
it("renders a largest Divider", () => {
|
|
34
|
+
const { getByTestId } = render(<Divider size="largest" />);
|
|
35
|
+
const dividerStyle = getByTestId(dividerTestId).props.style;
|
|
36
|
+
expect(dividerStyle).toContainEqual(horizontalStyles.base);
|
|
37
|
+
expect(dividerStyle).not.toContainEqual(horizontalStyles.large);
|
|
38
|
+
expect(dividerStyle).toContainEqual(horizontalStyles.largest);
|
|
39
|
+
});
|
|
23
40
|
});
|
|
24
41
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
42
|
+
describe("Vertical", () => {
|
|
43
|
+
it("renders a default Divider", () => {
|
|
44
|
+
const { getByTestId } = render(<Divider direction="vertical" />);
|
|
45
|
+
const dividerStyle = getByTestId(dividerTestId).props.style;
|
|
46
|
+
expect(dividerStyle).toContainEqual(verticalStyles.base);
|
|
47
|
+
expect(dividerStyle).not.toContainEqual(verticalStyles.large);
|
|
48
|
+
expect(dividerStyle).not.toContainEqual(verticalStyles.largest);
|
|
49
|
+
});
|
|
50
|
+
|
|
51
|
+
it("renders a large Divider", () => {
|
|
52
|
+
const { getByTestId } = render(
|
|
53
|
+
<Divider direction="vertical" size="large" />,
|
|
54
|
+
);
|
|
55
|
+
const dividerStyle = getByTestId(dividerTestId).props.style;
|
|
56
|
+
expect(dividerStyle).toContainEqual(verticalStyles.base);
|
|
57
|
+
expect(dividerStyle).toContainEqual(verticalStyles.large);
|
|
58
|
+
expect(dividerStyle).not.toContainEqual(verticalStyles.largest);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
it("renders a largest Divider", () => {
|
|
62
|
+
const { getByTestId } = render(
|
|
63
|
+
<Divider direction="vertical" size="largest" />,
|
|
64
|
+
);
|
|
65
|
+
const dividerStyle = getByTestId(dividerTestId).props.style;
|
|
66
|
+
expect(dividerStyle).toContainEqual(verticalStyles.base);
|
|
67
|
+
expect(dividerStyle).not.toContainEqual(verticalStyles.large);
|
|
68
|
+
expect(dividerStyle).toContainEqual(verticalStyles.largest);
|
|
69
|
+
});
|
|
31
70
|
});
|
|
32
71
|
});
|
package/src/Divider/Divider.tsx
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import {
|
|
3
|
+
import { horizontalStyles } from "./DividerHorizontal.style";
|
|
4
|
+
import { verticalStyles } from "./DividerVertical.style";
|
|
4
5
|
|
|
5
6
|
interface DividerProps {
|
|
6
7
|
/**
|
|
@@ -8,15 +9,32 @@ interface DividerProps {
|
|
|
8
9
|
*
|
|
9
10
|
* @default "base"
|
|
10
11
|
*/
|
|
11
|
-
readonly size?:
|
|
12
|
+
readonly size?: "base" | "large" | "larger" | "largest";
|
|
13
|
+
/**
|
|
14
|
+
* The direction of the divider
|
|
15
|
+
*
|
|
16
|
+
* @default "horizontal"
|
|
17
|
+
*/
|
|
18
|
+
readonly direction?: "horizontal" | "vertical";
|
|
19
|
+
/**
|
|
20
|
+
* Used to locate this view in end-to-end tests.
|
|
21
|
+
*/
|
|
22
|
+
readonly testID?: string;
|
|
12
23
|
}
|
|
13
24
|
|
|
14
|
-
export function Divider({
|
|
25
|
+
export function Divider({
|
|
26
|
+
size = "base",
|
|
27
|
+
direction = "horizontal",
|
|
28
|
+
testID = "Divider",
|
|
29
|
+
}: DividerProps): JSX.Element {
|
|
30
|
+
const directionalStyles =
|
|
31
|
+
direction === "horizontal" ? horizontalStyles : verticalStyles;
|
|
15
32
|
const style = [
|
|
16
|
-
|
|
17
|
-
size === "large" &&
|
|
18
|
-
size === "
|
|
33
|
+
directionalStyles.base,
|
|
34
|
+
size === "large" && directionalStyles.large,
|
|
35
|
+
size === "larger" && directionalStyles.larger,
|
|
36
|
+
size === "largest" && directionalStyles.largest,
|
|
19
37
|
];
|
|
20
38
|
|
|
21
|
-
return <View testID=
|
|
39
|
+
return <View testID={testID} style={style} />;
|
|
22
40
|
}
|
|
@@ -1,19 +1,24 @@
|
|
|
1
1
|
import { StyleSheet } from "react-native";
|
|
2
2
|
import { tokens } from "../utils/design";
|
|
3
3
|
|
|
4
|
-
export const
|
|
4
|
+
export const horizontalStyles = StyleSheet.create({
|
|
5
5
|
base: {
|
|
6
|
-
height:
|
|
6
|
+
height: 1,
|
|
7
7
|
margin: 0,
|
|
8
|
-
|
|
8
|
+
width: "auto",
|
|
9
9
|
borderBottomColor: tokens["color-border"],
|
|
10
|
+
borderBottomWidth: tokens["border-base"],
|
|
10
11
|
},
|
|
11
12
|
large: {
|
|
12
13
|
borderBottomWidth: tokens["border-thick"],
|
|
13
14
|
opacity: 0.875,
|
|
14
15
|
},
|
|
16
|
+
larger: {
|
|
17
|
+
borderBottomWidth: tokens["border-thicker"],
|
|
18
|
+
opacity: 0.625,
|
|
19
|
+
},
|
|
15
20
|
largest: {
|
|
16
|
-
borderBottomWidth: tokens["
|
|
21
|
+
borderBottomWidth: tokens["border-thickest"],
|
|
17
22
|
opacity: 0.375,
|
|
18
23
|
},
|
|
19
24
|
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
|
|
4
|
+
export const verticalStyles = StyleSheet.create({
|
|
5
|
+
base: {
|
|
6
|
+
margin: 0,
|
|
7
|
+
height: "100%",
|
|
8
|
+
width: 1,
|
|
9
|
+
borderRightWidth: tokens["border-base"],
|
|
10
|
+
borderRightColor: tokens["color-border"],
|
|
11
|
+
},
|
|
12
|
+
large: {
|
|
13
|
+
borderRightWidth: tokens["border-thick"],
|
|
14
|
+
opacity: 0.875,
|
|
15
|
+
},
|
|
16
|
+
larger: {
|
|
17
|
+
borderRightWidth: tokens["border-thicker"],
|
|
18
|
+
opacity: 0.625,
|
|
19
|
+
},
|
|
20
|
+
largest: {
|
|
21
|
+
borderRightWidth: tokens["border-thickest"],
|
|
22
|
+
opacity: 0.375,
|
|
23
|
+
},
|
|
24
|
+
vertical: {
|
|
25
|
+
borderRightColor: tokens["color-border"],
|
|
26
|
+
},
|
|
27
|
+
});
|