@jobber/components-native 0.11.0 → 0.12.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/Heading/Heading.js +51 -0
- package/dist/src/Heading/index.js +1 -0
- package/dist/src/index.js +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/src/Heading/Heading.d.ts +37 -0
- package/dist/types/src/Heading/index.d.ts +2 -0
- package/dist/types/src/index.d.ts +1 -0
- package/package.json +2 -2
- package/src/Heading/Heading.test.tsx +83 -0
- package/src/Heading/Heading.tsx +132 -0
- package/src/Heading/__snapshots__/Heading.test.tsx.snap +270 -0
- package/src/Heading/index.ts +2 -0
- package/src/index.ts +1 -0
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Typography, } from "../Typography";
|
|
3
|
+
import { tokens } from "../utils/design";
|
|
4
|
+
const maxScaledFontSize = {
|
|
5
|
+
subHeading: tokens["typography--fontSize-base"] * 1.375,
|
|
6
|
+
heading: tokens["typography--fontSize-base"] * 1.5,
|
|
7
|
+
subtitle: tokens["typography--fontSize-base"] * 1.5,
|
|
8
|
+
title: tokens["typography--fontSize-base"] * 2.125,
|
|
9
|
+
};
|
|
10
|
+
export function Heading({ children, level, variation = "heading", reverseTheme = false, align, maxLines = "unlimited", allowFontScaling = true, selectable, }) {
|
|
11
|
+
const headingStyle = getHeadingStyle(level, variation);
|
|
12
|
+
const accessibilityRole = "header";
|
|
13
|
+
return (React.createElement(Typography, Object.assign({}, Object.assign(Object.assign({}, headingStyle), { accessibilityRole,
|
|
14
|
+
reverseTheme,
|
|
15
|
+
align,
|
|
16
|
+
maxLines,
|
|
17
|
+
allowFontScaling }), { maxFontScaleSize: maxScaledFontSize[level], selectable: selectable }), children));
|
|
18
|
+
}
|
|
19
|
+
function getHeadingStyle(level = "heading", variation) {
|
|
20
|
+
const headingLevelToStyle = {
|
|
21
|
+
title: {
|
|
22
|
+
fontFamily: "display",
|
|
23
|
+
fontWeight: "black",
|
|
24
|
+
size: "jumbo",
|
|
25
|
+
lineHeight: "jumbo",
|
|
26
|
+
color: variation,
|
|
27
|
+
},
|
|
28
|
+
subtitle: {
|
|
29
|
+
fontFamily: "display",
|
|
30
|
+
fontWeight: "extraBold",
|
|
31
|
+
size: "largest",
|
|
32
|
+
lineHeight: "largest",
|
|
33
|
+
color: variation,
|
|
34
|
+
},
|
|
35
|
+
heading: {
|
|
36
|
+
fontFamily: "display",
|
|
37
|
+
fontWeight: "extraBold",
|
|
38
|
+
size: "larger",
|
|
39
|
+
lineHeight: "large",
|
|
40
|
+
color: variation,
|
|
41
|
+
},
|
|
42
|
+
subHeading: {
|
|
43
|
+
fontFamily: "base",
|
|
44
|
+
fontWeight: "semiBold",
|
|
45
|
+
size: "default",
|
|
46
|
+
lineHeight: "base",
|
|
47
|
+
color: variation,
|
|
48
|
+
},
|
|
49
|
+
};
|
|
50
|
+
return headingLevelToStyle[level];
|
|
51
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Heading } from "./Heading";
|
package/dist/src/index.js
CHANGED