@jobber/components-native 0.7.0 → 0.9.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.
Files changed (42) hide show
  1. package/dist/src/Card/Card.js +38 -0
  2. package/dist/src/Card/Card.style.js +31 -0
  3. package/dist/src/Card/components/InternalCardHeader.js +14 -0
  4. package/dist/src/Card/components/InternalCardHeader.style.js +16 -0
  5. package/dist/src/Card/components/index.js +1 -0
  6. package/dist/src/Card/index.js +1 -0
  7. package/dist/src/StatusLabel/StatusLabel.js +21 -0
  8. package/dist/src/StatusLabel/StatusLabel.style.js +27 -0
  9. package/dist/src/StatusLabel/index.js +1 -0
  10. package/dist/src/Typography/Typography.style.js +101 -164
  11. package/dist/src/Typography/webFonts.js +34 -0
  12. package/dist/src/index.js +2 -0
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/types/src/Card/Card.d.ts +40 -0
  15. package/dist/types/src/Card/Card.style.d.ts +56 -0
  16. package/dist/types/src/Card/components/InternalCardHeader.d.ts +9 -0
  17. package/dist/types/src/Card/components/InternalCardHeader.style.d.ts +14 -0
  18. package/dist/types/src/Card/components/index.d.ts +1 -0
  19. package/dist/types/src/Card/index.d.ts +2 -0
  20. package/dist/types/src/StatusLabel/StatusLabel.d.ts +22 -0
  21. package/dist/types/src/StatusLabel/StatusLabel.style.d.ts +23 -0
  22. package/dist/types/src/StatusLabel/index.d.ts +2 -0
  23. package/dist/types/src/Typography/Typography.style.d.ts +6 -6
  24. package/dist/types/src/Typography/webFonts.d.ts +4 -0
  25. package/dist/types/src/index.d.ts +2 -0
  26. package/package.json +2 -2
  27. package/src/Card/Card.style.ts +46 -0
  28. package/src/Card/Card.test.tsx +128 -0
  29. package/src/Card/Card.tsx +145 -0
  30. package/src/Card/components/InternalCardHeader.style.ts +19 -0
  31. package/src/Card/components/InternalCardHeader.test.tsx +31 -0
  32. package/src/Card/components/InternalCardHeader.tsx +41 -0
  33. package/src/Card/components/index.ts +1 -0
  34. package/src/Card/index.ts +2 -0
  35. package/src/StatusLabel/StatusLabel.style.ts +30 -0
  36. package/src/StatusLabel/StatusLabel.test.tsx +68 -0
  37. package/src/StatusLabel/StatusLabel.tsx +73 -0
  38. package/src/StatusLabel/__snapshots__/StatusLabel.test.tsx.snap +554 -0
  39. package/src/StatusLabel/index.ts +2 -0
  40. package/src/Typography/Typography.style.ts +33 -18
  41. package/src/Typography/webFonts.ts +43 -0
  42. package/src/index.ts +2 -0
