@jobber/components-native 0.71.2 → 0.72.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.
@@ -46,6 +46,12 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
46
46
  * Use italic font style
47
47
  */
48
48
  readonly italic?: boolean;
49
+ /**
50
+ * Underline style to use for the text. The non-solid style is only supported
51
+ * on iOS, as per React Native's Text component's limitations.
52
+ * https://reactnative.dev/docs/text-style-props#textdecorationstyle-ios
53
+ */
54
+ readonly underline?: "solid" | "dotted";
49
55
  /**
50
56
  * This will make the text inaccessible to the screen reader.
51
57
  * This should be avoided unless there is a good reason.
@@ -57,5 +63,5 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
57
63
  }
58
64
  export type TextLevel = "text" | "textSupporting";
59
65
  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;
66
+ export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, italic, hideFromScreenReader, maxFontScaleSize, underline, selectable, }: TextProps): JSX.Element;
61
67
  export {};
@@ -55,6 +55,12 @@ 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
+ * Underline style to use for the text. The non-solid style is only supported
60
+ * on iOS, as per React Native's Text component's limitations.
61
+ * https://reactnative.dev/docs/text-style-props#textdecorationstyle-ios
62
+ */
63
+ readonly underline?: "solid" | "double" | "dotted" | "dashed" | undefined;
58
64
  /**
59
65
  * Font weight
60
66
  */
@@ -81,7 +87,7 @@ export interface TypographyProps<T extends FontFamily> extends Pick<TextProps, "
81
87
  readonly strikeThrough?: boolean;
82
88
  }
83
89
  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;
90
+ 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
91
  export type FontFamily = "base" | "display";
86
92
  export type FontStyle = "regular" | "italic";
87
93
  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.72.0",
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": "26cb076b2f8a8cbdaee1df6be72b211987a4e5eb"
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,13 @@ interface TextProps
70
70
  */
71
71
  readonly italic?: boolean;
72
72
 
73
+ /**
74
+ * Underline style to use for the text. The non-solid style is only supported
75
+ * on iOS, as per React Native's Text component's limitations.
76
+ * https://reactnative.dev/docs/text-style-props#textdecorationstyle-ios
77
+ */
78
+ readonly underline?: "solid" | "dotted";
79
+
73
80
  /**
74
81
  * This will make the text inaccessible to the screen reader.
75
82
  * This should be avoided unless there is a good reason.
@@ -118,6 +125,7 @@ export function Text({
118
125
  italic = false,
119
126
  hideFromScreenReader = false,
120
127
  maxFontScaleSize,
128
+ underline,
121
129
  selectable,
122
130
  }: TextProps): JSX.Element {
123
131
  const accessibilityRole: TextAccessibilityRole = "text";
@@ -130,6 +138,7 @@ export function Text({
130
138
  fontWeight={getFontWeight({ level, emphasis })}
131
139
  maxFontScaleSize={maxFontScaleSize || TEXT_MAX_SCALED_FONT_SIZES[level]}
132
140
  selectable={selectable}
141
+ underline={underline}
133
142
  {...{
134
143
  ...levelStyles[level],
135
144
  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,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);
@@ -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
+ `;