@shopify/shop-minis-react 0.0.18 → 0.0.20

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.
Files changed (120) hide show
  1. package/dist/_virtual/index2.js +2 -3
  2. package/dist/_virtual/index2.js.map +1 -1
  3. package/dist/_virtual/index3.js +3 -2
  4. package/dist/_virtual/index3.js.map +1 -1
  5. package/dist/components/MinisContainer.js +13 -11
  6. package/dist/components/MinisContainer.js.map +1 -1
  7. package/dist/components/atoms/alert-dialog.js +41 -0
  8. package/dist/components/atoms/alert-dialog.js.map +1 -0
  9. package/dist/components/atoms/list.js +52 -0
  10. package/dist/components/atoms/list.js.map +1 -0
  11. package/dist/components/atoms/pagination.js +10 -0
  12. package/dist/components/atoms/pagination.js.map +1 -0
  13. package/dist/components/atoms/thumbhash-image.js +54 -0
  14. package/dist/components/atoms/thumbhash-image.js.map +1 -0
  15. package/dist/components/atoms/tracking-pixel.js +32 -0
  16. package/dist/components/atoms/tracking-pixel.js.map +1 -0
  17. package/dist/components/commerce/merchant-card-skeleton.js +29 -0
  18. package/dist/components/commerce/merchant-card-skeleton.js.map +1 -0
  19. package/dist/components/commerce/merchant-card.js +28 -22
  20. package/dist/components/commerce/merchant-card.js.map +1 -1
  21. package/dist/components/commerce/product-card-skeleton.js +20 -0
  22. package/dist/components/commerce/product-card-skeleton.js.map +1 -0
  23. package/dist/components/commerce/product-card.js +105 -78
  24. package/dist/components/commerce/product-card.js.map +1 -1
  25. package/dist/components/navigation/transition-container.js +8 -0
  26. package/dist/components/navigation/transition-container.js.map +1 -0
  27. package/dist/components/navigation/transition-link.js +27 -0
  28. package/dist/components/navigation/transition-link.js.map +1 -0
  29. package/dist/components/ui/skeleton.js +16 -0
  30. package/dist/components/ui/skeleton.js.map +1 -0
  31. package/dist/hooks/navigation/useNavigateWithTransition.js +43 -0
  32. package/dist/hooks/navigation/useNavigateWithTransition.js.map +1 -0
  33. package/dist/hooks/navigation/useViewTransitions.js +45 -0
  34. package/dist/hooks/navigation/useViewTransitions.js.map +1 -0
  35. package/dist/index.js +217 -196
  36. package/dist/index.js.map +1 -1
  37. package/dist/internal/useShopActions.js.map +1 -1
  38. package/dist/internal/useShopActionsDataFetching.js +26 -26
  39. package/dist/internal/useShopActionsDataFetching.js.map +1 -1
  40. package/dist/internal/useShopActionsPaginatedDataFetching.js.map +1 -1
  41. package/dist/mocks.js +267 -0
  42. package/dist/mocks.js.map +1 -0
  43. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js +8 -0
  44. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/assertThisInitialized.js.map +1 -0
  45. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js +13 -0
  46. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/extends.js.map +1 -0
  47. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js +8 -0
  48. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/inheritsLoose.js.map +1 -0
  49. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js +9 -0
  50. package/dist/shop-minis-react/node_modules/.pnpm/@babel_runtime@7.27.6/node_modules/@babel/runtime/helpers/esm/setPrototypeOf.js.map +1 -0
  51. package/dist/shop-minis-react/node_modules/.pnpm/@radix-ui_react-use-is-hydrated@0.1.0_@types_react@19.1.6_react@19.1.0/node_modules/@radix-ui/react-use-is-hydrated/dist/index.js +1 -1
  52. package/dist/shop-minis-react/node_modules/.pnpm/js-base64@3.7.7/node_modules/js-base64/base64.js +21 -0
  53. package/dist/shop-minis-react/node_modules/.pnpm/js-base64@3.7.7/node_modules/js-base64/base64.js.map +1 -0
  54. package/dist/shop-minis-react/node_modules/.pnpm/memoize-one@5.2.1/node_modules/memoize-one/dist/memoize-one.esm.js +28 -0
  55. package/dist/shop-minis-react/node_modules/.pnpm/memoize-one@5.2.1/node_modules/memoize-one/dist/memoize-one.esm.js.map +1 -0
  56. package/dist/shop-minis-react/node_modules/.pnpm/querystringify@2.2.0/node_modules/querystringify/index.js +1 -1
  57. package/dist/shop-minis-react/node_modules/.pnpm/react-intersection-observer@9.16.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-intersection-observer/dist/index.js +135 -0
  58. package/dist/shop-minis-react/node_modules/.pnpm/react-intersection-observer@9.16.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-intersection-observer/dist/index.js.map +1 -0
  59. package/dist/shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js +1298 -0
  60. package/dist/shop-minis-react/node_modules/.pnpm/react-router@7.7.0_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-router/dist/development/chunk-EF7DTUVF.js.map +1 -0
  61. package/dist/shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js +375 -0
  62. package/dist/shop-minis-react/node_modules/.pnpm/react-window@1.8.11_react-dom@19.1.0_react@19.1.0__react@19.1.0/node_modules/react-window/dist/index.esm.js.map +1 -0
  63. package/dist/shop-minis-react/node_modules/.pnpm/thumbhash@0.1.1/node_modules/thumbhash/thumbhash.js +145 -0
  64. package/dist/shop-minis-react/node_modules/.pnpm/thumbhash@0.1.1/node_modules/thumbhash/thumbhash.js.map +1 -0
  65. package/dist/shop-minis-react.css +1 -0
  66. package/dist/types/index.js +10 -0
  67. package/dist/types/index.js.map +1 -0
  68. package/dist/utils/image.js +15 -0
  69. package/dist/utils/image.js.map +1 -0
  70. package/package.json +18 -3
  71. package/src/components/MinisContainer.tsx +4 -1
  72. package/src/components/atoms/alert-dialog.tsx +67 -0
  73. package/src/components/atoms/list.tsx +101 -0
  74. package/src/components/atoms/pagination.tsx +19 -0
  75. package/src/components/atoms/thumbhash-image.tsx +66 -0
  76. package/src/components/atoms/tracking-pixel.tsx +40 -0
  77. package/src/components/commerce/merchant-card-skeleton.tsx +31 -0
  78. package/src/components/commerce/merchant-card.tsx +5 -2
  79. package/src/components/commerce/product-card-skeleton.tsx +30 -0
  80. package/src/components/commerce/product-card.tsx +49 -8
  81. package/src/components/index.ts +9 -0
  82. package/src/components/navigation/transition-container.tsx +7 -0
  83. package/src/components/navigation/transition-link.tsx +48 -0
  84. package/src/components/ui/skeleton.tsx +13 -0
  85. package/src/hooks/index.ts +1 -0
  86. package/src/hooks/navigation/useNavigateWithTransition.ts +62 -0
  87. package/src/hooks/navigation/useViewTransitions.ts +79 -0
  88. package/src/index.css +2 -0
  89. package/src/internal/useShopActions.ts +1 -1
  90. package/src/internal/useShopActionsDataFetching.ts +6 -7
  91. package/src/internal/useShopActionsPaginatedDataFetching.ts +3 -6
  92. package/src/mocks.ts +27 -9
  93. package/src/stories/Accordion.stories.tsx +124 -0
  94. package/src/stories/Alert.stories.tsx +38 -0
  95. package/src/stories/AlertDialog.stories.tsx +48 -0
  96. package/src/stories/Avatar.stories.tsx +29 -0
  97. package/src/stories/Badge.stories.tsx +46 -0
  98. package/src/stories/Button.stories.tsx +81 -0
  99. package/src/stories/Card.stories.tsx +40 -0
  100. package/src/stories/Checkbox.stories.tsx +44 -0
  101. package/src/stories/FavoriteButton.stories.tsx +58 -0
  102. package/src/stories/IconButton.stories.tsx +68 -0
  103. package/src/stories/Input.stories.tsx +44 -0
  104. package/src/stories/Label.stories.tsx +19 -0
  105. package/src/stories/List.stories.tsx +68 -0
  106. package/src/stories/MerchantCard.stories.tsx +55 -0
  107. package/src/stories/ProductCard.stories.tsx +85 -0
  108. package/src/stories/ProductLink.stories.tsx +46 -0
  109. package/src/stories/Progress.stories.tsx +30 -0
  110. package/src/stories/RadioGroup.stories.tsx +51 -0
  111. package/src/stories/Select.stories.tsx +85 -0
  112. package/src/stories/Skeleton.stories.tsx +19 -0
  113. package/src/stories/Toaster.stories.tsx +46 -0
  114. package/src/stories/Touchable.stories.tsx +40 -0
  115. package/src/styles/animations.css +90 -0
  116. package/src/styles/globals.css +8 -0
  117. package/src/styles/theme.css +1 -1
  118. package/src/styles/utilities.css +22 -0
  119. package/src/types/index.ts +7 -1
  120. package/src/utils/image.ts +18 -0
