@jobber/components-native 0.1.4 → 0.2.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.
@@ -0,0 +1,101 @@
1
+ import React from "react";
2
+ import { TextProps } from "react-native";
3
+ export interface TypographyProps<T extends FontFamily> extends Pick<TextProps, "selectable"> {
4
+ /**
5
+ * Text capitalization
6
+ */
7
+ readonly transform?: TextTransform;
8
+ /**
9
+ * Color of text
10
+ */
11
+ readonly color?: TextColor;
12
+ /**
13
+ * Alignment of text
14
+ */
15
+ readonly align?: TextAlign;
16
+ /**
17
+ * Font size
18
+ */
19
+ readonly size?: TextSize;
20
+ /**
21
+ * Text to display
22
+ */
23
+ readonly children?: string;
24
+ /**
25
+ * The maximum amount of lines the text can occupy before being truncated with "...".
26
+ * Uses predefined string values that correspond to a doubling scale for the amount of lines.
27
+ */
28
+ readonly maxLines?: TruncateLength;
29
+ /**
30
+ * Allow text to be resized based on user's device display scale
31
+ */
32
+ readonly allowFontScaling?: boolean;
33
+ /**
34
+ * Set the maximum font the text can go to size when the user scales their
35
+ * device font size
36
+ */
37
+ readonly maxFontScaleSize?: number;
38
+ /**
39
+ * Determines whether text should be scaled down to fit based on maxLines prop
40
+ */
41
+ readonly adjustsFontSizeToFit?: boolean;
42
+ /**
43
+ * Line Height
44
+ */
45
+ readonly lineHeight?: LineHeight;
46
+ /**
47
+ * Spacing between letters
48
+ */
49
+ readonly letterSpacing?: LetterSpacing;
50
+ /**
51
+ * Font Family
52
+ */
53
+ readonly fontFamily?: T;
54
+ /**
55
+ * Font style
56
+ */
57
+ readonly fontStyle?: T extends "base" ? BaseStyle : DisplayStyle;
58
+ /**
59
+ * Font weight
60
+ */
61
+ readonly fontWeight?: T extends "base" ? BaseWeight : DisplayWeight;
62
+ /**
63
+ * Reverse theme for better display on dark background
64
+ */
65
+ readonly reverseTheme?: boolean;
66
+ /**
67
+ * Accessibility role describing the context of the text
68
+ */
69
+ readonly accessibilityRole?: TextAccessibilityRole;
70
+ /**
71
+ * This will make the text inaccessible to the screen reader.
72
+ * This should be avoided unless there is a good reason.
73
+ * For example this is used in InputText to make it so the label isn't
74
+ * selectable because it is already read from the accessibilityLabel
75
+ * of the TextInput
76
+ */
77
+ readonly hideFromScreenReader?: boolean;
78
+ /**
79
+ * Have text styled with strike through
80
+ */
81
+ readonly strikeThrough?: boolean;
82
+ }
83
+ export declare const Typography: React.MemoExoticComponent<typeof InternalTypography>;
84
+ declare function InternalTypography<T extends FontFamily = "base">({ fontFamily, fontStyle, fontWeight, transform, color, align, size, children, maxLines, allowFontScaling, maxFontScaleSize, adjustsFontSizeToFit, lineHeight, letterSpacing, reverseTheme, hideFromScreenReader, accessibilityRole, strikeThrough, selectable, }: TypographyProps<T>): JSX.Element;
85
+ export type FontFamily = "base" | "display";
86
+ export type FontStyle = "regular" | "italic";
87
+ export type FontWeight = "regular" | "medium" | "bold" | "semiBold" | "extraBold" | "black";
88
+ export type BaseWeight = Extract<FontWeight, "regular" | "medium" | "semiBold" | "bold" | "extraBold">;
89
+ export type DisplayWeight = Extract<FontWeight, "semiBold" | "bold" | "extraBold" | "black">;
90
+ export type BaseStyle = FontStyle;
91
+ export type DisplayStyle = Extract<FontStyle, "regular">;
92
+ export type TextColor = TextVariation | "default" | "blue" | "blueDark" | "white" | "green" | "greenDark" | "grey" | "greyDark" | "greyBlue" | "greyBlueDark" | "lightBlue" | "lightBlueDark" | "red" | "redDark" | "yellow" | "yellowDark" | "yellowGreenDark" | "orangeDark" | "navyDark" | "limeDark" | "purpleDark" | "pinkDark" | "tealDark" | "indigoDark" | "navy" | "text" | "heading" | "textSecondary" | "textReverse" | "textReverseSecondary" | "interactive" | "destructive" | "learning" | "subtle" | "onPrimary";
93
+ export type TextVariation = "success" | "interactive" | "error" | "base" | "subdued" | "warn" | "info" | "disabled" | "critical";
94
+ export type TextTransform = "uppercase" | "lowercase" | "capitalize" | "none";
95
+ export type TextSize = "smallest" | "smaller" | "small" | "default" | "large" | "larger" | "largest" | "jumbo" | "extravagant";
96
+ export type TextAlign = "start" | "end" | "center" | "justify";
97
+ export type LineHeight = "extravagant" | "jumbo" | "largest" | "larger" | "large" | "base" | "tight";
98
+ export type LetterSpacing = "base" | "loose";
99
+ export type TextAccessibilityRole = "text" | "header";
100
+ export type TruncateLength = "single" | "small" | "base" | "large" | "extraLarge" | "unlimited";
101
+ export {};
@@ -0,0 +1,20 @@
1
+ import { TextStyle } from "react-native";
2
+ /**
3
+ * `StyleSheet` for Typography.tsx.
4
+ *
5
+ * If you find yourself needing to use what's inside this object on files other
6
+ * than `<Typography />`, please import from `@jobber/components-native` instead.
7
+ *
8
+ * ```
9
+ * import { typographyStyles } from "@jobber/components-native"
10
+ * ```
11
+ */
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
+ export declare const typographyStyles: {
19
+ [index: string]: TextStyle;
20
+ };
@@ -0,0 +1,7 @@
1
+ import { PropsWithChildren } from "react";
2
+ /**
3
+ * This is a workaround suggested by react-native-gesture-handler to prevent
4
+ * accidental highlighting of text in Android devices
5
+ * https://github.com/software-mansion/react-native-gesture-handler/issues/1372
6
+ */
7
+ export declare function TypographyGestureDetector(props: PropsWithChildren<unknown>): JSX.Element;
@@ -0,0 +1,4 @@
1
+ export { Typography } from "./Typography";
2
+ export type { FontFamily, FontStyle, FontWeight, BaseWeight, DisplayWeight, BaseStyle, DisplayStyle, TextColor, TextTransform, TextSize, TextAlign, LineHeight, LetterSpacing, TextAccessibilityRole, TextVariation, TypographyProps, TruncateLength, } from "./Typography";
3
+ export { typographyStyles } from "./Typography.style";
4
+ export { TypographyGestureDetector } from "./TypographyGestureDetector";
@@ -1,2 +1,3 @@
1
1
  export * from "./Icon";
