@jobber/components-native 0.69.2 → 0.69.3-SCOTTTHd.45

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.
@@ -42,6 +42,10 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
42
42
  * Have text styled with strike through
43
43
  */
44
44
  readonly strikeThrough?: boolean;
45
+ /**
46
+ * Use italic font style
47
+ */
48
+ readonly italic?: boolean;
45
49
  /**
46
50
  * This will make the text inaccessible to the screen reader.
47
51
  * This should be avoided unless there is a good reason.
@@ -53,5 +57,5 @@ interface TextProps extends Pick<TypographyProps<"base">, "maxFontScaleSize" | "
53
57
  }
54
58
  export type TextLevel = "text" | "textSupporting";
55
59
  export declare const TEXT_MAX_SCALED_FONT_SIZES: Record<TextLevel, number>;
56
- export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, hideFromScreenReader, maxFontScaleSize, selectable, }: TextProps): JSX.Element;
60
+ export declare function Text({ level, variation, emphasis, allowFontScaling, adjustsFontSizeToFit, maxLines, align, children, reverseTheme, strikeThrough, italic, hideFromScreenReader, maxFontScaleSize, selectable, }: TextProps): JSX.Element;
57
61
  export {};
@@ -1,2 +1,2 @@
1
- import { tokens as mobileFoundationBase } from "@jobber/design/foundation.native";
2
- export declare const tokens: typeof mobileFoundationBase;
1
+ import { iosTokens } from "@jobber/design";
2
+ export declare const tokens: typeof iosTokens;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.69.2",
3
+ "version": "0.69.3-SCOTTTHd.45+8d76eff1",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -36,8 +36,6 @@
36
36
  "build:clean": "rm -rf ./dist"
37
37
  },
38
38
  "dependencies": {
39
- "@jobber/design": "^0.62.2",
40
- "@jobber/hooks": "^2.10.2",
41
39
  "@react-native-clipboard/clipboard": "^1.11.2",
42
40
  "@react-native-picker/picker": "^2.4.10",
43
41
  "autolinker": "^4.0.0",
@@ -70,8 +68,8 @@
70
68
  "peerDependencies": {
71
69
  "@babel/core": "^7.4.5",
72
70
  "@react-native-community/datetimepicker": ">=6.7.0",
73
- "date-fns": "^2.0.0",
74
- "date-fns-tz": "*",
71
+ "date-fns": "^2.30.0",
72
+ "date-fns-tz": "^2.0.0",
75
73
  "react": "^18.2.0",
76
74
  "react-intl": "^6.4.2",
77
75
  "react-native": ">=0.69.2",
@@ -84,5 +82,5 @@
84
82
  "react-native-safe-area-context": "^4.5.2",
85
83
  "react-native-svg": ">=12.0.0"
86
84
  },
87
- "gitHead": "286b357ffa0945aad45139fa031bee27bbb479eb"
85
+ "gitHead": "8d76eff16e7f4fad97727aff66cfb2435b30480a"
88
86
  }
@@ -1,7 +1,7 @@
1
1
  import React from "react";
2
2
  import { ColorValue, Pressable, View } from "react-native";
3
3
  import { XOR } from "ts-xor";
4
- import { tokens } from "@jobber/design/foundation";
4
+ import { tokens } from "@jobber/design";
5
5
  import { styles } from "./Checkbox.style";
6
6
  import { Text } from "../Text";
7
7
  import { Icon } from "../Icon";
@@ -35,7 +35,8 @@ export function FormActionBar({
35
35
  const buttonStyle = StyleSheet.flatten([
36
36
  styles.saveButton,
37
37
  {
38
- position: keyboardHeight > 0 ? "absolute" : "relative",
38
+ position:
39
+ keyboardHeight > 0 ? ("absolute" as const) : ("relative" as const),
39
40
  bottom: 0,
40
41
  },
41
42
  ]);
@@ -45,7 +46,6 @@ export function FormActionBar({
45
46
  };
46
47
 
47
48
  return (
48
- //@ts-expect-error tsc-ci
49
49
  <ReanimatedView style={buttonStyle} onLayout={onLayout}>
50
50
  {renderStickySection ? (
51
51
  renderStickySection(submit, saveButtonLabel, isFormSubmitting)
package/src/Icon/Icon.tsx CHANGED
@@ -1,15 +1,6 @@
1
1
  import React from "react";
2
- import Svg, { FillProps, Path, SvgProps } from "react-native-svg";
3
- import {
4
- IconColorNames,
5
- IconNames,
6
- IconSizes,
7
- colorsClassMap,
8
- getIcon,
9
- iconClassMap,
10
- iconStyles,
11
- sizesClassMap,
12
- } from "@jobber/design";
2
+ import Svg, { Path } from "react-native-svg";
3
+ import { IconColorNames, IconNames, IconSizes, getIcon } from "@jobber/design";
13
4
 
14
5
  export interface IconProps {
15
6
  /** The icon to show. */
