@jobber/components-native 0.71.2 → 0.71.3-JOB-104505-f142a3c.4

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.
@@ -46,6 +46,10 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
46
46
  * Use italic font style
47
47
  */
48
48
  readonly italic?: boolean;
49
+ /**
50
+ * Underline text
51
+ */
52
+ readonly underline?: "solid" | "dotted";
49
53
  /**
50
54
  * This will make the text inaccessible to the screen reader.
51
55
  * This should be avoided unless there is a good reason.
@@ -57,5 +61,5 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
57
61
  }
58
62
  export type TextLevel = "text" | "textSupporting";
59
63
  export declare const TEXT_MAX_SCALED_FONT_SIZES: Record<TextLevel, number>;
60
- export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, italic, hideFromScreenReader, maxFontScaleSize, selectable, }: TextProps): JSX.Element;
64
+ export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, italic, hideFromScreenReader, maxFontScaleSize, underline, selectable, }: TextProps): JSX.Element;
61
65
  export {};
@@ -55,6 +55,10 @@ export interface TypographyProps<T extends FontFamily> extends Pick<TextProps, "
55
55
  * Font style
56
56
  */
57
57
  readonly fontStyle?: T extends "base" ? BaseStyle : DisplayStyle;
58
+ /**
59
+ * Style of underline for the text
60
+ */
61
+ readonly underline?: "solid" | "double" | "dotted" | "dashed" | undefined;
58
62
  /**
59
63
  * Font weight
60
64
  */
@@ -81,7 +85,7 @@ export interface TypographyProps<T extends FontFamily> extends Pick<TextProps, "
81
85
  readonly strikeThrough?: boolean;
82
86
  }
83
87
  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;
88
+ 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, underline, selectable, }: TypographyProps<T>): JSX.Element;
85
89
  export type FontFamily = "base" | "display";
86
90
  export type FontStyle = "regular" | "italic";
87
91
  export type FontWeight = "regular" | "medium" | "bold" | "semiBold" | "extraBold" | "black";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.71.2",
3
+ "version": "0.71.3-JOB-104505-f142a3c.4+f142a3c3",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -82,5 +82,5 @@
82
82
  "react-native-safe-area-context": "^4.5.2",
83
83
  "react-native-svg": ">=12.0.0"
84
84
  },
85
- "gitHead": "88ff540bdd1af6f58af44e60d20fe00921084adb"
85
+ "gitHead": "f142a3c38918be56d7fd5af3d679c0940f89c51c"
86
86
  }
@@ -142,3 +142,9 @@ it("renders text that is inaccessible", () => {
142
142
  }),
143
143
  );
144
144
  });
145
+
146
+ it("renders text with underline styling", () => {
147
+ const text = render(<Text underline="dashed">Test Text</Text>);
148
+
149
+ expect(text.toJSON()).toMatchSnapshot();
150
+ });
package/src/Text/Text.tsx CHANGED
@@ -70,6 +70,11 @@ interface TextProps
70
70
  */
71
71
  readonly italic?: boolean;
72
72
 