2
2
  export * from "./Divider";
3
+ export * from "./Typography";
@@ -0,0 +1,2 @@
1
+ import { JobberStyle as mobileFoundationBase } from "@jobber/design/foundation.native";
2
+ export declare const tokens: typeof mobileFoundationBase;
@@ -0,0 +1 @@
1
+ export declare function capitalize(text: string): string;
@@ -0,0 +1 @@
1
+ export { capitalize } from "./capitalize";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.1.4",
3
+ "version": "0.2.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/src/index.js",
6
6
  "module": "dist/src/index.js",
@@ -22,7 +22,8 @@
22
22
  },
23
23
  "dependencies": {
24
24
  "@jobber/design": "^0.39.0",
25
- "react-native-svg": "^12.4.4",
25
+ "react-native-gesture-handler": "^2.10.0",
26
+ "react-native-svg": "^13.9.0",
26
27
  "ts-xor": "^1.1.0"
27
28
  },
28
29
  "devDependencies": {
@@ -38,5 +39,5 @@
38
39
  "react": "^18",
39
40
  "react-native": ">=0.69.2"
40
41
  },
41
- "gitHead": "67a8aae8b181f43f4eef5d579ae28959d5b4b19f"
42
+ "gitHead": "9e11e1953c6542432db3498bede05d1a5814f584"
42
43
  }