@@ -46,72 +37,24 @@ export function Icon({
46
37
  customColor,
47
38
  testID,
48
39
  }: IconProps): JSX.Element {
49
- const { svgClassNames, pathClassNames, paths, viewBox } = getIcon({
40
+ const { svgStyle, pathStyle, paths, viewBox } = getIcon({
50
41
  name,
51
42
  color,
52
43
  size,
44
+ platform: "mobile",
45
+ format: "js",
53
46
  });
54
-
55
- /*
56
- * This is to fix a bug where icons with built-in colours do not respect
57
- * their color property. At time of writing, if you pass a color to getIcon,
58
- * pathClassNames will return the color class first in pathClassNames.
59
- * getSvgStyle applies styles in order, so the styles in the last class
60
- * processed take precedence.
61
- *
62
- * This fix reverses the order of pathClassNames, so any color-specific
63
- * CSS classes are processed last. The order of classes in pathClassNames
64
- * is not contractual, so this is potentially fragile if there are updates
65
- * to the @jobber/design package it comes from.
66
- */
67
- const reversedPathClassNames = pathClassNames.split(" ").reverse().join(" ");
68
-
69
- const svgStyle = getSvgStyle(svgClassNames + " " + reversedPathClassNames);
70
-
71
47
  const icon = paths.map((path: string) => {
72
- return <Path key={path} d={path} fill={customColor || svgStyle.fill} />;
48
+ return <Path key={path} d={path} fill={customColor || pathStyle.fill} />;
73
49
  });
74
50
 
75
51
  return (
76
- <Svg style={svgStyle} testID={testID || name} viewBox={viewBox}>
52
+ <Svg
53
+ style={{ ...svgStyle, display: "flex" }}
54
+ testID={testID || name}
55
+ viewBox={viewBox}
56
+ >
77
57
  {icon}
78
58
  </Svg>
79
59
  );
80
60
  }
81
-
82
- /*
83
- * get svg styles based on the class names
84
- * @param className - list of hashed names separated by space - "_2GsLyQLHv8yNULHeXGdver _1ANbiqwd8qgeLaumvLs27n"
85
- * @default ""
86
- * @return - style object for the icon - {"display": "flex" "height": 24, "width": 24, "verticalAlign": "middle" }
87
- *
88
- * Since the class names are hashed, we use the [name]ClassMap to find the actual class name. For example if we get
89
- * "_2GsLyQLHv8yNULHeXGdver _1ANbiqwd8qgeLaumvLs27n", it might map to ".icon .base". Then using the mapped class names,
90
- * we get the style from the css files which will be something like {"display": "flex" "height": 24, "width": 24, "verticalAlign": "middle" }
91
- *
92
- * Atlantis returns "display: inline-block" for icons, but since React Native doesn't support that, we override it with
93
- * the default "display" value for React Native which is "flex"
94
- */
95
- function getSvgStyle(classNames = ""): SvgProps["style"] & FillProps {
96
- const classMap = {
97
- ...iconClassMap,
98
- ...sizesClassMap,
99
- ...colorsClassMap,
100
- };
101
- const svgStyle = getStylesForClassNames(classNames.split(" "), classMap);
102
-
103
- return { ...svgStyle, display: "flex" };
104
- }
105
-
106
- function getStylesForClassNames(
107
- classNames: string[],
108
- classMap: Record<string, string>,
109
- ) {
110
- return classNames.reduce(
111
- (acc, className) => ({
112
- ...acc,
113
- ...iconStyles[classMap[className] as keyof typeof iconStyles],
114
- }),
115
- {},
116
- );
117
- }
@@ -50,7 +50,7 @@ exports[`renders apple icon 1`] = `
50
50
  d="M18.467 12.754c-.027-2.996 2.453-4.453 2.566-4.52-1.404-2.048-3.581-2.328-4.346-2.35-1.828-.193-3.601 1.094-4.533 1.094-.95 0-2.384-1.076-3.93-1.044-1.988.03-3.849 1.182-4.87 2.97C1.25 12.55 2.82 17.91 4.838 20.856c1.01 1.443 2.189 3.055 3.733 2.998 1.51-.062 2.074-.963 3.897-.963 1.806 0 2.335.963 3.91.927 1.62-.026 2.641-1.45 3.615-2.907 1.166-1.654 1.635-3.283 1.653-3.367-.038-.013-3.147-1.2-3.178-4.79Zm-2.974-8.81c.812-1.015 1.368-2.397 1.213-3.8-1.175.053-2.646.814-3.492 1.807-.75.876-1.418 2.31-1.246 3.66 1.321.099 2.677-.666 3.525-1.666Z"
51
51
  fill={
52
52
  {
53
- "payload": 4280499528,
53
+ "payload": 4278190080,
54
54
  "type": 0,
55
55
  }
56
56
  }
@@ -114,7 +114,7 @@ exports[`renders home icon 1`] = `
114
114
  d="M13.147 3.582a2 2 0 0 0-2.294 0l-9.426 6.599a1 1 0 1 0 1.147 1.638L5 10.121V18a3 3 0 0 0 3 3h8a3 3 0 0 0 3-3v-7.88l2.427 1.7a1 1 0 0 0 1.146-1.64l-9.426-6.598ZM17 8.721V18a1 1 0 0 1-1 1H8a1 1 0 0 1-1-1V8.72l5-3.5 5 3.5Z"
115
115
  fill={
116
116
  {
117
- "payload": 4280499528,
117
+ "payload": 4278190080,
118
118
  "type": 0,
119
119
  }
120
120
  }
@@ -178,7 +178,7 @@ exports[`renders large arrowDown icon 1`] = `
178
178
  d="M7.703 8.291a.996.996 0 0 0-1.41.001.994.994 0 0 0 0 1.41l5 5.005a.998.998 0 0 0 1.415 0l5-5a.994.994 0 0 0 0-1.41.995.995 0 0 0-1.411-.001L12 12.584 7.703 8.291Z"
179
179
  fill={
180
180
  {
181
- "payload": 4280499528,
181
+ "payload": 4278190080,
182
182
  "type": 0,
183
183
  }
184
184
  }
@@ -320,7 +320,7 @@ exports[`renders small more icon 1`] = `
320
320
  d="M4 12a2 2 0 1 1 4 0 2 2 0 0 1-4 0Zm6 0a2 2 0 1 1 4 0 2 2 0 0 1-4 0Zm8-2a2 2 0 1 0 0 4 2 2 0 0 0 0-4Z"
321
321
  fill={
322
322
  {
323
- "payload": 4280499528,
323
+ "payload": 4278190080,
324
324
  "type": 0,
325
325
  }
326
326
  }
@@ -453,7 +453,7 @@ exports[`renders thumbsDown icon 1`] = `
453
453
  d="M8 11.78V19h8l3-5.76v-1.29h-7.639l1.036-7.944L8 11.78ZM6.134 11l4.555-8.034c1.124-1.846 3.971-.844 3.691 1.299l-.74 5.685h6.86a.5.5 0 0 1 .5.5v3a1 1 0 0 1-.084.4l-3.276 6.648a.95.95 0 0 1-.44.453c-.132.065-.276.049-.423.049H4c-1.105 0-2-1.045-2-2.15V13a2 2 0 0 1 2-2h2.134ZM6 13H4v6h2v-6Z"
454
454
  fill={
455
455
  {
456
- "payload": 4280499528,
456
+ "payload": 4278190080,
457
457
  "type": 0,
458
458
  }
459
459
  }
@@ -1,4 +1,4 @@
1
- import { tokens } from "@jobber/design/foundation";
1
+ import { tokens } from "@jobber/design";
2
2
  import { StyleSheet } from "react-native";
3
3
  import { typographyStyles } from "../Typography/Typography.style";
4
4
 
@@ -127,6 +127,11 @@ it("renders with strikethrough styling", () => {
127
127
  expect(text.toJSON()).toMatchSnapshot();
128
128
  });
129
129
 
130
+ it("renders with italic styling", () => {
131
+ const text = render(<Text italic>Test Text</Text>);
132
+ expect(text.toJSON()).toMatchSnapshot();
133
+ });
134
+
130
135
  it("renders text that is inaccessible", () => {
131
136
  const text = render(<Text hideFromScreenReader={true}>Test Text</Text>);
132
137
  expect(text.root.props).toEqual(
package/src/Text/Text.tsx CHANGED
@@ -65,6 +65,11 @@ interface TextProps
65
65
  */
66
66
  readonly strikeThrough?: boolean;
67
67
 
68
+ /**
69
+ * Use italic font style
70
+ */
71
+ readonly italic?: boolean;
72
+
68
73
  /**
69
74
  * This will make the text inaccessible to the screen reader.
70
75
  * This should be avoided unless there is a good reason.
@@ -110,6 +115,7 @@ export function Text({
110
115
  children,
111
116
  reverseTheme = false,
112
117
  strikeThrough = false,
118
+ italic = false,
113
119
  hideFromScreenReader = false,
114
120
  maxFontScaleSize,
115
121
  selectable,
@@ -120,7 +126,7 @@ export function Text({
120
126
  <Typography
121
127
  color={variation}
122
128
  fontFamily="base"
123
- fontStyle="regular"
129
+ fontStyle={italic ? "italic" : "regular"}
124
130
  fontWeight={getFontWeight({ level, emphasis })}
125
131
  maxFontScaleSize={maxFontScaleSize || TEXT_MAX_SCALED_FONT_SIZES[level]}
126
132
  selectable={selectable}
@@ -133,6 +139,7 @@ export function Text({
133
139
  reverseTheme,
134
140
  maxLines,
135
141
  strikeThrough,
142
+ italic,
136
143
  hideFromScreenReader,
137
144
  }}
138
145
  >
@@ -580,6 +580,43 @@ exports[`renders text with warn variation 1`] = `
580
580
  </Text>
581
581
  `;
582
582
 
583
+ exports[`renders with italic styling 1`] = `
584
+ <Text
585
+ accessibilityRole="text"
586
+ adjustsFontSizeToFit={false}
587
+ allowFontScaling={true}
588
+ collapsable={false}
589
+ maxFontSizeMultiplier={3.125}
590
+ selectable={true}
591
+ selectionColor="hsl(86, 100%, 46%)"
592
+ style={
593
+ [
594
+ {
595
+ "fontFamily": "inter-italic",
596
+ },
597
+ {
598
+ "color": "hsl(198, 35%, 21%)",
599
+ },
600
+ {
601
+ "textAlign": "left",
602
+ },
603
+ {
604
+ "fontSize": 16,
605
+ "lineHeight": 20,
606
+ },
607
+ {
608
+ "letterSpacing": 0,
609
+ },
610
+ {
611
+ "fontStyle": "italic",
612
+ },
613
+ ]
614
+ }
615
+ >
616
+ Test Text
617
+ </Text>
618
+ `;
619
+
583
620
  exports[`renders with strikethrough styling 1`] = `
584
621
  <Text
585
622
  accessibilityRole="text"
@@ -9,7 +9,7 @@ const largerLineHeight = tokens["typography--lineHeight-larger"];
9
9
  const largeLineHeight = tokens["typography--lineHeight-large"];
10
10
  const baseLineHeight = tokens["typography--lineHeight-base"];
11
11
  const tightLineHeight = tokens["typography--lineHeight-tight"];
12
- const minisculeLineHeight = tokens["typography--lineHeight-miniscule"];
12
+ const minusculeLineHeight = tokens["typography--lineHeight-minuscule"];
13
13
 
14
14
  const deviceFonts = {
15
15
  baseRegularRegular: {
@@ -32,6 +32,26 @@ const deviceFonts = {
32
32
  fontFamily: "inter-extrabold",
33
33
  },
34
34
 
35
+ baseItalicRegular: {
36
+ fontFamily: "inter-italic",
37
+ },
38
+
39
+ baseItalicMedium: {
40
+ fontFamily: "inter-italic-medium",
41
+ },
42
+
43
+ baseItalicBold: {
44
+ fontFamily: "inter-italic-bold",
45
+ },
46
+
47
+ baseItalicSemiBold: {
48
+ fontFamily: "inter-italic-semibold",
49
+ },
50
+
51
+ baseItalicExtraBold: {
52
+ fontFamily: "inter-italic-extrabold",
53
+ },
54
+
35
55
  displayRegularBold: {
36
56
  fontFamily: "jobberpro-bd",
37
57
  },
@@ -64,6 +84,10 @@ export const typographyTokens: { [index: string]: TextStyle } = {
64
84
  // { fontFamily }{ fontStyle }{ fontWeight }
65
85
  ...fonts,
66
86
 
87
+ italic: {
88
+ fontStyle: "italic",
89
+ },
90
+
67
91
  startAlign: {
68
92
  textAlign: "left",
69
93
  },
@@ -282,7 +306,7 @@ export const typographyTokens: { [index: string]: TextStyle } = {
282
306
 
283
307
  smallestSize: {
284
308
  fontSize: tokens["typography--fontSize-smallest"],
285
- lineHeight: minisculeLineHeight,
309
+ lineHeight: minusculeLineHeight,
286
310
  },
287
311
 
288
312
  smallerSize: {
@@ -106,6 +106,7 @@ export interface TypographyProps<T extends FontFamily>
106
106
  * of the TextInput
107
107
  */
108
108
  readonly hideFromScreenReader?: boolean;
109
+
109
110
  /**
110
111
  * Have text styled with strike through
111
112
  */
@@ -156,6 +157,11 @@ function InternalTypography<T extends FontFamily = "base">({
156
157
  if (strikeThrough) {
157
158
  style.push(styles.strikeThrough);
158
159
  }
160
+
161
+ if (fontStyle === "italic") {
162
+ style.push(styles.italic);
163
+ }
164
+
159
165
  const numberOfLinesForNativeText = maxNumberOfLines[maxLines];
160
166
 
161
167
  const text = getTransformedText(children, transform);
@@ -211,7 +211,7 @@ exports[`renders text with bold weight and italic style 1`] = `
211
211
  style={
212
212
  [
213
213
  {
214
- "fontFamily": "inter-regular",
214
+ "fontFamily": "inter-italic-bold",
215
215
  },
216
216
  {
217
217
  "color": "hsl(197, 15%, 45%)",
@@ -226,6 +226,9 @@ exports[`renders text with bold weight and italic style 1`] = `
226
226
  {
227
227
  "letterSpacing": 0,
228
228
  },
229
+ {
230
+ "fontStyle": "italic",
231
+ },
229
232
  ]
230
233
  }
231
234
  >
@@ -409,7 +412,7 @@ exports[`renders text with italic style 1`] = `
409
412
  style={
410
413
  [
411
414
  {
412
- "fontFamily": "inter-regular",
415
+ "fontFamily": "inter-italic",
413
416
  },
414
417
  {
415
418
  "color": "hsl(197, 15%, 45%)",
@@ -424,6 +427,9 @@ exports[`renders text with italic style 1`] = `
424
427
  {
425
428
  "letterSpacing": 0,
426
429
  },
430
+ {
431
+ "fontStyle": "italic",
432
+ },
427
433
  ]
428
434
  }
429
435
  >
@@ -1,8 +1,8 @@
1
- import { tokens as mobileFoundationBase } from "@jobber/design/foundation.native";
2
1
  import { Platform } from "react-native";
2
+ import { androidTokens, iosTokens } from "@jobber/design";
3
3
 
4
- export const tokens: typeof mobileFoundationBase = Platform.select({
5
- ios: () => require("@jobber/design/foundation.ios").tokens,
6
- android: () => require("@jobber/design/foundation.android").tokens,
7
- default: () => require("@jobber/design/foundation.native").tokens,
4
+ export const tokens: typeof iosTokens = Platform.select({
5
+ ios: () => iosTokens,
6
+ android: () => androidTokens,
7
+ default: () => androidTokens,
8
8
  })();