@@ -0,0 +1,145 @@
1
+ function W(t) {
2
+ let { PI: r, min: p, max: l, cos: u, round: c } = Math, _ = t[0] | t[1] << 8 | t[2] << 16, n = t[3] | t[4] << 8, s = (_ & 63) / 63, y = (_ >> 6 & 63) / 31.5 - 1, i = (_ >> 12 & 63) / 31.5 - 1, a = (_ >> 18 & 31) / 31, o = _ >> 23, v = (n >> 3 & 63) / 63, z = (n >> 9 & 63) / 63, G = n >> 15, B = l(3, G ? o ? 5 : 7 : n & 7), A = l(3, G ? n & 7 : o ? 5 : 7), E = o ? (t[5] & 15) / 15 : 1, F = (t[5] >> 4) / 15, J = o ? 6 : 5, I = 0, j = (L, x, R) => {
3
+ let m = [];
4
+ for (let b = 0; b < x; b++)
5
+ for (let g = b ? 0 : 1; g * x < L * (x - b); g++)
6
+ m.push(((t[J + (I >> 1)] >> ((I++ & 1) << 2) & 15) / 7.5 - 1) * R);
7
+ return m;
8
+ }, K = j(B, A, a), N = j(3, 3, v * 1.25), O = j(3, 3, z * 1.25), Q = o && j(5, 5, F), C = X(t), H = c(C > 1 ? 32 : 32 * C), U = c(C > 1 ? 32 / C : 32), q = new Uint8Array(H * U * 4), w = [], D = [];
9
+ for (let L = 0, x = 0; L < U; L++)
10
+ for (let R = 0; R < H; R++, x += 4) {
11
+ let m = s, b = y, g = i, M = E;
12
+ for (let e = 0, f = l(B, o ? 5 : 3); e < f; e++)
13
+ w[e] = u(r / H * (R + 0.5) * e);
14
+ for (let e = 0, f = l(A, o ? 5 : 3); e < f; e++)
15
+ D[e] = u(r / U * (L + 0.5) * e);
16
+ for (let e = 0, f = 0; e < A; e++)
17
+ for (let d = e ? 0 : 1, T = D[e] * 2; d * A < B * (A - e); d++, f++)
18
+ m += K[f] * w[d] * T;
19
+ for (let e = 0, f = 0; e < 3; e++)
20
+ for (let d = e ? 0 : 1, T = D[e] * 2; d < 3 - e; d++, f++) {
21
+ let k = w[d] * T;
22
+ b += N[f] * k, g += O[f] * k;
23
+ }
24
+ if (o)
25
+ for (let e = 0, f = 0; e < 5; e++)
26
+ for (let d = e ? 0 : 1, T = D[e] * 2; d < 5 - e; d++, f++)
27
+ M += Q[f] * w[d] * T;
28
+ let P = m - 2 / 3 * b, S = (3 * m - P + g) / 2, V = S - g;
29
+ q[x] = l(0, 255 * p(1, S)), q[x + 1] = l(0, 255 * p(1, V)), q[x + 2] = l(0, 255 * p(1, P)), q[x + 3] = l(0, 255 * p(1, M));
30
+ }
31
+ return { w: H, h: U, rgba: q };
32
+ }
33
+ function X(t) {
34
+ let r = t[3], p = t[2] & 128, l = t[4] & 128, u = l ? p ? 5 : 7 : r & 7, c = l ? r & 7 : p ? 5 : 7;
35
+ return u / c;
36
+ }
37
+ function Y(t, r, p) {
38
+ let l = t * 4 + 1, u = 6 + r * (5 + l), c = [
39
+ 137,
40
+ 80,
41
+ 78,
42
+ 71,
43
+ 13,
44
+ 10,
45
+ 26,
46
+ 10,
47
+ 0,
48
+ 0,
49
+ 0,
50
+ 13,
51
+ 73,
52
+ 72,
53
+ 68,
54
+ 82,
55
+ 0,
56
+ 0,
57
+ t >> 8,
58
+ t & 255,
59
+ 0,
60
+ 0,
61
+ r >> 8,
62
+ r & 255,
63
+ 8,
64
+ 6,
65
+ 0,
66
+ 0,
67
+ 0,
68
+ 0,
69
+ 0,
70
+ 0,
71
+ 0,
72
+ u >>> 24,
73
+ u >> 16 & 255,
74
+ u >> 8 & 255,
75
+ u & 255,
76
+ 73,
77
+ 68,
78
+ 65,
79
+ 84,
80
+ 120,
81
+ 1
82
+ ], _ = [
83
+ 0,
84
+ 498536548,
85
+ 997073096,
86
+ 651767980,
87
+ 1994146192,
88
+ 1802195444,
89
+ 1303535960,
90
+ 1342533948,
91
+ -306674912,
92
+ -267414716,
93
+ -690576408,
94
+ -882789492,
95
+ -1687895376,
96
+ -2032938284,
97
+ -1609899400,
98
+ -1111625188
99
+ ], n = 1, s = 0;
100
+ for (let y = 0, i = 0, a = l - 1; y < r; y++, a += l - 1)
101
+ for (c.push(y + 1 < r ? 0 : 1, l & 255, l >> 8, ~l & 255, l >> 8 ^ 255, 0), s = (s + n) % 65521; i < a; i++) {
102
+ let o = p[i] & 255;
103
+ c.push(o), n = (n + o) % 65521, s = (s + n) % 65521;
104
+ }
105
+ c.push(
106
+ s >> 8,
107
+ s & 255,
108
+ n >> 8,
109
+ n & 255,
110
+ 0,
111
+ 0,
112
+ 0,
113
+ 0,
114
+ 0,
115
+ 0,
116
+ 0,
117
+ 0,
118
+ 73,
119
+ 69,
120
+ 78,
121
+ 68,
122
+ 174,
123
+ 66,
124
+ 96,
125
+ 130
126
+ );
127
+ for (let [y, i] of [[12, 29], [37, 41 + u]]) {
128
+ let a = -1;
129
+ for (let o = y; o < i; o++)
130
+ a ^= c[o], a = a >>> 4 ^ _[a & 15], a = a >>> 4 ^ _[a & 15];
131
+ a = ~a, c[i++] = a >>> 24, c[i++] = a >> 16 & 255, c[i++] = a >> 8 & 255, c[i++] = a & 255;
132
+ }
133
+ return "data:image/png;base64," + btoa(String.fromCharCode(...c));
134
+ }
135
+ function Z(t) {
136
+ let r = W(t);
137
+ return Y(r.w, r.h, r.rgba);
138
+ }
139
+ export {
140
+ Y as rgbaToDataURL,
141
+ X as thumbHashToApproximateAspectRatio,
142
+ Z as thumbHashToDataURL,
143
+ W as thumbHashToRGBA
144
+ };
145
+ //# sourceMappingURL=thumbhash.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"thumbhash.js","sources":["../../../../../../../node_modules/.pnpm/thumbhash@0.1.1/node_modules/thumbhash/thumbhash.js"],"sourcesContent":["/**\n * Encodes an RGBA image to a ThumbHash. RGB should not be premultiplied by A.\n *\n * @param w The width of the input image. Must be ≤100px.\n * @param h The height of the input image. Must be ≤100px.\n * @param rgba The pixels in the input image, row-by-row. Must have w*h*4 elements.\n * @returns The ThumbHash as a Uint8Array.\n */\nexport function rgbaToThumbHash(w, h, rgba) {\n // Encoding an image larger than 100x100 is slow with no benefit\n if (w > 100 || h > 100) throw new Error(`${w}x${h} doesn't fit in 100x100`)\n let { PI, round, max, cos, abs } = Math\n\n // Determine the average color\n let avg_r = 0, avg_g = 0, avg_b = 0, avg_a = 0\n for (let i = 0, j = 0; i < w * h; i++, j += 4) {\n let alpha = rgba[j + 3] / 255\n avg_r += alpha / 255 * rgba[j]\n avg_g += alpha / 255 * rgba[j + 1]\n avg_b += alpha / 255 * rgba[j + 2]\n avg_a += alpha\n }\n if (avg_a) {\n avg_r /= avg_a\n avg_g /= avg_a\n avg_b /= avg_a\n }\n\n let hasAlpha = avg_a < w * h\n let l_limit = hasAlpha ? 5 : 7 // Use fewer luminance bits if there's alpha\n let lx = max(1, round(l_limit * w / max(w, h)))\n let ly = max(1, round(l_limit * h / max(w, h)))\n let l = [] // luminance\n let p = [] // yellow - blue\n let q = [] // red - green\n let a = [] // alpha\n\n // Convert the image from RGBA to LPQA (composite atop the average color)\n for (let i = 0, j = 0; i < w * h; i++, j += 4) {\n let alpha = rgba[j + 3] / 255\n let r = avg_r * (1 - alpha) + alpha / 255 * rgba[j]\n let g = avg_g * (1 - alpha) + alpha / 255 * rgba[j + 1]\n let b = avg_b * (1 - alpha) + alpha / 255 * rgba[j + 2]\n l[i] = (r + g + b) / 3\n p[i] = (r + g) / 2 - b\n q[i] = r - g\n a[i] = alpha\n }\n\n // Encode using the DCT into DC (constant) and normalized AC (varying) terms\n let encodeChannel = (channel, nx, ny) => {\n let dc = 0, ac = [], scale = 0, fx = []\n for (let cy = 0; cy < ny; cy++) {\n for (let cx = 0; cx * ny < nx * (ny - cy); cx++) {\n let f = 0\n for (let x = 0; x < w; x++)\n fx[x] = cos(PI / w * cx * (x + 0.5))\n for (let y = 0; y < h; y++)\n for (let x = 0, fy = cos(PI / h * cy * (y + 0.5)); x < w; x++)\n f += channel[x + y * w] * fx[x] * fy\n f /= w * h\n if (cx || cy) {\n ac.push(f)\n scale = max(scale, abs(f))\n } else {\n dc = f\n }\n }\n }\n if (scale)\n for (let i = 0; i < ac.length; i++)\n ac[i] = 0.5 + 0.5 / scale * ac[i]\n return [dc, ac, scale]\n }\n let [l_dc, l_ac, l_scale] = encodeChannel(l, max(3, lx), max(3, ly))\n let [p_dc, p_ac, p_scale] = encodeChannel(p, 3, 3)\n let [q_dc, q_ac, q_scale] = encodeChannel(q, 3, 3)\n let [a_dc, a_ac, a_scale] = hasAlpha ? encodeChannel(a, 5, 5) : []\n\n // Write the constants\n let isLandscape = w > h\n let header24 = round(63 * l_dc) | (round(31.5 + 31.5 * p_dc) << 6) | (round(31.5 + 31.5 * q_dc) << 12) | (round(31 * l_scale) << 18) | (hasAlpha << 23)\n let header16 = (isLandscape ? ly : lx) | (round(63 * p_scale) << 3) | (round(63 * q_scale) << 9) | (isLandscape << 15)\n let hash = [header24 & 255, (header24 >> 8) & 255, header24 >> 16, header16 & 255, header16 >> 8]\n let ac_start = hasAlpha ? 6 : 5\n let ac_index = 0\n if (hasAlpha) hash.push(round(15 * a_dc) | (round(15 * a_scale) << 4))\n\n // Write the varying factors\n for (let ac of hasAlpha ? [l_ac, p_ac, q_ac, a_ac] : [l_ac, p_ac, q_ac])\n for (let f of ac)\n hash[ac_start + (ac_index >> 1)] |= round(15 * f) << ((ac_index++ & 1) << 2)\n return new Uint8Array(hash)\n}\n\n/**\n * Decodes a ThumbHash to an RGBA image. RGB is not be premultiplied by A.\n *\n * @param hash The bytes of the ThumbHash.\n * @returns The width, height, and pixels of the rendered placeholder image.\n */\nexport function thumbHashToRGBA(hash) {\n let { PI, min, max, cos, round } = Math\n\n // Read the constants\n let header24 = hash[0] | (hash[1] << 8) | (hash[2] << 16)\n let header16 = hash[3] | (hash[4] << 8)\n let l_dc = (header24 & 63) / 63\n let p_dc = ((header24 >> 6) & 63) / 31.5 - 1\n let q_dc = ((header24 >> 12) & 63) / 31.5 - 1\n let l_scale = ((header24 >> 18) & 31) / 31\n let hasAlpha = header24 >> 23\n let p_scale = ((header16 >> 3) & 63) / 63\n let q_scale = ((header16 >> 9) & 63) / 63\n let isLandscape = header16 >> 15\n let lx = max(3, isLandscape ? hasAlpha ? 5 : 7 : header16 & 7)\n let ly = max(3, isLandscape ? header16 & 7 : hasAlpha ? 5 : 7)\n let a_dc = hasAlpha ? (hash[5] & 15) / 15 : 1\n let a_scale = (hash[5] >> 4) / 15\n\n // Read the varying factors (boost saturation by 1.25x to compensate for quantization)\n let ac_start = hasAlpha ? 6 : 5\n let ac_index = 0\n let decodeChannel = (nx, ny, scale) => {\n let ac = []\n for (let cy = 0; cy < ny; cy++)\n for (let cx = cy ? 0 : 1; cx * ny < nx * (ny - cy); cx++)\n ac.push((((hash[ac_start + (ac_index >> 1)] >> ((ac_index++ & 1) << 2)) & 15) / 7.5 - 1) * scale)\n return ac\n }\n let l_ac = decodeChannel(lx, ly, l_scale)\n let p_ac = decodeChannel(3, 3, p_scale * 1.25)\n let q_ac = decodeChannel(3, 3, q_scale * 1.25)\n let a_ac = hasAlpha && decodeChannel(5, 5, a_scale)\n\n // Decode using the DCT into RGB\n let ratio = thumbHashToApproximateAspectRatio(hash)\n let w = round(ratio > 1 ? 32 : 32 * ratio)\n let h = round(ratio > 1 ? 32 / ratio : 32)\n let rgba = new Uint8Array(w * h * 4), fx = [], fy = []\n for (let y = 0, i = 0; y < h; y++) {\n for (let x = 0; x < w; x++, i += 4) {\n let l = l_dc, p = p_dc, q = q_dc, a = a_dc\n\n // Precompute the coefficients\n for (let cx = 0, n = max(lx, hasAlpha ? 5 : 3); cx < n; cx++)\n fx[cx] = cos(PI / w * (x + 0.5) * cx)\n for (let cy = 0, n = max(ly, hasAlpha ? 5 : 3); cy < n; cy++)\n fy[cy] = cos(PI / h * (y + 0.5) * cy)\n\n // Decode L\n for (let cy = 0, j = 0; cy < ly; cy++)\n for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx * ly < lx * (ly - cy); cx++, j++)\n l += l_ac[j] * fx[cx] * fy2\n\n // Decode P and Q\n for (let cy = 0, j = 0; cy < 3; cy++) {\n for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx < 3 - cy; cx++, j++) {\n let f = fx[cx] * fy2\n p += p_ac[j] * f\n q += q_ac[j] * f\n }\n }\n\n // Decode A\n if (hasAlpha)\n for (let cy = 0, j = 0; cy < 5; cy++)\n for (let cx = cy ? 0 : 1, fy2 = fy[cy] * 2; cx < 5 - cy; cx++, j++)\n a += a_ac[j] * fx[cx] * fy2\n\n // Convert to RGB\n let b = l - 2 / 3 * p\n let r = (3 * l - b + q) / 2\n let g = r - q\n rgba[i] = max(0, 255 * min(1, r))\n rgba[i + 1] = max(0, 255 * min(1, g))\n rgba[i + 2] = max(0, 255 * min(1, b))\n rgba[i + 3] = max(0, 255 * min(1, a))\n }\n }\n return { w, h, rgba }\n}\n\n/**\n * Extracts the average color from a ThumbHash. RGB is not be premultiplied by A.\n *\n * @param hash The bytes of the ThumbHash.\n * @returns The RGBA values for the average color. Each value ranges from 0 to 1.\n */\nexport function thumbHashToAverageRGBA(hash) {\n let { min, max } = Math\n let header = hash[0] | (hash[1] << 8) | (hash[2] << 16)\n let l = (header & 63) / 63\n let p = ((header >> 6) & 63) / 31.5 - 1\n let q = ((header >> 12) & 63) / 31.5 - 1\n let hasAlpha = header >> 23\n let a = hasAlpha ? (hash[5] & 15) / 15 : 1\n let b = l - 2 / 3 * p\n let r = (3 * l - b + q) / 2\n let g = r - q\n return {\n r: max(0, min(1, r)),\n g: max(0, min(1, g)),\n b: max(0, min(1, b)),\n a\n }\n}\n\n/**\n * Extracts the approximate aspect ratio of the original image.\n *\n * @param hash The bytes of the ThumbHash.\n * @returns The approximate aspect ratio (i.e. width / height).\n */\nexport function thumbHashToApproximateAspectRatio(hash) {\n let header = hash[3]\n let hasAlpha = hash[2] & 0x80\n let isLandscape = hash[4] & 0x80\n let lx = isLandscape ? hasAlpha ? 5 : 7 : header & 7\n let ly = isLandscape ? header & 7 : hasAlpha ? 5 : 7\n return lx / ly\n}\n\n/**\n * Encodes an RGBA image to a PNG data URL. RGB should not be premultiplied by\n * A. This is optimized for speed and simplicity and does not optimize for size\n * at all. This doesn't do any compression (all values are stored uncompressed).\n *\n * @param w The width of the input image. Must be ≤100px.\n * @param h The height of the input image. Must be ≤100px.\n * @param rgba The pixels in the input image, row-by-row. Must have w*h*4 elements.\n * @returns A data URL containing a PNG for the input image.\n */\nexport function rgbaToDataURL(w, h, rgba) {\n let row = w * 4 + 1\n let idat = 6 + h * (5 + row)\n let bytes = [\n 137, 80, 78, 71, 13, 10, 26, 10, 0, 0, 0, 13, 73, 72, 68, 82, 0, 0,\n w >> 8, w & 255, 0, 0, h >> 8, h & 255, 8, 6, 0, 0, 0, 0, 0, 0, 0,\n idat >>> 24, (idat >> 16) & 255, (idat >> 8) & 255, idat & 255,\n 73, 68, 65, 84, 120, 1\n ]\n let table = [\n 0, 498536548, 997073096, 651767980, 1994146192, 1802195444, 1303535960,\n 1342533948, -306674912, -267414716, -690576408, -882789492, -1687895376,\n -2032938284, -1609899400, -1111625188\n ]\n let a = 1, b = 0\n for (let y = 0, i = 0, end = row - 1; y < h; y++, end += row - 1) {\n bytes.push(y + 1 < h ? 0 : 1, row & 255, row >> 8, ~row & 255, (row >> 8) ^ 255, 0)\n for (b = (b + a) % 65521; i < end; i++) {\n let u = rgba[i] & 255\n bytes.push(u)\n a = (a + u) % 65521\n b = (b + a) % 65521\n }\n }\n bytes.push(\n b >> 8, b & 255, a >> 8, a & 255, 0, 0, 0, 0,\n 0, 0, 0, 0, 73, 69, 78, 68, 174, 66, 96, 130\n )\n for (let [start, end] of [[12, 29], [37, 41 + idat]]) {\n let c = ~0\n for (let i = start; i < end; i++) {\n c ^= bytes[i]\n c = (c >>> 4) ^ table[c & 15]\n c = (c >>> 4) ^ table[c & 15]\n }\n c = ~c\n bytes[end++] = c >>> 24\n bytes[end++] = (c >> 16) & 255\n bytes[end++] = (c >> 8) & 255\n bytes[end++] = c & 255\n }\n return 'data:image/png;base64,' + btoa(String.fromCharCode(...bytes))\n}\n\n/**\n * Decodes a ThumbHash to a PNG data URL. This is a convenience function that\n * just calls \"thumbHashToRGBA\" followed by \"rgbaToDataURL\".\n *\n * @param hash The bytes of the ThumbHash.\n * @returns A data URL containing a PNG for the rendered ThumbHash.\n */\nexport function thumbHashToDataURL(hash) {\n let image = thumbHashToRGBA(hash)\n return rgbaToDataURL(image.w, image.h, image.rgba)\n}\n"],"names":["thumbHashToRGBA","hash","PI","min","max","cos","round","header24","header16","l_dc","p_dc","q_dc","l_scale","hasAlpha","p_scale","q_scale","isLandscape","lx","ly","a_dc","a_scale","ac_start","ac_index","decodeChannel","nx","ny","scale","ac","cy","cx","l_ac","p_ac","q_ac","a_ac","ratio","thumbHashToApproximateAspectRatio","w","h","rgba","fx","fy","y","i","x","l","p","q","a","n","j","fy2","f","b","r","g","header","rgbaToDataURL","row","idat","bytes","table","end","u","start","c","thumbHashToDataURL","image"],"mappings":"AAqGO,SAASA,EAAgBC,GAAM;AACpC,MAAI,EAAE,IAAAC,GAAI,KAAAC,GAAK,KAAAC,GAAK,KAAAC,GAAK,OAAAC,EAAK,IAAK,MAG/BC,IAAWN,EAAK,CAAC,IAAKA,EAAK,CAAC,KAAK,IAAMA,EAAK,CAAC,KAAK,IAClDO,IAAWP,EAAK,CAAC,IAAKA,EAAK,CAAC,KAAK,GACjCQ,KAAQF,IAAW,MAAM,IACzBG,KAASH,KAAY,IAAK,MAAM,OAAO,GACvCI,KAASJ,KAAY,KAAM,MA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K,CAAC,CAAC,IAAI,EAAE,GAAG,CAAC,IAAI,KAAKH,CAAI,CAAC,GAAG;AACpD,QAAIM,IAAI;AACR,aAAStB,IAAIqB,GAAOrB,IAAImB,GAAKnB;AAC3B,MAAAsB,KAAKL,EAAMjB,CAAC,GACZsB,IAAKA,MAAM,IAAKJ,EAAMI,IAAI,EAAE,GAC5BA,IAAKA,MAAM,IAAKJ,EAAMI,IAAI,EAAE;AAE9B,IAAAA,IAAI,CAACA,GACLL,EAAME,GAAK,IAAIG,MAAM,IACrBL,EAAME,GAAK,IAAKG,KAAK,KAAM,KAC3BL,EAAME,GAAK,IAAKG,KAAK,IAAK,KAC1BL,EAAME,GAAK,IAAIG,IAAI;AAAA,EACvB;AACE,SAAO,2BAA2B,KAAK,OAAO,aAAa,GAAGL,CAAK,CAAC;AACtE;AASO,SAASM,EAAmBhE,GAAM;AACvC,MAAIiE,IAAQlE,EAAgBC,CAAI;AAChC,SAAOuD,EAAcU,EAAM,GAAGA,EAAM,GAAGA,EAAM,IAAI;AACnD;","x_google_ignoreList":[0]}
@@ -0,0 +1 @@
1
+ .no-scrollbars{scrollbar-width:thin;scrollbar-color:transparent transparent;&::-webkit-scrollbar{width:1px}&::-webkit-scrollbar-track{background:transparent}&::-webkit-scrollbar-thumb{background-color:transparent}}.no-scrollbars::-webkit-scrollbar{display:none}
@@ -0,0 +1,10 @@
1
+ const a = "data-navigation-type", n = {
2
+ forward: "forward",
3
+ backward: "backward",
4
+ none: "none"
5
+ };
6
+ export {
7
+ a as DATA_NAVIGATION_TYPE_ATTRIBUTE,
8
+ n as NAVIGATION_TYPES
9
+ };
10
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sources":["../../src/types/index.ts"],"sourcesContent":["export * from '@shopify/shop-minis-platform'\n\nexport interface BaseComponentProps {\n className?: string\n children?: React.ReactNode\n}\n\n// Theme types\nexport interface ThemeConfig {\n colors?: {[key: string]: string}\n spacing?: {[key: string]: string}\n typography?: {[key: string]: string}\n}\n\n// Navigation\nexport const DATA_NAVIGATION_TYPE_ATTRIBUTE = 'data-navigation-type' as const\nexport const NAVIGATION_TYPES = {\n forward: 'forward',\n backward: 'backward',\n none: 'none',\n} as const\n"],"names":["DATA_NAVIGATION_TYPE_ATTRIBUTE","NAVIGATION_TYPES"],"mappings":"AAeO,MAAMA,IAAiC,wBACjCC,IAAmB;AAAA,EAC9B,SAAS;AAAA,EACT,UAAU;AAAA,EACV,MAAM;AACR;"}
@@ -0,0 +1,15 @@
1
+ import { toUint8Array as o } from "../shop-minis-react/node_modules/.pnpm/js-base64@3.7.7/node_modules/js-base64/base64.js";
2
+ import { thumbHashToDataURL as a } from "../shop-minis-react/node_modules/.pnpm/thumbhash@0.1.1/node_modules/thumbhash/thumbhash.js";
3
+ function n(r) {
4
+ if (r)
5
+ try {
6
+ const t = o(r);
7
+ return a(t);
8
+ } catch (t) {
9
+ console.warn("Failed to decode thumbhash to data URL", t);
10
+ }
11
+ }
12
+ export {
13
+ n as getThumbhashDataURL
14
+ };
15
+ //# sourceMappingURL=image.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"image.js","sources":["../../src/utils/image.ts"],"sourcesContent":["import {toUint8Array} from 'js-base64'\nimport {thumbHashToDataURL} from 'thumbhash'\n\n/**\n * Converts a thumbhash string to a data URL for use as an image placeholder\n * @param thumbhash Base64 encoded thumbhash string\n * @returns Data URL that can be used as image source or undefined if conversion fails\n */\nexport function getThumbhashDataURL(thumbhash?: string): string | undefined {\n if (!thumbhash) return\n\n try {\n const thumbhashArray = toUint8Array(thumbhash)\n return thumbHashToDataURL(thumbhashArray)\n } catch (error) {\n console.warn('Failed to decode thumbhash to data URL', error)\n }\n}\n"],"names":["getThumbhashDataURL","thumbhash","thumbhashArray","toUint8Array","thumbHashToDataURL","error"],"mappings":";;AAQO,SAASA,EAAoBC,GAAwC;AAC1E,MAAKA;AAED,QAAA;AACI,YAAAC,IAAiBC,EAAaF,CAAS;AAC7C,aAAOG,EAAmBF,CAAc;AAAA,aACjCG,GAAO;AACN,cAAA,KAAK,0CAA0CA,CAAK;AAAA,IAAA;AAEhE;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@shopify/shop-minis-react",
3
3
  "license": "SEE LICENSE IN LICENSE.txt",