@@ -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
+ }
@@ -0,0 +1,554 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`StatusLabel alignment when alignment prop set to "end" should match snapshot 1`] = `
4
+ <View
5
+ style={
6
+ [
7
+ {
8
+ "flexDirection": "row",
9
+ "flexWrap": "nowrap",
10
+ "justifyContent": "flex-end",
11
+ },
12
+ false,
13
+ ]
14
+ }
15
+ >
16
+ <View
17
+ style={
18
+ {
19
+ "flexShrink": 1,
20
+ }
21
+ }
22
+ >
23
+ <Text
24
+ accessibilityRole="text"
25
+ adjustsFontSizeToFit={false}
26
+ allowFontScaling={true}
27
+ collapsable={false}
28
+ maxFontSizeMultiplier={1.1428571428571428}
29
+ selectable={true}
30
+ selectionColor="rgb(160, 215, 42)"
31
+ style={
32
+ [
33
+ {
34
+ "fontFamily": "inter-medium",
35
+ },
36
+ {
37
+ "color": "rgba(101, 120, 132, 1)",
38
+ },
39
+ {
40
+ "textAlign": "right",
41
+ },
42
+ {
43
+ "fontSize": 14,
44
+ "lineHeight": 18,
45
+ },
46
+ {
47
+ "letterSpacing": 0,
48
+ },
49
+ ]
50
+ }
51
+ >
52
+ End Aligned
53
+ </Text>
54
+ </View>
55
+ <View
56
+ style={
57
+ {
58
+ "width": 8,
59
+ }
60
+ }
61
+ />
62
+ <View
63
+ style={
64
+ [
65
+ {
66
+ "backgroundColor": "rgb(125, 176, 14)",
67
+ "borderRadius": 2,
68
+ "height": 12,
69
+ "marginTop": 3,
70
+ "width": 12,
71
+ },
72
+ {
73
+ "backgroundColor": "rgb(125, 176, 14)",
74
+ },
75
+ ]
76
+ }
77
+ testID="successLabelIcon"
78
+ />
79
+ </View>
80
+ `;
81
+
82
+ exports[`StatusLabel alignment when alignment prop set to default ("start") should match snapshot 1`] = `
83
+ <View
84
+ style={
85
+ [
86
+ {
87
+ "flexDirection": "row",
88
+ "flexWrap": "nowrap",
89
+ "justifyContent": "flex-end",
90
+ },
91
+ false,
92
+ ]
93
+ }
94
+ >
95
+ <View
96
+ style={
97
+ {
98
+ "flexShrink": 1,
99
+ }
100
+ }
101
+ >
102
+ <Text
103
+ accessibilityRole="text"
104
+ adjustsFontSizeToFit={false}
105
+ allowFontScaling={true}
106
+ collapsable={false}
107
+ maxFontSizeMultiplier={1.1428571428571428}
108
+ selectable={true}
109
+ selectionColor="rgb(160, 215, 42)"
110
+ style={
111
+ [
112
+ {
113
+ "fontFamily": "inter-medium",
114
+ },
115
+ {
116
+ "color": "rgba(101, 120, 132, 1)",
117
+ },
118
+ {
119
+ "textAlign": "right",
120
+ },
121
+ {
122
+ "fontSize": 14,
123
+ "lineHeight": 18,
124
+ },
125
+ {
126
+ "letterSpacing": 0,
127
+ },
128
+ ]
129
+ }
130
+ >
131
+ Start Aligned
132
+ </Text>
133
+ </View>
134
+ <View
135
+ style={
136
+ {
137
+ "width": 8,
138
+ }
139
+ }
140
+ />
141
+ <View
142
+ style={
143
+ [
144
+ {
145
+ "backgroundColor": "rgb(125, 176, 14)",
146
+ "borderRadius": 2,
147
+ "height": 12,
148
+ "marginTop": 3,
149
+ "width": 12,
150
+ },
151
+ {
152
+ "backgroundColor": "rgb(125, 176, 14)",
153
+ },
154
+ ]
155
+ }
156
+ testID="successLabelIcon"
157
+ />
158
+ </View>
159
+ `;
160
+
161
+ exports[`StatusLabel status when status prop set to "critical" should match snapshot 1`] = `
162
+ <View
163
+ style={
164
+ [
165
+ {
166
+ "flexDirection": "row",
167
+ "flexWrap": "nowrap",
168
+ "justifyContent": "flex-end",
169
+ },
170
+ false,
171
+ ]
172
+ }
173
+ >
174
+ <View
175
+ style={
176
+ {
177
+ "flexShrink": 1,
178
+ }
179
+ }
180
+ >
181
+ <Text
182
+ accessibilityRole="text"
183
+ adjustsFontSizeToFit={false}
184
+ allowFontScaling={true}
185
+ collapsable={false}
186
+ maxFontSizeMultiplier={1.1428571428571428}
187
+ selectable={true}
188
+ selectionColor="rgb(160, 215, 42)"
189
+ style={
190
+ [
191
+ {
192
+ "fontFamily": "inter-medium",
193
+ },
194
+ {
195
+ "color": "rgba(101, 120, 132, 1)",
196
+ },
197
+ {
198
+ "textAlign": "right",
199
+ },
200
+ {
201
+ "fontSize": 14,
202
+ "lineHeight": 18,
203
+ },
204
+ {
205
+ "letterSpacing": 0,
206
+ },
207
+ ]
208
+ }
209
+ >
210
+ Critical
211
+ </Text>
212
+ </View>
213
+ <View
214
+ style={
215
+ {
216
+ "width": 8,
217
+ }
218
+ }
219
+ />
220
+ <View
221
+ style={
222
+ [
223
+ {
224
+ "backgroundColor": "rgb(125, 176, 14)",
225
+ "borderRadius": 2,
226
+ "height": 12,
227
+ "marginTop": 3,
228
+ "width": 12,
229
+ },
230
+ {
231
+ "backgroundColor": "rgb(201, 66, 33)",
232
+ },
233
+ ]
234
+ }
235
+ testID="criticalLabelIcon"
236
+ />
237
+ </View>
238
+ `;
239
+
240
+ exports[`StatusLabel status when status prop set to "inactive" should match snapshot 1`] = `
241
+ <View
242
+ style={
243
+ [
244
+ {
245
+ "flexDirection": "row",
246
+ "flexWrap": "nowrap",
247
+ "justifyContent": "flex-end",
248
+ },
249
+ false,
250
+ ]
251
+ }
252
+ >
253
+ <View
254
+ style={
255
+ {
256
+ "flexShrink": 1,
257
+ }
258
+ }
259
+ >
260
+ <Text
261
+ accessibilityRole="text"
262
+ adjustsFontSizeToFit={false}
263
+ allowFontScaling={true}
264
+ collapsable={false}
265
+ maxFontSizeMultiplier={1.1428571428571428}
266
+ selectable={true}
267
+ selectionColor="rgb(160, 215, 42)"
268
+ style={
269
+ [
270
+ {
271
+ "fontFamily": "inter-medium",
272
+ },
273
+ {
274
+ "color": "rgba(101, 120, 132, 1)",
275
+ },
276
+ {
277
+ "textAlign": "right",
278
+ },
279
+ {
280
+ "fontSize": 14,
281
+ "lineHeight": 18,
282
+ },
283
+ {
284
+ "letterSpacing": 0,
285
+ },
286
+ ]
287
+ }
288
+ >
289
+ Inactive
290
+ </Text>
291
+ </View>
292
+ <View
293
+ style={
294
+ {
295
+ "width": 8,
296
+ }
297
+ }
298
+ />
299
+ <View
300
+ style={
301
+ [
302
+ {
303
+ "backgroundColor": "rgb(125, 176, 14)",
304
+ "borderRadius": 2,
305
+ "height": 12,
306
+ "marginTop": 3,
307
+ "width": 12,
308
+ },
309
+ {
310
+ "backgroundColor": "rgb(77, 105, 116)",
311
+ },
312
+ ]
313
+ }
314
+ testID="inactiveLabelIcon"
315
+ />
316
+ </View>
317
+ `;
318
+
319
+ exports[`StatusLabel status when status prop set to "informative" should match snapshot 1`] = `
320
+ <View
321
+ style={
322
+ [
323
+ {
324
+ "flexDirection": "row",
325
+ "flexWrap": "nowrap",
326
+ "justifyContent": "flex-end",
327
+ },
328
+ false,
329
+ ]
330
+ }
331
+ >
332
+ <View
333
+ style={
334
+ {
335
+ "flexShrink": 1,
336
+ }
337
+ }
338
+ >
339
+ <Text
340
+ accessibilityRole="text"
341
+ adjustsFontSizeToFit={false}
342
+ allowFontScaling={true}
343
+ collapsable={false}
344
+ maxFontSizeMultiplier={1.1428571428571428}
345
+ selectable={true}
346
+ selectionColor="rgb(160, 215, 42)"
347
+ style={
348
+ [
349
+ {
350
+ "fontFamily": "inter-medium",
351
+ },
352
+ {
353
+ "color": "rgba(101, 120, 132, 1)",
354
+ },
355
+ {
356
+ "textAlign": "right",
357
+ },
358
+ {
359
+ "fontSize": 14,
360
+ "lineHeight": 18,
361
+ },
362
+ {
363
+ "letterSpacing": 0,
364
+ },
365
+ ]
366
+ }
367
+ >
368
+ Informative
369
+ </Text>
370
+ </View>
371
+ <View
372
+ style={
373
+ {
374
+ "width": 8,
375
+ }
376
+ }
377
+ />
378
+ <View
379
+ style={
380
+ [
381
+ {
382
+ "backgroundColor": "rgb(125, 176, 14)",
383
+ "borderRadius": 2,
384
+ "height": 12,
385
+ "marginTop": 3,
386
+ "width": 12,
387
+ },
388
+ {
389
+ "backgroundColor": "rgb(60, 162, 224)",
390
+ },
391
+ ]
392
+ }
393
+ testID="informativeLabelIcon"
394
+ />
395
+ </View>
396
+ `;
397
+
398
+ exports[`StatusLabel status when status prop set to "warning" should match snapshot 1`] = `
399
+ <View
400
+ style={
401
+ [
402
+ {
403
+ "flexDirection": "row",
404
+ "flexWrap": "nowrap",
405
+ "justifyContent": "flex-end",
406
+ },
407
+ false,
408
+ ]
409
+ }
410
+ >
411
+ <View
412
+ style={
413
+ {
414
+ "flexShrink": 1,
415
+ }
416
+ }
417
+ >
418
+ <Text
419
+ accessibilityRole="text"
420
+ adjustsFontSizeToFit={false}
421
+ allowFontScaling={true}
422
+ collapsable={false}
423
+ maxFontSizeMultiplier={1.1428571428571428}
424
+ selectable={true}
425
+ selectionColor="rgb(160, 215, 42)"
426
+ style={
427
+ [
428
+ {
429
+ "fontFamily": "inter-medium",
430
+ },
431
+ {
432
+ "color": "rgba(101, 120, 132, 1)",
433
+ },
434
+ {
435
+ "textAlign": "right",
436
+ },
437
+ {
438
+ "fontSize": 14,
439
+ "lineHeight": 18,
440
+ },
441
+ {
442
+ "letterSpacing": 0,
443
+ },
444
+ ]
445
+ }
446
+ >
447
+ Warning
448
+ </Text>
449
+ </View>
450
+ <View
451
+ style={
452
+ {
453
+ "width": 8,
454
+ }
455
+ }
456
+ />
457
+ <View
458
+ style={
459
+ [
460
+ {
461
+ "backgroundColor": "rgb(125, 176, 14)",
462
+ "borderRadius": 2,
463
+ "height": 12,
464
+ "marginTop": 3,
465
+ "width": 12,
466
+ },
467
+ {
468
+ "backgroundColor": "rgb(221, 195, 15)",
469
+ },
470
+ ]
471
+ }
472
+ testID="warningLabelIcon"
473
+ />
474
+ </View>
475
+ `;
476
+
477
+ exports[`StatusLabel status when status prop set to default ("success") should match snapshot 1`] = `
478
+ <View
479
+ style={
480
+ [
481
+ {
482
+ "flexDirection": "row",
483
+ "flexWrap": "nowrap",
484
+ "justifyContent": "flex-end",
485
+ },
486
+ false,
487
+ ]
488
+ }
489
+ >
490
+ <View
491
+ style={
492
+ {
493
+ "flexShrink": 1,
494
+ }
495
+ }
496
+ >
497
+ <Text
498
+ accessibilityRole="text"
499
+ adjustsFontSizeToFit={false}
500
+ allowFontScaling={true}
501
+ collapsable={false}
502
+ maxFontSizeMultiplier={1.1428571428571428}
503
+ selectable={true}
504
+ selectionColor="rgb(160, 215, 42)"
505
+ style={
506
+ [
507
+ {
508
+ "fontFamily": "inter-medium",
509
+ },
510
+ {
511
+ "color": "rgba(101, 120, 132, 1)",
512
+ },
513
+ {
514
+ "textAlign": "right",
515
+ },
516
+ {
517
+ "fontSize": 14,
518
+ "lineHeight": 18,
519
+ },
520
+ {
521
+ "letterSpacing": 0,
522
+ },
523
+ ]
524
+ }
525
+ >
526
+ Success
527
+ </Text>
528
+ </View>
529
+ <View
530
+ style={
531
+ {
532
+ "width": 8,
533
+ }
534
+ }
535
+ />
536
+ <View
537
+ style={
538
+ [
539
+ {
540
+ "backgroundColor": "rgb(125, 176, 14)",
541
+ "borderRadius": 2,
542
+ "height": 12,
543
+ "marginTop": 3,
544
+ "width": 12,
545
+ },
546
+ {
547
+ "backgroundColor": "rgb(125, 176, 14)",
548
+ },
549
+ ]
550
+ }
551
+ testID="successLabelIcon"
552
+ />
553
+ </View>
554
+ `;
@@ -0,0 +1,2 @@
1
+ export { StatusLabel } from "./StatusLabel";
2
+ export type { StatusType, StatusLabelType } from "./StatusLabel";