73
+ /**
74
+ * Underline text
75
+ */
76
+ readonly underline?: "solid" | "dotted";
77
+
73
78
  /**
74
79
  * This will make the text inaccessible to the screen reader.
75
80
  * This should be avoided unless there is a good reason.
@@ -118,6 +123,7 @@ export function Text({
118
123
  italic = false,
119
124
  hideFromScreenReader = false,
120
125
  maxFontScaleSize,
126
+ underline,
121
127
  selectable,
122
128
  }: TextProps): JSX.Element {
123
129
  const accessibilityRole: TextAccessibilityRole = "text";
@@ -130,6 +136,7 @@ export function Text({
130
136
  fontWeight={getFontWeight({ level, emphasis })}
131
137
  maxFontScaleSize={maxFontScaleSize || TEXT_MAX_SCALED_FONT_SIZES[level]}
132
138
  selectable={selectable}
139
+ underline={underline}
133
140
  {...{
134
141
  ...levelStyles[level],
135
142
  allowFontScaling,
@@ -546,6 +546,47 @@ exports[`renders text with success variation reverseTheme true 1`] = `
546
546
  </Text>
547
547
  `;
548
548
 
549
+ exports[`renders text with underline styling 1`] = `
550
+ <Text
551
+ accessibilityRole="text"
552
+ adjustsFontSizeToFit={false}
553
+ allowFontScaling={true}
554
+ collapsable={false}
555
+ maxFontSizeMultiplier={3.125}
556
+ selectable={true}
557
+ selectionColor="hsl(86, 100%, 46%)"
558
+ style={
559
+ [
560
+ {
561
+ "fontFamily": "inter-regular",
562
+ },
563
+ {
564
+ "color": "hsl(198, 35%, 21%)",
565
+ },
566
+ {
567
+ "textAlign": "left",
568
+ },
569
+ {
570
+ "fontSize": 16,
571
+ "lineHeight": 20,
572
+ },
573
+ {
574
+ "letterSpacing": 0,
575
+ },
576
+ {
577
+ "textDecorationStyle": "dashed",
578
+ },
579
+ {
580
+ "textDecorationColor": "hsl(197, 15%, 45%)",
581
+ "textDecorationLine": "underline",
582
+ },
583
+ ]
584
+ }
585
+ >
586
+ Test Text
587
+ </Text>
588
+ `;
589
+
549
590
  exports[`renders text with warn variation 1`] = `
550
591
  <Text
551
592
  accessibilityRole="text"
@@ -88,6 +88,11 @@ export const typographyTokens: { [index: string]: TextStyle } = {
88
88
  fontStyle: "italic",
89
89
  },
90
90
 
91
+ underline: {
92
+ textDecorationColor: tokens["color-text--secondary"],
93
+ textDecorationLine: "underline",
94
+ },
95
+
91
96
  startAlign: {
92
97
  textAlign: "left",
93
98
  },
@@ -217,3 +217,16 @@ it("renders text that is inaccessible", () => {
217
217
  }),
218
218
  );
219
219
  });
220
+
221
+ describe("underline", () => {
222
+ it.each(["solid", "double", "dotted", "dashed"] as const)(
223
+ "renders text with %s underline",
224
+ underlineStyle => {
225
+ const typography = render(
226
+ <Typography underline={underlineStyle}>Test Text</Typography>,
227
+ );
228
+
229
+ expect(typography.toJSON()).toMatchSnapshot();
230
+ },
231
+ );
232
+ });
@@ -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,11 @@ export interface TypographyProps<T extends FontFamily>
83
84
  */
84
85
  readonly fontStyle?: T extends "base" ? BaseStyle : DisplayStyle;
85
86
 
87
+ /**
88
+ * Style of underline for the text
89
+ */
90
+ readonly underline?: "solid" | "double" | "dotted" | "dashed" | undefined;
91
+
86
92
  /**
87
93
  * Font weight
88
94
  */