4
- "version": "0.0.18",
4
+ "version": "0.0.20",
5
5
  "sideEffects": false,
6
6
  "type": "module",
7
7
  "engines": {
@@ -38,33 +38,44 @@
38
38
  "typescript": ">=5.0.0"
39
39
  },
40
40
  "dependencies": {
41
- "@shopify/shop-minis-platform": "0.0.3",
41
+ "@shopify/shop-minis-platform": "0.0.7",
42
42
  "@tailwindcss/vite": "4.1.8",
43
43
  "@types/url-parse": "1.4.9",
44
44
  "@vitejs/plugin-react": "4.5.1",
45
45
  "class-variance-authority": "0.7.1",
46
46
  "clsx": "2.1.1",
47
47
  "embla-carousel-react": "8.6.0",
48
+ "js-base64": "^3.7.7",
48
49
  "lodash": "4.17.21",
49
50
  "lucide-react": "0.513.0",
50
51
  "motion": "12.17.3",
51
52
  "next-themes": "0.4.6",
52
53
  "radix-ui": "1.4.2",
54
+ "react-intersection-observer": "^9.13.1",
53
55
  "react-resizable-panels": "3.0.2",
56
+ "react-router": "^7.7.0",
57
+ "react-window": "^1.8.11",
54
58
  "sonner": "2.0.5",
55
59
  "tailwind-merge": "2.6.0",
56
60
  "tailwindcss": "4.1.8",
61
+ "thumbhash": "^0.1.1",
57
62
  "tw-animate-css": "1.3.4",
58
63
  "url-parse": "1.5.10",
59
64
  "vaul": "1.1.2"
60
65
  },
