@usequeek/theme-kit 0.5.6 → 0.5.7

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.
@@ -123,7 +123,7 @@ export function DefaultCartShell({
123
123
  return (
124
124
  <li key={`${item.shop_id}-${item.id}`} className="core-cart-page__item">
125
125
  {item.image ? (
126
- <Image src={item.image} alt={item.title} className="core-cart-page__item-img" />
126
+ <Image src={item.image} variants={item.image_variants} intent="card" sizes="150px" alt={item.title} className="core-cart-page__item-img" />
127
127
  ) : (
128
128
  <div className="core-cart-page__item-img core-cart-page__item-img--placeholder" />
129
129
  )}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@usequeek/theme-kit",
3
- "version": "0.5.6",
3
+ "version": "0.5.7",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "description": "The runtime a Queek storefront theme is built on: hooks, stores, page renderer, navigation, shared blocks and locale strings.",
@@ -187,7 +187,11 @@ export const useCartStore = create<CartState>()(
187
187
  // A variant's own price/stock override the base product's — the same
188
188
  // precedence the quick-add flow uses.
189
189
  const unitPrice = (variant?.pricing.sale_amount ?? product.pricing.sale_amount) + addonTotal;
190
- const itemImage = variant?.media.thumbnail ?? variant?.media.image ?? product.media.thumbnail ?? product.media.image ?? null;
190
+ const itemMedia = [variant?.media, product.media].find((media) => media && (media.thumbnail ?? media.image) != null);
191
+ const itemImage = itemMedia ? (itemMedia.thumbnail ?? itemMedia.image) : null;
192
+ // The tier map belongs to `media.image`: when the picked url IS that image (the API's thumbnail falls back to it) the line can
193
+ // render a small copy; a separate thumbnail file is small already.
194
+ const itemImageVariants = itemMedia && itemImage === itemMedia.image ? (itemMedia.image_variants ?? null) : null;
191
195
 
192
196
  // Confirm the add with a global toast (works across every theme) —
193
197
  // except on QR, which has its own persistent cart bar (QrCartBar)
@@ -235,6 +239,7 @@ export const useCartStore = create<CartState>()(
235
239
  title: product.title,
236
240
  slug: product.slug,
237
241
  image: itemImage,
242
+ ...(itemImageVariants ? { image_variants: itemImageVariants } : {}),
238
243
  unit_price: unitPrice,
239
244
  quantity: Math.max(1, quantity),
240
245
  addons,
package/types/cart.ts CHANGED
@@ -1,3 +1,5 @@
1
+ import type { ImageVariants } from './media';
2
+
1
3
  export interface CartAddon {
2
4
  addon_id: string;
3
5
  item_id: string;
@@ -12,6 +14,12 @@ export interface CartItem {
12
14
  title: string;
13
15
  slug?: string | null;
14
16
  image: string | null;
17
+ /**
18
+ * The tier map of `image` (the API's `image_variants`), kept so a cart thumbnail renders a small WebP copy: the line's `image` is
19
+ * the product's thumbnail, which the API sets to the full image unless the merchant chose another. Null when `image` is a separate,
20
+ * explicit thumbnail file (already small) or is not Media-backed; absent on a line saved before the kit kept it.
21
+ */
22
+ image_variants?: ImageVariants | null;
15
23
  unit_price: number;
16
24
  quantity: number;
17
25
  addons: CartAddon[];
package/types/vendor.ts CHANGED
@@ -209,6 +209,8 @@ export interface StorefrontConfig {
209
209
  default_variants?: Record<string, string>;
210
210
  pages?: Record<string, {
211
211
  banner?: string;
212
+ /** The tier map of `banner` (the API's `image_variants` contract); null when the banner is not Media-backed, absent without a banner. */
213
+ banner_variants?: ImageVariants | null;
212
214
  title?: string;
213
215
  subtitle?: string;
214
216
  /** QR-only header overrides, each falling back to the vendor's own
@@ -1,5 +1,5 @@
1
1
  import type { ImageVariants } from '../types/media';
2
- import type { Product, ProductImage } from '../types/product';
2
+ import type { Product, ProductImage, ProductMedia } from '../types/product';
3
3
 
4
4
  export interface MediaFrame {
5
5
  id: string;
@@ -37,6 +37,19 @@ export function getSlideshowImages(product: Product): ProductImage[] {
37
37
  );
38
38
  }
39
39
 
40
+ /**
41
+ * The tier map to pass to `<Image variants>` for a product picture: `media.image_variants` only when `src` IS the main image.
42
+ * A card or thumb often renders `media.thumbnail ?? media.image`; the API sets the thumbnail to the main image unless the merchant chose
43
+ * a separate thumbnail file, and `<Image>` renders the variants' url ahead of `src`, so the main photo's copies would replace the
44
+ * merchant's own thumbnail. Null for any other src (the thumbnail file is small already), for no src and for no media.
45
+ */
46
+ export function mainImageVariants(
47
+ src: string | null | undefined,
48
+ media: Pick<ProductMedia, 'image' | 'image_variants'> | null | undefined,
49
+ ): ImageVariants | null {
50
+ return src && media && media.image === src ? (media.image_variants ?? null) : null;
51
+ }
52
+
40
53
  /**
41
54
  * The card hover-swap source: the second ordered image. Null unless the
42
55
  * product carries at least two images — callers render the primary alone.