@@ -124,6 +130,7 @@ const maxNumberOfLines = {
124
130
 
125
131
  export const Typography = React.memo(InternalTypography);
126
132
 
133
+ // eslint-disable-next-line max-statements
127
134
  function InternalTypography<T extends FontFamily = "base">({
128
135
  fontFamily,
129
136
  fontStyle,
@@ -143,6 +150,7 @@ function InternalTypography<T extends FontFamily = "base">({
143
150
  hideFromScreenReader = false,
144
151
  accessibilityRole = "text",
145
152
  strikeThrough = false,
153
+ underline,
146
154
  selectable = true,
147
155
  }: TypographyProps<T>): JSX.Element {
148
156
  const sizeAndHeight = getSizeAndHeightStyle(size, lineHeight);
@@ -162,6 +170,11 @@ function InternalTypography<T extends FontFamily = "base">({
162
170
  style.push(styles.italic);
163
171
  }
164
172
 
173
+ if (underline) {
174
+ const underlineTextStyle: TextStyle = { textDecorationStyle: underline };
175
+ style.push(underlineTextStyle, styles.underline);
176
+ }
177
+
165
178
  const numberOfLinesForNativeText = maxNumberOfLines[maxLines];
166
179
 
167
180
  const text = getTransformedText(children, transform);
@@ -868,3 +868,163 @@ exports[`renders text with white color 1`] = `
868
868
  Test Text
869
869
  </Text>
870
870
  `;
871
+
872
+ exports[`underline renders text with dashed underline 1`] = `
873
+ <Text
874
+ accessibilityRole="text"
875
+ adjustsFontSizeToFit={false}
876
+ allowFontScaling={true}
877
+ collapsable={false}
878
+ selectable={true}
879
+ selectionColor="hsl(86, 100%, 46%)"
880
+ style={
881
+ [
882
+ {
883
+ "fontFamily": "inter-regular",
884
+ },
885
+ {
886
+ "color": "hsl(197, 15%, 45%)",
887
+ },
888
+ {
889
+ "textAlign": "left",
890
+ },
891
+ {
892
+ "fontSize": 16,
893
+ "lineHeight": 20,
894
+ },
895
+ {
896
+ "letterSpacing": 0,
897
+ },
898
+ {
899
+ "textDecorationStyle": "dashed",
900
+ },
901
+ {
902
+ "textDecorationColor": "hsl(197, 15%, 45%)",
903
+ "textDecorationLine": "underline",
904
+ },
905
+ ]
906
+ }
907
+ >
908
+ Test Text
909
+ </Text>
910
+ `;
911
+
912
+ exports[`underline renders text with dotted underline 1`] = `
913
+ <Text
914
+ accessibilityRole="text"
915
+ adjustsFontSizeToFit={false}
916
+ allowFontScaling={true}
917
+ collapsable={false}
918
+ selectable={true}
919
+ selectionColor="hsl(86, 100%, 46%)"
920
+ style={
921
+ [
922
+ {
923
+ "fontFamily": "inter-regular",
924
+ },
925
+ {
926
+ "color": "hsl(197, 15%, 45%)",
927
+ },
928
+ {
929
+ "textAlign": "left",
930
+ },
931
+ {
932
+ "fontSize": 16,
933
+ "lineHeight": 20,
934
+ },
935
+ {
936
+ "letterSpacing": 0,
937
+ },
938
+ {
939
+ "textDecorationStyle": "dotted",
940
+ },
941
+ {
942
+ "textDecorationColor": "hsl(197, 15%, 45%)",
943
+ "textDecorationLine": "underline",
944
+ },
945
+ ]
946
+ }
947
+ >
948
+ Test Text
949
+ </Text>
950
+ `;
951
+
952
+ exports[`underline renders text with double underline 1`] = `
953
+ <Text
954
+ accessibilityRole="text"
955
+ adjustsFontSizeToFit={false}
956
+ allowFontScaling={true}
957
+ collapsable={false}
958
+ selectable={true}
959
+ selectionColor="hsl(86, 100%, 46%)"
960
+ style={
961
+ [
962
+ {
963
+ "fontFamily": "inter-regular",
964
+ },
965
+ {
966
+ "color": "hsl(197, 15%, 45%)",
967
+ },
968
+ {
969
+ "textAlign": "left",
970
+ },
971
+ {
972
+ "fontSize": 16,
973
+ "lineHeight": 20,
974
+ },
975
+ {
976
+ "letterSpacing": 0,
977
+ },
978
+ {
979
+ "textDecorationStyle": "double",
980
+ },
981
+ {
982
+ "textDecorationColor": "hsl(197, 15%, 45%)",
983
+ "textDecorationLine": "underline",
984
+ },
985
+ ]
986
+ }
987
+ >
988
+ Test Text
989
+ </Text>
990
+ `;
991
+
992
+ exports[`underline renders text with solid underline 1`] = `
993
+ <Text
994
+ accessibilityRole="text"
995
+ adjustsFontSizeToFit={false}
996
+ allowFontScaling={true}
997
+ collapsable={false}
998
+ selectable={true}
999
+ selectionColor="hsl(86, 100%, 46%)"
1000
+ style={
1001
+ [
1002
+ {
1003
+ "fontFamily": "inter-regular",
1004
+ },
1005
+ {
1006
+ "color": "hsl(197, 15%, 45%)",
1007
+ },
1008
+ {
1009
+ "textAlign": "left",
1010
+ },
1011
+ {
1012
+ "fontSize": 16,
1013
+ "lineHeight": 20,
1014
+ },
1015
+ {
1016
+ "letterSpacing": 0,
1017
+ },
1018
+ {
1019
+ "textDecorationStyle": "solid",
1020
+ },
1021
+ {
1022
+ "textDecorationColor": "hsl(197, 15%, 45%)",
1023
+ "textDecorationLine": "underline",
1024
+ },
1025
+ ]
1026
+ }
1027
+ >
1028
+ Test Text
1029
+ </Text>
1030
+ `;