61
66
  "devDependencies": {
62
67
  "@shopify/generate-docs": "^0.16.6",
68
+ "@storybook/addon-docs": "^9.0.16",
69
+ "@storybook/react-vite": "^9.0.16",
63
70
  "@types/node": "^20.12.1",
64
71
  "@types/react": "^19.1.6",
65
72
  "@types/react-dom": "^19.1.2",
73
+ "@types/react-window": "^1.8.8",
74
+ "eslint": "^8.57.0",
75
+ "eslint-plugin-storybook": "^9.0.16",
66
76
  "react": "^19.1.0",
67
77
  "react-dom": "^19.1.0",
78
+ "storybook": "^9.0.16",
68
79
  "typescript": "^5.8.3",
69
80
  "vite": "^6.3.3",
70
81
  "vite-plugin-dts": "^4.3.0"
@@ -92,6 +103,10 @@
92
103
  "build": "vite build --mode lib",
93
104
  "build:watch": "vite build --mode lib --watch",
94
105
  "type-check": "tsc --noEmit",
95
- "clean": "rm -rf dist"
106
+ "clean": "rm -rf dist",
107
+ "storybook": "storybook dev -p 6006",
108
+ "build-storybook": "storybook build",
109
+ "lint": "eslint . --format codeframe --cache --max-warnings=0",
110
+ "lint:fix": "eslint . --format codeframe --cache --fix"
96
111
  }