@@ -1,20 +1,19 @@
1
1
  import { StyleSheet } from "react-native";
2
- // eslint-disable-next-line import/no-internal-modules
3
- import { JobberStyle } from "@jobber/design/foundation";
2
+ import { tokens } from "../utils/design";
4
3
 
5
4
  export const styles = StyleSheet.create({
6
5
  base: {
7
- height: JobberStyle["space-minuscule"],
6
+ height: tokens["space-minuscule"],
8
7
  margin: 0,
9
- borderBottomWidth: JobberStyle["border-base"],
10
- borderBottomColor: JobberStyle["color-border"],
8
+ borderBottomWidth: tokens["border-base"],
9
+ borderBottomColor: tokens["color-border"],
11
10
  },
12
11
  large: {
13
- borderBottomWidth: JobberStyle["border-thick"],
12
+ borderBottomWidth: tokens["border-thick"],
14
13
  opacity: 0.875,
15
14
  },
16
15
  largest: {
17
- borderBottomWidth: JobberStyle["space-small"],
16
+ borderBottomWidth: tokens["space-small"],
18
17
  opacity: 0.375,
19
18
  },
20
19
  });
@@ -0,0 +1,364 @@
1
+ import { StyleSheet, TextStyle } from "react-native";
2
+ import { tokens } from "../utils/design";
3
+
4
+ const extravagantLineHeight = tokens["typography--lineHeight-extravagant"];
5
+ const jumboLineHeight = tokens["typography--lineHeight-jumbo"];
6
+ const largestLineHeight = tokens["typography--lineHeight-largest"];
7
+ const largerLineHeight = tokens["typography--lineHeight-larger"];
8
+ const largeLineHeight = tokens["typography--lineHeight-large"];
9
+ const baseLineHeight = tokens["typography--lineHeight-base"];
10
+ const tightLineHeight = tokens["typography--lineHeight-tight"];
11
+ const minisculeLineHeight = tokens["typography--lineHeight-miniscule"];
12
+
13
+ /**
14
+ * `StyleSheet` for Typography.tsx.
15
+ *
16
+ * If you find yourself needing to use what's inside this object on files other
17
+ * than `<Typography />`, please import from `@jobber/components-native` instead.
18
+ *
19
+ * ```
20
+ * import { typographyStyles } from "@jobber/components-native"
21
+ * ```
22
+ */
23
+
24
+ /**
25
+ * Reusable typography tokens to ensure consistency for any client facing texts.
26
+ */
27
+ export const typographyTokens: { [index: string]: TextStyle } = {
28
+ // This follows a pattern of
29
+ // { fontFamily }{ fontStyle }{ fontWeight }
30
+ baseRegularRegular: {
31
+ fontFamily: "inter-regular",
32
+ },
33
+
34
+ baseRegularMedium: {
35
+ fontFamily: "inter-medium",
36
+ },
37
+
38
+ baseRegularBold: {
39
+ fontFamily: "inter-bold",
40
+ },
41
+
42
+ baseRegularSemiBold: {
43
+ fontFamily: "inter-semibold",
44
+ },
45
+
46
+ baseRegularExtraBold: {
47
+ fontFamily: "inter-extrabold",
48
+ },
49
+
50
+ displayRegularBold: {
51
+ fontFamily: "jobberpro-bd",
52
+ },
53
+
54
+ displayRegularExtraBold: {
55
+ fontFamily: "jobberpro-xbd",
56
+ },
57
+
58
+ displayRegularBlack: {
59
+ fontFamily: "jobberpro-blk",
60
+ },
61
+
62
+ startAlign: {
63
+ textAlign: "left",
64
+ },
65
+
66
+ endAlign: {
67
+ textAlign: "right",
68
+ },
69
+
70
+ centerAlign: {
71
+ textAlign: "center",
72
+ },
73
+
74
+ justifyAlign: {
75
+ textAlign: "justify",
76
+ },
77
+
78
+ blue: {
79
+ color: tokens["color-heading"],
80
+ },
81
+
82
+ blueDark: {
83
+ color: tokens["color-blue--dark"],
84
+ },
85
+
86
+ white: {
87
+ color: tokens["color-white"],
88
+ },
89
+
90
+ green: {
91
+ color: tokens["color-green"],
92
+ },
93
+
94
+ greenDark: {
95
+ color: tokens["color-green--dark"],
96
+ },
97
+
98
+ grey: {
99
+ color: tokens["color-grey"],
100
+ },
101
+
102
+ greyDark: {
103
+ color: tokens["color-grey--dark"],
104
+ },
105
+
106
+ greyBlue: {
107
+ color: tokens["color-greyBlue"],
108
+ },
109
+
110
+ greyBlueDark: {
111
+ color: tokens["color-greyBlue--dark"],
112
+ },
113
+
114
+ lightBlue: {
115
+ color: tokens["color-lightBlue"],
116
+ },
117
+
118
+ lightBlueDark: {
119
+ color: tokens["color-lightBlue--dark"],
120
+ },
121
+
122
+ red: {
123
+ color: tokens["color-red"],
124
+ },
125
+
126
+ redDark: {
127
+ color: tokens["color-red--dark"],
128
+ },
129
+
130
+ yellow: {
131
+ color: tokens["color-yellow"],
132
+ },
133
+
134
+ yellowDark: {
135
+ color: tokens["color-yellow--dark"],
136
+ },
137
+
138
+ yellowGreenDark: {
139
+ color: tokens["color-yellowGreen--dark"],
140
+ },
141
+
142
+ orangeDark: {
143
+ color: tokens["color-orange--dark"],
144
+ },
145
+
146
+ navyDark: {
147
+ color: tokens["color-navy--dark"],
148
+ },
149
+
150
+ limeDark: {
151
+ color: tokens["color-lime--dark"],
152
+ },
153
+
154
+ purpleDark: {
155
+ color: tokens["color-purple--dark"],
156
+ },
157
+
158
+ pinkDark: {
159
+ color: tokens["color-pink--dark"],
160
+ },
161
+
162
+ tealDark: {
163
+ color: tokens["color-teal--dark"],
164
+ },
165
+
166
+ indigoDark: {
167
+ color: tokens["color-indigo--dark"],
168
+ },
169
+
170
+ navy: {
171
+ color: tokens["color-navy"],
172
+ },
173
+
174
+ heading: {
175
+ color: tokens["color-heading"],
176
+ },
177
+
178
+ headingReverse: {
179
+ color: tokens["color-text--reverse"],
180
+ },
181
+
182
+ text: {
183
+ color: tokens["color-text"],
184
+ },
185
+
186
+ textSecondary: {
187
+ color: tokens["color-text--secondary"],
188
+ },
189
+
190
+ textReverse: {
191
+ color: tokens["color-text--reverse"],
192
+ },
193
+
194
+ textReverseSecondary: {
195
+ color: tokens["color-text--reverse--secondary"],
196
+ },
197
+
198
+ success: {
199
+ color: tokens["color-success--onSurface"],
200
+ },
201
+
202
+ error: {
203
+ color: tokens["color-critical"],
204
+ },
205
+
206
+ base: {
207
+ color: tokens["color-text"],
208
+ },
209
+
210
+ subdued: {
211
+ color: tokens["color-text--secondary"],
212
+ },
213
+
214
+ warn: {
215
+ color: tokens["color-warning--onSurface"],
216
+ },
217
+
218
+ info: {
219
+ color: tokens["color-informative--onSurface"],
220
+ },
221
+
222
+ critical: {
223
+ color: tokens["color-critical"],
224
+ },
225
+
226
+ successReverse: {
227
+ color: tokens["color-success"],
228
+ },
229
+
230
+ errorReverse: {
231
+ color: tokens["color-critical"],
232
+ },
233
+
234
+ baseReverse: {
235
+ color: tokens["color-text--reverse"],
236
+ },
237
+
238
+ subduedReverse: {
239
+ color: tokens["color-text--reverse--secondary"],
240
+ },
241
+
242
+ warnReverse: {
243
+ color: tokens["color-warning"],
244
+ },
245
+
246
+ infoReverse: {
247
+ color: tokens["color-informative"],
248
+ },
249
+
250
+ criticalReverse: {
251
+ color: tokens["color-critical"],
252
+ },
253
+
254
+ interactive: {
255
+ color: tokens["color-interactive"],
256
+ },
257
+
258
+ destructive: {
259
+ color: tokens["color-destructive"],
260
+ },
261
+
262
+ learning: {
263
+ color: tokens["color-informative"],
264
+ },
265
+
266
+ subtle: {
267
+ color: tokens["color-interactive--subtle"],
268
+ },
269
+
270
+ onPrimary: {
271
+ color: tokens["color-surface"],
272
+ },
273
+
274
+ disabled: {
275
+ color: tokens["color-disabled"],
276
+ },
277
+
278
+ smallestSize: {
279
+ fontSize: tokens["typography--fontSize-smallest"],
280
+ lineHeight: minisculeLineHeight,
281
+ },
282
+
283
+ smallerSize: {
284
+ fontSize: tokens["typography--fontSize-smaller"],
285
+ lineHeight: tightLineHeight,
286
+ },
287
+
288
+ smallSize: {
289
+ fontSize: tokens["typography--fontSize-small"],
290
+ lineHeight: tightLineHeight,
291
+ },
292
+
293
+ defaultSize: {
294
+ fontSize: tokens["typography--fontSize-base"],
295
+ lineHeight: baseLineHeight,
296
+ },
297
+
298
+ largeSize: {
299
+ fontSize: tokens["typography--fontSize-large"],
300
+ lineHeight: largeLineHeight,
301
+ },
302
+
303
+ largerSize: {
304
+ fontSize: tokens["typography--fontSize-larger"],
305
+ lineHeight: largeLineHeight,
306
+ },
307
+
308
+ largestSize: {
309
+ fontSize: tokens["typography--fontSize-largest"],
310
+ lineHeight: largerLineHeight,
311
+ },
312
+
313
+ jumboSize: {
314
+ fontSize: tokens["typography--fontSize-jumbo"],
315
+ lineHeight: jumboLineHeight,
316
+ },
317
+
318
+ extravagantSize: {
319
+ fontSize: tokens["typography--fontSize-extravagant"],
320
+ lineHeight: extravagantLineHeight,
321
+ },
322
+
323
+ extravagantLineHeight: {
324
+ lineHeight: extravagantLineHeight,
325
+ },
326
+
327
+ jumboLineHeight: {
328
+ lineHeight: jumboLineHeight,
329
+ },
330
+
331
+ largestLineHeight: {
332
+ lineHeight: largestLineHeight,
333
+ },
334
+ largerLineHeight: {
335
+ lineHeight: largerLineHeight,
336
+ },
337
+
338
+ largeLineHeight: {
339
+ lineHeight: largeLineHeight,
340
+ },
341
+
342
+ baseLineHeight: {
343
+ lineHeight: baseLineHeight,
344
+ },
345
+
346
+ tightLineHeight: {
347
+ lineHeight: tightLineHeight,
348
+ },
349
+
350
+ baseLetterSpacing: {
351
+ letterSpacing: tokens["typography--letterSpacing-base"],
352
+ },
353
+
354
+ looseLetterSpacing: {
355
+ letterSpacing: tokens["typography--letterSpacing-loose"],
356
+ },
357
+
358
+ strikeThrough: {
359
+ textDecorationLine: "line-through",
360
+ },
361
+ };
362
+
363
+ export const typographyStyles: { [index: string]: TextStyle } =
364
+ StyleSheet.create(typographyTokens);