@jobber/components-native 0.71.2-TAYLORmax-6e14b32.19 → 0.71.2-improve-di-796b148.24

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.
@@ -7,6 +7,7 @@ import {
7
7
  // eslint-disable-next-line no-restricted-imports
8
8
  Text,
9
9
  TextProps,
10
+ TextStyle,
10
11
  ViewStyle,
11
12
  } from "react-native";
12
13
  import { TypographyGestureDetector } from "./TypographyGestureDetector";
@@ -83,6 +84,13 @@ export interface TypographyProps<T extends FontFamily>
83
84
  */
84
85
  readonly fontStyle?: T extends "base" ? BaseStyle : DisplayStyle;
85
86
 
87
+ /**
88
+ * Underline style to use for the text. The non-solid style is only supported
89
+ * on iOS, as per React Native's Text component's limitations.
90
+ * https://reactnative.dev/docs/text-style-props#textdecorationstyle-ios
91
+ */
92
+ readonly underline?: "solid" | "double" | "dotted" | "dashed" | undefined;
93
+
86
94
  /**
87
95
  * Font weight
88
96
  */
@@ -124,6 +132,7 @@ const maxNumberOfLines = {
124
132
 
125
133
  export const Typography = React.memo(InternalTypography);
126
134
 
135
+ // eslint-disable-next-line max-statements
127
136
  function InternalTypography<T extends FontFamily = "base">({
128
137
  fontFamily,
129
138
  fontStyle,
@@ -143,6 +152,7 @@ function InternalTypography<T extends FontFamily = "base">({
143
152
  hideFromScreenReader = false,
144
153
  accessibilityRole = "text",
145
154
  strikeThrough = false,
155
+ underline,
146
156
  selectable = true,
147
157
  }: TypographyProps<T>): JSX.Element {
148
158
  const sizeAndHeight = getSizeAndHeightStyle(size, lineHeight);
@@ -162,6 +172,11 @@ function InternalTypography<T extends FontFamily = "base">({
162
172
  style.push(styles.italic);
163
173
  }
164
174
 
175
+ if (underline) {
176
+ const underlineTextStyle: TextStyle = { textDecorationStyle: underline };
177
+ style.push(underlineTextStyle, styles.underline);
178
+ }
179
+
165
180
  const numberOfLinesForNativeText = maxNumberOfLines[maxLines];
166
181
 
167
182
  const text = getTransformedText(children, transform);
@@ -295,8 +310,8 @@ export type DisplayStyle = Extract<FontStyle, "regular">;
295
310
 
296
311
  export type TextColor =
297
312
  | TextVariation
313
+ // Base colors for backwards compatibility
298
314
  | "default"
299
- | "blue"
300
315
  | "blueDark"
301
316
  | "white"
302
317
  | "green"
@@ -320,27 +335,89 @@ export type TextColor =
320
335
  | "tealDark"
321
336
  | "indigoDark"
322
337
  | "navy"
323
- | "text"
338
+
339
+ // Typography
324
340
  | "heading"
341
+ | "text"
325
342
  | "textSecondary"
326
343
  | "textReverse"
327
344
  | "textReverseSecondary"
328
- | "interactive"
329
- | "destructive"
330
- | "learning"
331
- | "subtle"
332
- | "onPrimary";
333
345
 
334
- export type TextVariation =
346
+ // Statuses
347
+ | "inactive"
348
+ | "inactiveSurface"
349
+ | "inactiveOnSurface"
350
+ | "critical"
351
+ | "criticalSurface"
352
+ | "criticalOnSurface"
353
+ | "warning"
354
+ | "warningSurface"
355
+ | "warningOnSurface"
356
+ | "informative"
357
+ | "informativeSurface"
358
+ | "informativeOnSurface"
335
359
  | "success"
360
+ | "successSurface"
361
+ | "successOnSurface"
362
+
363
+ // Interactions
364
+ | "interactiveHover"
365
+ | "interactiveSubtleHover"
366
+ | "destructiveHover"
367
+ | "disabledSecondary"
368
+
369
+ // Workflow
370
+ | "request"
371
+ | "requestSurface"
372
+ | "requestOnSurface"
373
+ | "quote"
374
+ | "quoteSurface"
375
+ | "quoteOnSurface"
376
+ | "job"
377
+ | "jobSurface"
378
+ | "jobOnSurface"
379
+ | "visit"
380
+ | "visitSurface"
381
+ | "visitOnSurface"
382
+ | "task"
383
+ | "taskSurface"
384
+ | "taskOnSurface"
385
+ | "event"
386
+ | "eventSurface"
387
+ | "eventOnSurface"
388
+ | "invoice"
389
+ | "invoiceSurface"
390
+ | "invoiceOnSurface"
391
+ | "payments"
392
+ | "paymentsSurface"
393
+ | "paymentsOnSurface"
394
+ | "client"
395
+
396
+ // Deprecated
397
+ | "blue" // Use "heading" instead
398
+ | "learning" // Use "informative" instead
399
+ | "subtle" // Use "interactiveSubtle" instead
400
+ | "onPrimary"; // Use "subtle" instead
401
+
402
+ // A subset of colors that can be used with the Text component
403
+ export type TextVariation =
404
+ | "text"
405
+ | "textSecondary"
336
406
  | "interactive"
337
- | "error"
338
- | "base"
339
- | "subdued"
340
- | "warn"
341
- | "info"
407
+ | "interactiveSubtle"
408
+ | "successOnSurface"
409
+ | "critical"
410
+ | "warning"
411
+ | "informativeOnSurface"
342
412
  | "disabled"
343
- | "critical";
413
+ | "destructive"
414
+
415
+ // Deprecated
416
+ | "base" // Use "text" instead
417
+ | "subdued" // Use "textSecondary" instead
418
+ | "error" // Use "critical" instead
419
+ | "warn" // Use "warningOnSurface" instead
420
+ | "info"; // Use "informativeOnSurface" instead
344
421
 
345
422
  export type TextTransform = "uppercase" | "lowercase" | "capitalize" | "none";
346
423
 
@@ -734,6 +734,39 @@ exports[`renders text with reverseTheme true with reversible color 1`] = `
734
734
  </Text>
735
735
  `;
736
736
 
737
+ exports[`renders text with semantic color 1`] = `
738
+ <Text
739
+ accessibilityRole="text"
740
+ adjustsFontSizeToFit={false}
741
+ allowFontScaling={true}
742
+ collapsable={false}
743
+ selectable={true}
744
+ selectionColor="hsl(86, 100%, 46%)"
745
+ style={
746
+ [
747
+ {
748
+ "fontFamily": "inter-regular",
749
+ },
750
+ {
751
+ "color": "hsl(197, 90%, 12%)",
752
+ },
753
+ {
754
+ "textAlign": "left",
755
+ },
756
+ {
757
+ "fontSize": 16,
758
+ "lineHeight": 20,
759
+ },
760
+ {
761
+ "letterSpacing": 0,
762
+ },
763
+ ]
764
+ }
765
+ >
766
+ Test Text
767
+ </Text>
768
+ `;
769
+
737
770
  exports[`renders text with small size 1`] = `
738
771
  <Text
739
772
  accessibilityRole="text"
@@ -868,3 +901,163 @@ exports[`renders text with white color 1`] = `
868
901
  Test Text
869
902
  </Text>
870
903
  `;
904
+
905
+ exports[`underline renders text with dashed underline 1`] = `
906
+ <Text
907
+ accessibilityRole="text"
908
+ adjustsFontSizeToFit={false}
909
+ allowFontScaling={true}
910
+ collapsable={false}
911
+ selectable={true}
912
+ selectionColor="hsl(86, 100%, 46%)"
913
+ style={
914
+ [
915
+ {
916
+ "fontFamily": "inter-regular",
917
+ },
918
+ {
919
+ "color": "hsl(197, 15%, 45%)",
920
+ },
921
+ {
922
+ "textAlign": "left",
923
+ },
924
+ {
925
+ "fontSize": 16,
926
+ "lineHeight": 20,
927
+ },
928
+ {
929
+ "letterSpacing": 0,
930
+ },
931
+ {
932
+ "textDecorationStyle": "dashed",
933
+ },
934
+ {
935
+ "textDecorationColor": "hsl(197, 15%, 45%)",
936
+ "textDecorationLine": "underline",
937
+ },
938
+ ]
939
+ }
940
+ >
941
+ Test Text
942
+ </Text>
943
+ `;
944
+
945
+ exports[`underline renders text with dotted underline 1`] = `
946
+ <Text
947
+ accessibilityRole="text"
948
+ adjustsFontSizeToFit={false}
949
+ allowFontScaling={true}
950
+ collapsable={false}
951
+ selectable={true}
952
+ selectionColor="hsl(86, 100%, 46%)"
953
+ style={
954
+ [
955
+ {
956
+ "fontFamily": "inter-regular",
957
+ },
958
+ {
959
+ "color": "hsl(197, 15%, 45%)",
960
+ },
961
+ {
962
+ "textAlign": "left",
963
+ },
964
+ {
965
+ "fontSize": 16,
966
+ "lineHeight": 20,
967
+ },
968
+ {
969
+ "letterSpacing": 0,
970
+ },
971
+ {
972
+ "textDecorationStyle": "dotted",
973
+ },
974
+ {
975
+ "textDecorationColor": "hsl(197, 15%, 45%)",
976
+ "textDecorationLine": "underline",
977
+ },
978
+ ]
979
+ }
980
+ >
981
+ Test Text
982
+ </Text>
983
+ `;
984
+
985
+ exports[`underline renders text with double underline 1`] = `
986
+ <Text
987
+ accessibilityRole="text"
988
+ adjustsFontSizeToFit={false}
989
+ allowFontScaling={true}
990
+ collapsable={false}
991
+ selectable={true}
992
+ selectionColor="hsl(86, 100%, 46%)"
993
+ style={
994
+ [
995
+ {
996
+ "fontFamily": "inter-regular",
997
+ },
998
+ {
999
+ "color": "hsl(197, 15%, 45%)",
1000
+ },
1001
+ {
1002
+ "textAlign": "left",
1003
+ },
1004
+ {
1005
+ "fontSize": 16,
1006
+ "lineHeight": 20,
1007
+ },
1008
+ {
1009
+ "letterSpacing": 0,
1010
+ },
1011
+ {
1012
+ "textDecorationStyle": "double",
1013
+ },
1014
+ {
1015
+ "textDecorationColor": "hsl(197, 15%, 45%)",
1016
+ "textDecorationLine": "underline",
1017
+ },
1018
+ ]
1019
+ }
1020
+ >
1021
+ Test Text
1022
+ </Text>
1023
+ `;
1024
+
1025
+ exports[`underline renders text with solid underline 1`] = `
1026
+ <Text
1027
+ accessibilityRole="text"
1028
+ adjustsFontSizeToFit={false}
1029
+ allowFontScaling={true}
1030
+ collapsable={false}
1031
+ selectable={true}
1032
+ selectionColor="hsl(86, 100%, 46%)"
1033
+ style={
1034
+ [
1035
+ {
1036
+ "fontFamily": "inter-regular",
1037
+ },
1038
+ {
1039
+ "color": "hsl(197, 15%, 45%)",
1040
+ },
1041
+ {
1042
+ "textAlign": "left",
1043
+ },
1044
+ {
1045
+ "fontSize": 16,
1046
+ "lineHeight": 20,
1047
+ },
1048
+ {
1049
+ "letterSpacing": 0,
1050
+ },
1051
+ {
1052
+ "textDecorationStyle": "solid",
1053
+ },
1054
+ {
1055
+ "textDecorationColor": "hsl(197, 15%, 45%)",
1056
+ "textDecorationLine": "underline",
1057
+ },
1058
+ ]
1059
+ }
1060
+ >
1061
+ Test Text
1062
+ </Text>
1063
+ `;