97
112
  }
@@ -1,7 +1,10 @@
1
1
  import React, {useEffect, useState} from 'react'
2
2
 
3
+ import {injectMocks} from '../mocks'
3
4
  import {ImagePickerProvider} from '../providers/ImagePickerProvider'
4
5
 
6
+ injectMocks()
7
+
5
8
  export function MinisContainer({children}: {children: React.ReactNode}) {
6
9
  const [isSDKReady, setIsSDKReady] = useState(false)
7
10
 
@@ -42,7 +45,7 @@ export function MinisContainer({children}: {children: React.ReactNode}) {
42
45
 
43
46
  // Cleanup
44
47
  return () => {
45
- // clearInterval(pollInterval);
48
+ clearInterval(pollInterval)
46
49
  window.removeEventListener('message', handleSDKReady)
47
50
  document.removeEventListener('message', handleSDKReady)
48
51
  }
@@ -0,0 +1,67 @@
1
+ import {useState} from 'react'
2
+
3
+ import {
4
+ AlertDialogTrigger,
5
+ AlertDialogContent,
6
+ AlertDialogHeader,
7
+ AlertDialogTitle,
8
+ AlertDialogDescription,
9
+ AlertDialogFooter,
10
+ AlertDialogCancel,
11
+ AlertDialogAction,
12
+ AlertDialog as AlertDialogPrimitive,
13
+ } from '../ui/alert-dialog'
14
+
15
+ export const AlertDialogAtom = ({
16
+ children,
17
+ title,
18
+ description,
19
+ cancelButtonText,
20
+ confirmationButtonText,
21
+ open,
22
+ onOpenChange,
23
+ onConfirmationAction,
24
+ }: {
25
+ /** The trigger element that opens the alert dialog */
26
+ children: React.ReactNode
27
+ /** The title text shown in the alert dialog header */
28
+ title: string
29
+ /** The description text shown in the alert dialog body */
30
+ description: string
31
+ /** The text shown in the cancel button */
32
+ cancelButtonText: string
33
+ /** The text shown in the confirmation button */
34
+ confirmationButtonText: string
35
+ /** Whether the alert dialog is open */
36
+ open: boolean
37
+ /** Callback fired when the alert dialog open state changes */
38
+ onOpenChange: (open: boolean) => void
39
+ /** Callback fired when the confirmation button is clicked */
40
+ onConfirmationAction: () => void
41
+ }) => {
42
+ const [isOpen, setIsOpen] = useState(open)
43
+
44
+ return (
45
+ <AlertDialogPrimitive
46
+ open={isOpen}
47
+ onOpenChange={open => {
48
+ setIsOpen(open)
49
+ onOpenChange(open)
50
+ }}
51
+ >
52
+ <AlertDialogTrigger asChild>{children}</AlertDialogTrigger>
53
+ <AlertDialogContent>
54
+ <AlertDialogHeader>
55
+ <AlertDialogTitle>{title}</AlertDialogTitle>
56
+ <AlertDialogDescription>{description}</AlertDialogDescription>
57
+ </AlertDialogHeader>
58
+ <AlertDialogFooter>
59
+ <AlertDialogCancel>{cancelButtonText}</AlertDialogCancel>
60
+ <AlertDialogAction onClick={onConfirmationAction}>
61
+ {confirmationButtonText}
62
+ </AlertDialogAction>
63
+ </AlertDialogFooter>
64
+ </AlertDialogContent>
65
+ </AlertDialogPrimitive>
66
+ )
67
+ }
@@ -0,0 +1,101 @@
1
+ import {ComponentType, useCallback} from 'react'
2
+
3
+ import {
4
+ VariableSizeList as _VariableSizeList,
5
+ VariableSizeListProps,
6
+ } from 'react-window'
7
+
8
+ import {cn} from '../../lib/utils'
9
+ import '../../styles/utilities.css'
10
+
11
+ import {Pagination} from './pagination'
12
+
13
+ const VariableSizeList =
14
+ _VariableSizeList as unknown as ComponentType<VariableSizeListProps>
15
+
16
+ interface Props<T = any>
17
+ extends Omit<
18
+ VariableSizeListProps<T>,
19
+ 'children' | 'itemCount' | 'width' | 'itemSize' | 'direction'
20
+ > {
21
+ items: T[]
22
+ renderItem: (item: T, index: number) => React.ReactNode
23
+ itemSizeForRow: (index: number) => number
24
+ showScrollbar?: boolean
25
+ header?: React.ReactNode
26
+ headerHeight?: number
27
+ fetchMore?: () => void
28
+ }
29
+
30
+ export function List<T = any>({
31
+ items,
32
+ height,
33
+ renderItem,
34
+ className,
35
+ showScrollbar = false,
36
+ header,
37
+ headerHeight,
38
+ itemSizeForRow,
39
+ fetchMore,
40
+ overscanCount,
41
+ ...listProps
42
+ }: Props<T>) {
43
+ const rowRenderer = useCallback(
44
+ ({index, style}: {index: number; style: React.CSSProperties}) => {
45
+ // prepend the header to the first row if it exists
46
+ if (header && index === 0) {
47
+ return (
48
+ <div style={style}>
49
+ {header}
50
+ <div style={{top: headerHeight}}>{renderItem(items[0], 0)}</div>
51
+ </div>
52
+ )
53
+ }
54
+
55
+ // append the pagination spinner to the last row if fetchMore exists
56
+ if (fetchMore && index === items.length - 1) {
57
+ return (
58
+ <div style={style}>
59
+ {renderItem(items[index], index)}
60
+ <div style={{bottom: 0}}>
61
+ <Pagination fetchMore={fetchMore} />
62
+ </div>
63
+ </div>
64
+ )
65
+ }
66
+
67
+ return <div style={style}>{renderItem(items[index], index)}</div>
68
+ },
69
+ [items, renderItem, header, fetchMore, headerHeight]
70
+ )
71
+
72
+ const getItemSize = useCallback(
73
+ (index: number) => {
74
+ // include the header height in the first row height
75
+ if (header && index === 0) {
76
+ const _headerHeight = headerHeight || 0
77
+ return _headerHeight + itemSizeForRow(index)
78
+ }
79
+
80
+ return itemSizeForRow(index)
81
+ },
82
+ [itemSizeForRow, header, headerHeight]
83
+ )
84
+
85
+ const classNames = cn(showScrollbar ? undefined : 'no-scrollbars', className)
86
+
87
+ return (
88
+ <VariableSizeList
89
+ className={classNames}
90
+ height={height}
91
+ direction="vertical"
92
+ width="100%"
93
+ itemCount={items.length}
94
+ overscanCount={overscanCount}
95
+ itemSize={getItemSize}
96
+ {...listProps}
97
+ >
98
+ {rowRenderer}
99
+ </VariableSizeList>
100
+ )
101
+ }
@@ -0,0 +1,19 @@
1
+ import {Skeleton} from '../ui/skeleton'
2
+
3
+ import {TrackingPixel} from './tracking-pixel'
4
+
5
+ interface Props {
6
+ loadingComponent?: React.ReactNode
7
+ isFetchingMore?: boolean
8
+ fetchMore: () => void
9
+ }
10
+
11
+ export function Pagination({loadingComponent, fetchMore}: Props) {
12
+ const loadingPlaceholder = loadingComponent ?? (
13
+ <Skeleton className="h-10 w-full p-8" />
14
+ )
15
+
16
+ return (
17
+ <TrackingPixel onImpression={fetchMore}>{loadingPlaceholder}</TrackingPixel>
18
+ )
19
+ }
@@ -0,0 +1,66 @@
1
+ /* eslint-disable jsx-a11y/no-noninteractive-element-interactions */
2
+ import {ImgHTMLAttributes, useCallback, useMemo, memo, useState} from 'react'
3
+
4
+ import {cn} from '../../lib/utils'
5
+ import {getThumbhashDataURL} from '../../utils/image'
6
+
7
+ type ThumbhashImageProps = ImgHTMLAttributes<HTMLImageElement> & {
8
+ src: string
9
+ thumbhash: string
10
+ alt?: string | null
11
+ aspectRatio?: number | string
12
+ }
13
+
14
+ export const ThumbhashImage = memo(function ThumbhashImage(
15
+ props: ThumbhashImageProps
16
+ ) {
17
+ const {
18
+ src,
19
+ alt,
20
+ thumbhash,
21
+ onLoad,
22
+ className,
23
+ style,
24
+ aspectRatio = 'auto',
25
+ ...restProps
26
+ } = props
27
+
28
+ const [isLoaded, setIsLoaded] = useState(false)
29
+
30
+ const dataURL = useMemo(
31
+ () => getThumbhashDataURL(thumbhash ?? undefined),
32
+ [thumbhash]
33
+ )
34
+
35
+ const handleLoad = useCallback(
36
+ (event: React.SyntheticEvent<HTMLImageElement, Event>) => {
37
+ setIsLoaded(true)
38
+ onLoad?.(event)
39
+ },
40
+ [onLoad]
41
+ )
42
+
43
+ return (
44
+ <div
45
+ className={cn('relative w-full ', className)}
46
+ style={{
47
+ ...style,
48
+ aspectRatio,
49
+ backgroundImage: dataURL ? `url(${dataURL})` : undefined,
50
+ backgroundSize: 'cover',
51
+ backgroundPosition: 'center',
52
+ }}
53
+ >
54
+ <img
55
+ className={cn(
56
+ 'absolute inset-0 w-full h-full opacity-0 object-cover',
57
+ isLoaded && 'opacity-100'
58
+ )}
59
+ src={src}
60
+ alt={alt}
61
+ onLoad={handleLoad}
62
+ {...restProps}
63
+ />
64
+ </div>
65
+ )
66
+ })
@@ -0,0 +1,40 @@
1
+ import {useCallback} from 'react'
2
+
3
+ import {InView} from 'react-intersection-observer'
4
+
5
+ interface Props {
6
+ children: React.ReactNode
7
+ onImpression?: () => void
8
+ triggerOnce?: boolean
9
+ threshold?: number
10
+ className?: string
11
+ }
12
+
13
+ export const TrackingPixel = ({
14
+ children,
15
+ onImpression,
16
+ triggerOnce = false,
17
+ threshold,
18
+ className,
19
+ }: Props) => {
20
+ const onChange = useCallback(
21
+ (inView: boolean) => {
22
+ if (inView) {
23
+ onImpression?.()
24
+ }
25
+ },
26
+ [onImpression]
27
+ )
28
+
29
+ return (
30
+ <InView
31
+ as="div"
32
+ onChange={onChange}
33
+ triggerOnce={triggerOnce}
34
+ className={className}
35
+ threshold={threshold}
36
+ >
37
+ {children}
38
+ </InView>
39
+ )
40
+ }
@@ -0,0 +1,31 @@
1
+ import * as React from 'react'
2
+
3
+ import {cn} from '../../lib/utils'
4
+ import {Skeleton} from '../ui/skeleton'
5
+
6
+ interface MerchantCardSkeletonProps extends React.ComponentProps<'div'> {}
7
+
8
+ function MerchantCardSkeleton({
9
+ className,
10
+ ...props
11
+ }: MerchantCardSkeletonProps) {
12
+ return (
13
+ <div
14
+ className={cn(
15
+ 'relative w-full aspect-square overflow-hidden rounded-xl border border-gray-100',
16
+ className
17
+ )}
18
+ {...props}
19
+ >
20
+ <div className="w-full h-2/3">
21
+ <Skeleton className="w-full h-full" />
22
+ </div>
23
+ <div className="mt-3 mb-3 ml-3">
24
+ <Skeleton className="mb-2 h-4 w-2/3" />
25
+ <Skeleton className="mb-2 h-5 w-1/3" />
26
+ </div>
27
+ </div>
28
+ )
29
+ }
30
+
31
+ export {MerchantCardSkeleton}
@@ -202,6 +202,7 @@ function MerchantCardRating({
202
202
  }
203
203
 
204
204
  export interface MerchantCardProps {
205
+ variant?: 'default' | 'compact'
205
206
  shop: Shop
206
207
  touchable?: boolean
207
208
  }
@@ -225,8 +226,10 @@ function MerchantCard({shop, touchable = true}: MerchantCardProps) {
225
226
  return (
226
227
  <MerchantCardRoot touchable={touchable} onPress={handlePress}>
227
228
  <MerchantCardImageContainer>
228
- {/* TODO: Add featured image */}
229
- <MerchantCardImage src={undefined} alt={`${name} featured image`} />
229
+ <MerchantCardImage
230
+ src={visualTheme?.featuredImages?.[0]?.url}
231
+ alt={`${name} featured image`}
232
+ />
230
233
  <MerchantCardLogo
231
234
  src={visualTheme?.logoImage?.url}
232
235
  alt={`${name} logo`}