@jobber/components-native 0.2.1 → 0.4.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/ActivityIndicator/ActivityIndicator.js +6 -0
- package/dist/src/ActivityIndicator/index.js +1 -0
- package/dist/src/Content/Content.js +24 -0
- package/dist/src/Content/ContentHorizontal.style.js +30 -0
- package/dist/src/Content/ContentSpaceAround.style.js +22 -0
- package/dist/src/Content/ContentVertical.style.js +30 -0
- package/dist/src/Content/index.js +1 -0
- package/dist/src/Text/Text.js +36 -0
- package/dist/src/Text/index.js +1 -0
- package/dist/src/index.js +3 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/ActivityIndicator/ActivityIndicator.d.ts +3 -0
- package/dist/types/src/ActivityIndicator/index.d.ts +1 -0
- package/dist/types/src/Content/Content.d.ts +18 -0
- package/dist/types/src/Content/ContentHorizontal.style.d.ts +28 -0
- package/dist/types/src/Content/ContentSpaceAround.style.d.ts +20 -0
- package/dist/types/src/Content/ContentVertical.style.d.ts +22 -0
- package/dist/types/src/Content/index.d.ts +2 -0
- package/dist/types/src/Text/Text.d.ts +56 -0
- package/dist/types/src/Text/index.d.ts +1 -0
- package/dist/types/src/index.d.ts +3 -0
- package/package.json +3 -2
- package/src/ActivityIndicator/ActivityIndicator.test.tsx +28 -0
- package/src/ActivityIndicator/ActivityIndicator.tsx +15 -0
- package/src/ActivityIndicator/index.ts +1 -0
- package/src/Content/Content.test.tsx +260 -0
- package/src/Content/Content.tsx +66 -0
- package/src/Content/ContentHorizontal.style.ts +38 -0
- package/src/Content/ContentSpaceAround.style.ts +28 -0
- package/src/Content/ContentVertical.style.ts +38 -0
- package/src/Content/index.ts +2 -0
- package/src/Text/Text.test.tsx +139 -0
- package/src/Text/Text.tsx +151 -0
- package/src/Text/__snapshots__/Text.test.tsx.snap +618 -0
- package/src/Text/index.ts +1 -0
- package/src/index.ts +3 -0
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { ActivityIndicator } from "react-native";
|
|
3
|
+
import { tokens } from "../utils/design";
|
|
4
|
+
export function JobberActivityIndicator(props) {
|
|
5
|
+
return (React.createElement(ActivityIndicator, Object.assign({}, props, { color: props.color || tokens["color-greyBlue"], testID: props.testID || "ActivityIndicator" })));
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { JobberActivityIndicator as ActivityIndicator } from "./ActivityIndicator";
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View } from "react-native";
|
|
3
|
+
import { horizontalStyles } from "./ContentHorizontal.style";
|
|
4
|
+
import { verticalStyles } from "./ContentVertical.style";
|
|
5
|
+
import { spaceStyles } from "./ContentSpaceAround.style";
|
|
6
|
+
export function Content({ children, spacing = "base", childSpacing = "base", direction = "vertical", }) {
|
|
7
|
+
const styles = direction === "horizontal" ? horizontalStyles : verticalStyles;
|
|
8
|
+
const styleName = `${spacing}Space`;
|
|
9
|
+
const containerStyle = spaceStyles[styleName];
|
|
10
|
+
return (React.createElement(View, { style: [styles.wrapper, containerStyle] }, renderChildren()));
|
|
11
|
+
function renderChildren() {
|
|
12
|
+
const childArray = React.Children.toArray(children);
|
|
13
|
+
if (childArray.length === 1)
|
|
14
|
+
return children;
|
|
15
|
+
const spaceName = `${childSpacing}ChildSpace`;
|
|
16
|
+
const childContainerStyle = styles[spaceName];
|
|
17
|
+
return childArray.map((child, index) => {
|
|
18
|
+
// In order to get spacing between the children, we apply the child spacing on each of
|
|
19
|
+
// the children except for the first (top) child
|
|
20
|
+
const childStyle = index !== 0 ? [childContainerStyle] : [];
|
|
21
|
+
return (React.createElement(View, { key: index, style: [styles.childWrapper, ...childStyle] }, child));
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
export const horizontalStyles = StyleSheet.create({
|
|
4
|
+
wrapper: {
|
|
5
|
+
flexDirection: "row",
|
|
6
|
+
},
|
|
7
|
+
childWrapper: {
|
|
8
|
+
flexGrow: 1,
|
|
9
|
+
flexShrink: 1,
|
|
10
|
+
flexBasis: 0,
|
|
11
|
+
},
|
|
12
|
+
noneChildSpace: {
|
|
13
|
+
padding: 0,
|
|
14
|
+
},
|
|
15
|
+
smallestChildSpace: {
|
|
16
|
+
paddingLeft: tokens["space-smallest"],
|
|
17
|
+
},
|
|
18
|
+
smallerChildSpace: {
|
|
19
|
+
paddingLeft: tokens["space-smaller"],
|
|
20
|
+
},
|
|
21
|
+
smallChildSpace: {
|
|
22
|
+
paddingLeft: tokens["space-small"],
|
|
23
|
+
},
|
|
24
|
+
baseChildSpace: {
|
|
25
|
+
paddingLeft: tokens["space-base"],
|
|
26
|
+
},
|
|
27
|
+
largeChildSpace: {
|
|
28
|
+
paddingLeft: tokens["space-large"],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
export const spaceStyles = StyleSheet.create({
|
|
4
|
+
noneSpace: {
|
|
5
|
+
padding: 0,
|
|
6
|
+
},
|
|
7
|
+
smallestSpace: {
|
|
8
|
+
padding: tokens["space-smallest"],
|
|
9
|
+
},
|
|
10
|
+
smallerSpace: {
|
|
11
|
+
padding: tokens["space-smaller"],
|
|
12
|
+
},
|
|
13
|
+
smallSpace: {
|
|
14
|
+
padding: tokens["space-small"],
|
|
15
|
+
},
|
|
16
|
+
baseSpace: {
|
|
17
|
+
padding: tokens["space-base"],
|
|
18
|
+
},
|
|
19
|
+
largeSpace: {
|
|
20
|
+
padding: tokens["space-large"],
|
|
21
|
+
},
|
|
22
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { StyleSheet } from "react-native";
|
|
2
|
+
import { tokens } from "../utils/design";
|
|
3
|
+
export const verticalStyles = StyleSheet.create({
|
|
4
|
+
wrapper: {
|
|
5
|
+
// No style. Default `<View />` styling should suffice.
|
|
6
|
+
// Only need this key to exist.
|
|
7
|
+
},
|
|
8
|
+
childWrapper: {
|
|
9
|
+
// No style. Default `<View />` styling should suffice.
|
|
10
|
+
// Only need this key to exist.
|
|
11
|
+
},
|
|
12
|
+
noneChildSpace: {
|
|
13
|
+
padding: 0,
|
|
14
|
+
},
|
|
15
|
+
smallestChildSpace: {
|
|
16
|
+
paddingTop: tokens["space-smallest"],
|
|
17
|
+
},
|
|
18
|
+
smallerChildSpace: {
|
|
19
|
+
paddingTop: tokens["space-smaller"],
|
|
20
|
+
},
|
|
21
|
+
smallChildSpace: {
|
|
22
|
+
paddingTop: tokens["space-small"],
|
|
23
|
+
},
|
|
24
|
+
baseChildSpace: {
|
|
25
|
+
paddingTop: tokens["space-base"],
|
|
26
|
+
},
|
|
27
|
+
largeChildSpace: {
|
|
28
|
+
paddingTop: tokens["space-large"],
|
|
29
|
+
},
|
|
30
|
+
});
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Content } from "./Content";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Typography, } from "../Typography";
|
|
3
|
+
import { tokens } from "../utils/design";
|
|
4
|
+
const levelStyles = {
|
|
5
|
+
text: {
|
|
6
|
+
size: "default",
|
|
7
|
+
lineHeight: "base",
|
|
8
|
+
},
|
|
9
|
+
textSupporting: {
|
|
10
|
+
size: "small",
|
|
11
|
+
lineHeight: "tight",
|
|
12
|
+
},
|
|
13
|
+
};
|
|
14
|
+
const MAX_TEXT_FONT_SIZE_SCALE = 50;
|
|
15
|
+
const maxScaledFontSize = {
|
|
16
|
+
text: MAX_TEXT_FONT_SIZE_SCALE,
|
|
17
|
+
textSupporting: tokens["typography--fontSize-base"],
|
|
18
|
+
};
|
|
19
|
+
export function Text({ level = "text", variation = "base", emphasis, allowFontScaling = true, adjustsFontSizeToFit = false, maxLines = "unlimited", align, children, reverseTheme = false, strikeThrough = false, hideFromScreenReader = false, maxFontScaleSize, selectable, }) {
|
|
20
|
+
const accessibilityRole = "text";
|
|
21
|
+
return (React.createElement(Typography, Object.assign({ color: variation, fontFamily: "base", fontStyle: "regular", fontWeight: getFontWeight({ level, emphasis }), maxFontScaleSize: maxFontScaleSize || maxScaledFontSize[level], selectable: selectable }, Object.assign(Object.assign({}, levelStyles[level]), { allowFontScaling,
|
|
22
|
+
align,
|
|
23
|
+
adjustsFontSizeToFit,
|
|
24
|
+
accessibilityRole,
|
|
25
|
+
reverseTheme,
|
|
26
|
+
maxLines,
|
|
27
|
+
strikeThrough,
|
|
28
|
+
hideFromScreenReader })), children));
|
|
29
|
+
}
|
|
30
|
+
function getFontWeight({ level, emphasis, }) {
|
|
31
|
+
if (emphasis === "strong")
|
|
32
|
+
return "semiBold";
|
|
33
|
+
if (level === "textSupporting")
|
|
34
|
+
return "medium";
|
|
35
|
+
return "regular";
|
|
36
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Text } from "./Text";
|