@jobber/components-native 0.114.0 → 0.114.2

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.
@@ -5,6 +5,7 @@ export declare const useStyles: () => {
5
5
  background: {
6
6
  borderTopLeftRadius: number;
7
7
  borderTopRightRadius: number;
8
+ backgroundColor: string;
8
9
  };
9
10
  footerContainer: {
10
11
  backgroundColor: string;
@@ -26,6 +26,7 @@ interface GlimmerProps {
26
26
  readonly width?: number | `${number}%`;
27
27
  }
28
28
  export declare const GLIMMER_TEST_ID = "ATL-Glimmer";
29
+ export declare const GLIMMER_BACKGROUND_TEST_ID = "ATL-Glimmer-Background";
29
30
  export declare const GLIMMER_SHINE_TEST_ID = "ATL-Glimmer-Shine";
30
31
  export declare function Glimmer({ width, shape, size, timing, }: GlimmerProps): React.JSX.Element;
31
32
  export {};
@@ -1,13 +1,21 @@
1
1
  export declare const shineWidth: number;
2
2
  export declare const useStyles: () => {
3
3
  container: {
4
- backgroundColor: string;
5
4
  overflow: "hidden";
6
5
  position: "relative";
7
6
  width: "100%";
8
7
  height: number;
9
8
  borderRadius: number;
10
9
  };
10
+ background: {
11
+ position: "absolute";
12
+ top: number;
13
+ left: number;
14
+ width: "100%";
15
+ height: "100%";
16
+ backgroundColor: string;
17
+ opacity: number;
18
+ };
11
19
  shine: {
12
20
  position: "absolute";
13
21
  top: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jobber/components-native",
3
- "version": "0.114.0",
3
+ "version": "0.114.2",
4
4
  "license": "MIT",
5
5
  "description": "React Native implementation of Atlantis",
6
6
  "repository": {
@@ -123,5 +123,5 @@
123
123
  "react-native-screens": ">=4.18.0",
124
124
  "react-native-svg": ">=12.0.0"
125
125
  },
126
- "gitHead": "d79c88a2241ded3f29e879cd3c0d5a1e2dceb568"
126
+ "gitHead": "063105930b808aca83b9c45624e4319711165b68"
127
127
  }
@@ -10,6 +10,7 @@ export const useStyles = buildThemedStyles(tokens => {
10
10
  background: {
11
11
  borderTopLeftRadius: modalBorderRadius,
12
12
  borderTopRightRadius: modalBorderRadius,
13
+ backgroundColor: tokens["color-surface"],
13
14
  },
14
15
  footerContainer: {
15
16
  backgroundColor: tokens["color-surface"],
@@ -6,7 +6,6 @@ export const shineWidth = staticTokens["space-largest"];
6
6
  export const useStyles = buildThemedStyles(tokens => {
7
7
  return {
8
8
  container: {
9
- backgroundColor: "rgba(0, 0, 0, 0.05)",
10
9
  overflow: "hidden",
11
10
  position: "relative",
12
11
  width: "100%",
@@ -14,6 +13,16 @@ export const useStyles = buildThemedStyles(tokens => {
14
13
  borderRadius: tokens["radius-base"],
15
14
  },
16
15
 
16
+ background: {
17
+ position: "absolute",
18
+ top: 0,
19
+ left: 0,
20
+ width: "100%",
21
+ height: "100%",
22
+ backgroundColor: tokens["color-surface--reverse"],
23
+ opacity: 0.075,
24
+ },
25
+
17
26
  shine: {
18
27
  position: "absolute",
19
28
  top: 0,
@@ -5,7 +5,15 @@ import {
5
5
  render as renderComponent,
6
6
  } from "@testing-library/react-native";
7
7
  import { Animated } from "react-native";
8
- import { GLIMMER_SHINE_TEST_ID, GLIMMER_TEST_ID, Glimmer } from "./Glimmer";
8
+ import { Stop } from "react-native-svg";
9
+ import { androidTokens, darkTokens } from "@jobber/design";
10
+ import {
11
+ GLIMMER_BACKGROUND_TEST_ID,
12
+ GLIMMER_SHINE_TEST_ID,
13
+ GLIMMER_TEST_ID,
14
+ Glimmer,
15
+ } from "./Glimmer";
16
+ import { AtlantisThemeContextProvider } from "../AtlantisThemeContext";
9
17
 
10
18
  let screen: ReturnType<typeof renderComponent<typeof Glimmer>>;
11
19
 
@@ -28,6 +36,32 @@ describe("Glimmer", () => {
28
36
  );
29
37
  });
30
38
 
39
+ it("uses a theme token for its dark-mode shine", () => {
40
+ const rendered = render(
41
+ <AtlantisThemeContextProvider dangerouslyOverrideTheme="dark">
42
+ <Glimmer />
43
+ </AtlantisThemeContextProvider>,
44
+ );
45
+
46
+ expect(
47
+ rendered.getByTestId(GLIMMER_BACKGROUND_TEST_ID).props.style,
48
+ ).toEqual(
49
+ expect.objectContaining({
50
+ backgroundColor: darkTokens["color-surface--reverse"],
51
+ opacity: 0.075,
52
+ }),
53
+ );
54
+
55
+ const shineStops = rendered.UNSAFE_root.findAllByType(Stop);
56
+
57
+ expect(shineStops[1].props).toEqual(
58
+ expect.objectContaining({
59
+ stopColor: androidTokens["color-white"],
60
+ stopOpacity: 0.2,
61
+ }),
62
+ );
63
+ });
64
+
31
65
  it("renders a Glimmer with custom width", () => {
32
66
  render(<Glimmer width={50} />);
33
67
  const element = screen.getByTestId(GLIMMER_TEST_ID);
@@ -6,6 +6,7 @@ import { shineWidth, useStyles } from "./Glimmer.style";
6
6
  import { useSizeStyles } from "./Glimmer.size.style";
7
7
  import { useShapeStyles } from "./Glimmer.shape.style";
8
8
  import { tokens } from "../utils/design";
9
+ import { useAtlantisTheme } from "../AtlantisThemeContext";
9
10
 
10
11
  export type GlimmerShapes = keyof ReturnType<typeof useShapeStyles>;
11
12
  export type GlimmerSizes = keyof ReturnType<typeof useSizeStyles>;
@@ -37,6 +38,7 @@ interface GlimmerProps {
37
38
  }
38
39
 
39
40
  export const GLIMMER_TEST_ID = "ATL-Glimmer";
41
+ export const GLIMMER_BACKGROUND_TEST_ID = "ATL-Glimmer-Background";
40
42
  export const GLIMMER_SHINE_TEST_ID = "ATL-Glimmer-Shine";
41
43
 
42
44
  export function Glimmer({
@@ -69,6 +71,8 @@ export function Glimmer({
69
71
  const styles = useStyles();
70
72
  const sizeStyles = useSizeStyles();
71
73
  const shapeStyles = useShapeStyles();
74
+ const { effectiveTheme, tokens: themeTokens } = useAtlantisTheme();
75
+ const shineOpacity = effectiveTheme === "dark" ? 0.2 : 0.75;
72
76
 
73
77
  return (
74
78
  <View
@@ -81,6 +85,7 @@ export function Glimmer({
81
85
  onLayout={getWidth}
82
86
  testID={GLIMMER_TEST_ID}
83
87
  >
88
+ <View style={styles.background} testID={GLIMMER_BACKGROUND_TEST_ID} />
84
89
  <Animated.View
85
90
  style={[styles.shine, { transform: [{ translateX: leftPosition }] }]}
86
91
  testID={GLIMMER_SHINE_TEST_ID}
@@ -90,17 +95,17 @@ export function Glimmer({
90
95
  <LinearGradient id="gradientShine" x1={0} y1={0.5} x2={1} y2={0.5}>
91
96
  <Stop
92
97
  offset="0%"
93
- stopColor="rgba(255,255,255,0)"
98
+ stopColor={themeTokens["color-white"]}
94
99
  stopOpacity="0"
95
100
  />
96
101
  <Stop
97
102
  offset="50%"
98
- stopColor="rgba(255,255,255,1)"
99
- stopOpacity="1"
103
+ stopColor={themeTokens["color-white"]}
104
+ stopOpacity={shineOpacity}
100
105
  />
101
106
  <Stop
102
107
  offset="100%"
103
- stopColor="rgba(255,255,255,0)"
108
+ stopColor={themeTokens["color-white"]}
104
109
  stopOpacity="0"
105
110
  />
106
111
  </LinearGradient>