@depict-ai/portal-components 2.7.17 → 2.7.18
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.
- package/dist/index.d.ts +1 -1
- package/dist/main.js +28 -9
- package/dist/module.js +29 -10
- package/package.json +1 -1
- package/src/specialForShopify/DefaultSolidProductCard.tsx +37 -5
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { SearchFilter } from "@depict-ai/types/api/SearchResponse";
|
|
|
3
3
|
import { Locale } from "@depict-ai/react-ui/locales/latest";
|
|
4
4
|
import { ReactNode } from "react";
|
|
5
5
|
import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
|
|
6
|
-
export const version = "2.7.
|
|
6
|
+
export const version = "2.7.18";
|
|
7
7
|
type TextOptions = {
|
|
8
8
|
/** Enabled */
|
|
9
9
|
enabled: boolean;
|
package/dist/main.js
CHANGED
|
@@ -18,7 +18,7 @@ $parcel$export(module.exports, "ExpandingSection", () => $2214dc111b9e2866$expor
|
|
|
18
18
|
$parcel$export(module.exports, "ReactLookCard", () => $35bab9ff48bfe404$export$48787da2a5568bc);
|
|
19
19
|
$parcel$export(module.exports, "version", () => $0a017be3a74fcc94$export$83d89fbfd8236492);
|
|
20
20
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
21
|
-
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.
|
|
21
|
+
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.18";
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -96,6 +96,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
96
96
|
const defaultVariantIndex = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_index);
|
|
97
97
|
const [showVariantIndex, setShowVariantIndex] = (0, $7jsgb$solidjs.createSignal)((0, $7jsgb$solidjs.untrack)(defaultVariantIndex));
|
|
98
98
|
const [cardIsHovered, setCardIsHovered] = (0, $7jsgb$solidjs.createSignal)(false);
|
|
99
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = (0, $7jsgb$solidjs.createSignal)();
|
|
99
100
|
const variantToShow = (0, $7jsgb$solidjs.createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
|
|
100
101
|
const noHoverSupport_ = (0, $7jsgb$depictaiuilatest.media_query_to_accessor)("(hover: none)");
|
|
101
102
|
const [salePrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.sale_price);
|
|
@@ -195,7 +196,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
195
196
|
(0, $7jsgb$solidjs.createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
196
197
|
// For switch from placeholders to product
|
|
197
198
|
(0, $7jsgb$solidjs.createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
|
|
198
|
-
|
|
199
|
+
const element = (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ContainsColorSwatchesProvider, {
|
|
199
200
|
get children () {
|
|
200
201
|
var _el$3 = $3375ddd88f77967d$var$_tmpl$3();
|
|
201
202
|
(0, $7jsgb$solidjsweb.addEventListener)(_el$3, "mouseleave", (0, $7jsgb$depictaiutilisharedlatest.catchify)(()=>!noHoverSupport_() && setCardIsHovered(false)));
|
|
@@ -259,7 +260,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
259
260
|
get children () {
|
|
260
261
|
return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$Sizes, {
|
|
261
262
|
sizesInStock_: sizesInStock_,
|
|
262
|
-
fontSizeRem_: ()=>titleOptions().font_size_rem
|
|
263
|
+
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
264
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
263
265
|
});
|
|
264
266
|
}
|
|
265
267
|
});
|
|
@@ -284,7 +286,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
284
286
|
HoveredComponent_: ({ ref_: ref_ })=>(0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$Sizes, {
|
|
285
287
|
sizesInStock_: sizesInStock_,
|
|
286
288
|
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
287
|
-
ref_: ref_
|
|
289
|
+
ref_: ref_,
|
|
290
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
288
291
|
}),
|
|
289
292
|
cardIsHovered_: cardIsHovered,
|
|
290
293
|
containerComponent_: ()=>containsColorSwatches() && LinkWrapped
|
|
@@ -363,6 +366,13 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
363
366
|
return _el$3;
|
|
364
367
|
}
|
|
365
368
|
});
|
|
369
|
+
// Now that we have created the ShopifyContainedImage, we can hook into its resize observer to know how many sizes we can fit into the size container
|
|
370
|
+
const context = (0, $7jsgb$depictaiuilatest.useListing)();
|
|
371
|
+
if (context) {
|
|
372
|
+
const signal = context[0, $7jsgb$depictaiuilatest.shopifyContainedImageContextSymbol];
|
|
373
|
+
(0, $7jsgb$solidjs.createEffect)(()=>setWidthAvailableForSizes(signal?.[0]?.()?.[0]?.()));
|
|
374
|
+
}
|
|
375
|
+
return element;
|
|
366
376
|
}
|
|
367
377
|
/**
|
|
368
378
|
* Transitions between DefaultComponent_ and HoveredComponent_ when cardIsHovered_ changes in both height and opacity.
|
|
@@ -540,12 +550,19 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
540
550
|
}
|
|
541
551
|
});
|
|
542
552
|
}
|
|
543
|
-
function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_ }) {
|
|
544
|
-
const keys = ()=>[
|
|
553
|
+
function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_, widthAvailableForSizes_: widthAvailableForSizes_ }) {
|
|
554
|
+
const keys = (0, $7jsgb$solidjs.createMemo)(()=>[
|
|
545
555
|
...sizesInStock_().keys()
|
|
546
|
-
];
|
|
547
|
-
const
|
|
548
|
-
const
|
|
556
|
+
]);
|
|
557
|
+
const gap = (0, $7jsgb$solidjs.createMemo)(()=>widthAvailableForSizes_() <= 250 ? 12 : 16);
|
|
558
|
+
const showMax = (0, $7jsgb$solidjs.createMemo)(()=>{
|
|
559
|
+
const fontSizeCircaPx = fontSizeRem_() * 16;
|
|
560
|
+
const availableWidth = widthAvailableForSizes_();
|
|
561
|
+
if (availableWidth && availableWidth < fontSizeCircaPx * 7 + gap() * 7 && keys().length > 4) return 2;
|
|
562
|
+
return 7;
|
|
563
|
+
});
|
|
564
|
+
const keysToShow = (0, $7jsgb$solidjs.createMemo)(()=>keys().slice(0, showMax()));
|
|
565
|
+
const hidden = (0, $7jsgb$solidjs.createMemo)(()=>keys().length - keysToShow().length);
|
|
549
566
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
550
567
|
get when () {
|
|
551
568
|
return keysToShow().length > 1;
|
|
@@ -556,6 +573,7 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
556
573
|
ref_?.(el);
|
|
557
574
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
558
575
|
(0, $7jsgb$solidjs.createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
576
|
+
(0, $7jsgb$solidjs.createEffect)(()=>el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
559
577
|
}, _el$7);
|
|
560
578
|
(0, $7jsgb$solidjsweb.insert)(_el$7, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
|
|
561
579
|
get each () {
|
|
@@ -589,6 +607,7 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
589
607
|
return _el$8;
|
|
590
608
|
}
|
|
591
609
|
}), null);
|
|
610
|
+
(0, $7jsgb$solidjsweb.effect)(()=>_el$7.classList.toggle("small", !!(widthAvailableForSizes_() < 250)));
|
|
592
611
|
return _el$7;
|
|
593
612
|
}
|
|
594
613
|
});
|
package/dist/module.js
CHANGED
|
@@ -2,12 +2,12 @@ import {add_to_version_info as $2MCgq$add_to_version_info, standard_price_format
|
|
|
2
2
|
import {render as $2MCgq$render, template as $2MCgq$template, createComponent as $2MCgq$createComponent, addEventListener as $2MCgq$addEventListener, use as $2MCgq$use, insert as $2MCgq$insert, effect as $2MCgq$effect, className as $2MCgq$className, setAttribute as $2MCgq$setAttribute, memo as $2MCgq$memo, style as $2MCgq$style, classList as $2MCgq$classList, spread as $2MCgq$spread, mergeProps as $2MCgq$mergeProps, delegateEvents as $2MCgq$delegateEvents} from "solid-js/web";
|
|
3
3
|
import {useRef as $2MCgq$useRef, useState as $2MCgq$useState, useEffect as $2MCgq$useEffect, createElement as $2MCgq$createElement, Fragment as $2MCgq$Fragment} from "react";
|
|
4
4
|
import {createStore as $2MCgq$createStore, reconcile as $2MCgq$reconcile} from "solid-js/store";
|
|
5
|
-
import {media_query_to_accessor as $2MCgq$media_query_to_accessor, TextPlaceholder as $2MCgq$TextPlaceholder, useSlidableInformation as $2MCgq$useSlidableInformation, SlidableItems as $2MCgq$SlidableItems, ImagePlaceholder as $2MCgq$ImagePlaceholder, ImageContainer as $2MCgq$ImageContainer, ShopifyContainedImage as $2MCgq$ShopifyContainedImage, useVisibilityState as $2MCgq$useVisibilityState, useProductCardIndex as $2MCgq$useProductCardIndex, useProductCardIsVisible as $2MCgq$useProductCardIsVisible, accessor_of_object_to_object_with_accessor_values as $2MCgq$accessor_of_object_to_object_with_accessor_values, create_modified_filters as $2MCgq$create_modified_filters, SelectedFilters as $2MCgq$SelectedFilters, FilterBody as $2MCgq$FilterBody, ExpandingDetails as $2MCgq$ExpandingDetails, ListingProvider as $2MCgq$ListingProvider, PseudoRouter as $2MCgq$PseudoRouter, LookCard as $2MCgq$LookCard} from "@depict-ai/ui/latest";
|
|
5
|
+
import {media_query_to_accessor as $2MCgq$media_query_to_accessor, TextPlaceholder as $2MCgq$TextPlaceholder, useListing as $2MCgq$useListing, shopifyContainedImageContextSymbol as $2MCgq$shopifyContainedImageContextSymbol, useSlidableInformation as $2MCgq$useSlidableInformation, SlidableItems as $2MCgq$SlidableItems, ImagePlaceholder as $2MCgq$ImagePlaceholder, ImageContainer as $2MCgq$ImageContainer, ShopifyContainedImage as $2MCgq$ShopifyContainedImage, useVisibilityState as $2MCgq$useVisibilityState, useProductCardIndex as $2MCgq$useProductCardIndex, useProductCardIsVisible as $2MCgq$useProductCardIsVisible, accessor_of_object_to_object_with_accessor_values as $2MCgq$accessor_of_object_to_object_with_accessor_values, create_modified_filters as $2MCgq$create_modified_filters, SelectedFilters as $2MCgq$SelectedFilters, FilterBody as $2MCgq$FilterBody, ExpandingDetails as $2MCgq$ExpandingDetails, ListingProvider as $2MCgq$ListingProvider, PseudoRouter as $2MCgq$PseudoRouter, LookCard as $2MCgq$LookCard} from "@depict-ai/ui/latest";
|
|
6
6
|
import {createContext as $2MCgq$createContext, createMemo as $2MCgq$createMemo, createSignal as $2MCgq$createSignal, untrack as $2MCgq$untrack, createResource as $2MCgq$createResource, Suspense as $2MCgq$Suspense, createEffect as $2MCgq$createEffect, children as $2MCgq$children, Show as $2MCgq$Show, onCleanup as $2MCgq$onCleanup, For as $2MCgq$For, createRenderEffect as $2MCgq$createRenderEffect, on as $2MCgq$on, useContext as $2MCgq$useContext} from "solid-js";
|
|
7
7
|
import {createPortal as $2MCgq$createPortal} from "react-dom";
|
|
8
8
|
|
|
9
9
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
10
|
-
const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.
|
|
10
|
+
const $91c11b750e80ede3$export$83d89fbfd8236492 = "2.7.18";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -85,6 +85,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
85
85
|
const defaultVariantIndex = (0, $2MCgq$createMemo)(()=>display()?.variant_index);
|
|
86
86
|
const [showVariantIndex, setShowVariantIndex] = (0, $2MCgq$createSignal)((0, $2MCgq$untrack)(defaultVariantIndex));
|
|
87
87
|
const [cardIsHovered, setCardIsHovered] = (0, $2MCgq$createSignal)(false);
|
|
88
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = (0, $2MCgq$createSignal)();
|
|
88
89
|
const variantToShow = (0, $2MCgq$createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
|
|
89
90
|
const noHoverSupport_ = (0, $2MCgq$media_query_to_accessor)("(hover: none)");
|
|
90
91
|
const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
|
|
@@ -184,7 +185,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
184
185
|
(0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
185
186
|
// For switch from placeholders to product
|
|
186
187
|
(0, $2MCgq$createEffect)(()=>!showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex()));
|
|
187
|
-
|
|
188
|
+
const element = (0, $2MCgq$createComponent)($29535f590238371c$var$ContainsColorSwatchesProvider, {
|
|
188
189
|
get children () {
|
|
189
190
|
var _el$3 = $29535f590238371c$var$_tmpl$3();
|
|
190
191
|
(0, $2MCgq$addEventListener)(_el$3, "mouseleave", (0, $2MCgq$catchify)(()=>!noHoverSupport_() && setCardIsHovered(false)));
|
|
@@ -248,7 +249,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
248
249
|
get children () {
|
|
249
250
|
return (0, $2MCgq$createComponent)($29535f590238371c$var$Sizes, {
|
|
250
251
|
sizesInStock_: sizesInStock_,
|
|
251
|
-
fontSizeRem_: ()=>titleOptions().font_size_rem
|
|
252
|
+
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
253
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
252
254
|
});
|
|
253
255
|
}
|
|
254
256
|
});
|
|
@@ -273,7 +275,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
273
275
|
HoveredComponent_: ({ ref_: ref_ })=>(0, $2MCgq$createComponent)($29535f590238371c$var$Sizes, {
|
|
274
276
|
sizesInStock_: sizesInStock_,
|
|
275
277
|
fontSizeRem_: ()=>titleOptions().font_size_rem,
|
|
276
|
-
ref_: ref_
|
|
278
|
+
ref_: ref_,
|
|
279
|
+
widthAvailableForSizes_: widthAvailableForSizes
|
|
277
280
|
}),
|
|
278
281
|
cardIsHovered_: cardIsHovered,
|
|
279
282
|
containerComponent_: ()=>containsColorSwatches() && LinkWrapped
|
|
@@ -352,6 +355,13 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
352
355
|
return _el$3;
|
|
353
356
|
}
|
|
354
357
|
});
|
|
358
|
+
// Now that we have created the ShopifyContainedImage, we can hook into its resize observer to know how many sizes we can fit into the size container
|
|
359
|
+
const context = (0, $2MCgq$useListing)();
|
|
360
|
+
if (context) {
|
|
361
|
+
const signal = context[0, $2MCgq$shopifyContainedImageContextSymbol];
|
|
362
|
+
(0, $2MCgq$createEffect)(()=>setWidthAvailableForSizes(signal?.[0]?.()?.[0]?.()));
|
|
363
|
+
}
|
|
364
|
+
return element;
|
|
355
365
|
}
|
|
356
366
|
/**
|
|
357
367
|
* Transitions between DefaultComponent_ and HoveredComponent_ when cardIsHovered_ changes in both height and opacity.
|
|
@@ -529,12 +539,19 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
529
539
|
}
|
|
530
540
|
});
|
|
531
541
|
}
|
|
532
|
-
function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_ }) {
|
|
533
|
-
const keys = ()=>[
|
|
542
|
+
function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_, fontSizeRem_: fontSizeRem_, widthAvailableForSizes_: widthAvailableForSizes_ }) {
|
|
543
|
+
const keys = (0, $2MCgq$createMemo)(()=>[
|
|
534
544
|
...sizesInStock_().keys()
|
|
535
|
-
];
|
|
536
|
-
const
|
|
537
|
-
const
|
|
545
|
+
]);
|
|
546
|
+
const gap = (0, $2MCgq$createMemo)(()=>widthAvailableForSizes_() <= 250 ? 12 : 16);
|
|
547
|
+
const showMax = (0, $2MCgq$createMemo)(()=>{
|
|
548
|
+
const fontSizeCircaPx = fontSizeRem_() * 16;
|
|
549
|
+
const availableWidth = widthAvailableForSizes_();
|
|
550
|
+
if (availableWidth && availableWidth < fontSizeCircaPx * 7 + gap() * 7 && keys().length > 4) return 2;
|
|
551
|
+
return 7;
|
|
552
|
+
});
|
|
553
|
+
const keysToShow = (0, $2MCgq$createMemo)(()=>keys().slice(0, showMax()));
|
|
554
|
+
const hidden = (0, $2MCgq$createMemo)(()=>keys().length - keysToShow().length);
|
|
538
555
|
return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
539
556
|
get when () {
|
|
540
557
|
return keysToShow().length > 1;
|
|
@@ -545,6 +562,7 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
545
562
|
ref_?.(el);
|
|
546
563
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
547
564
|
(0, $2MCgq$createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
565
|
+
(0, $2MCgq$createEffect)(()=>el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
548
566
|
}, _el$7);
|
|
549
567
|
(0, $2MCgq$insert)(_el$7, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
|
|
550
568
|
get each () {
|
|
@@ -578,6 +596,7 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
578
596
|
return _el$8;
|
|
579
597
|
}
|
|
580
598
|
}), null);
|
|
599
|
+
(0, $2MCgq$effect)(()=>_el$7.classList.toggle("small", !!(widthAvailableForSizes_() < 250)));
|
|
581
600
|
return _el$7;
|
|
582
601
|
}
|
|
583
602
|
});
|
package/package.json
CHANGED
|
@@ -11,6 +11,8 @@ import {
|
|
|
11
11
|
useProductCardIsVisible,
|
|
12
12
|
useSlidableInformation,
|
|
13
13
|
useVisibilityState,
|
|
14
|
+
shopifyContainedImageContextSymbol,
|
|
15
|
+
useListing,
|
|
14
16
|
} from "@depict-ai/ui/latest";
|
|
15
17
|
import { catchify, dlog, dwarn } from "@depict-ai/utilishared/latest";
|
|
16
18
|
import {
|
|
@@ -137,6 +139,7 @@ export function DefaultSolidProductCard(
|
|
|
137
139
|
const defaultVariantIndex = createMemo(() => display()?.variant_index);
|
|
138
140
|
const [showVariantIndex, setShowVariantIndex] = createSignal<number | undefined>(untrack(defaultVariantIndex));
|
|
139
141
|
const [cardIsHovered, setCardIsHovered] = createSignal(false);
|
|
142
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = createSignal<number | undefined>();
|
|
140
143
|
const variantToShow = createMemo(() => variantDisplays()?.[showVariantIndex() as number]);
|
|
141
144
|
const noHoverSupport_ = media_query_to_accessor("(hover: none)");
|
|
142
145
|
const [salePrice] = createResource(variantToShow, v => v?.sale_price);
|
|
@@ -247,7 +250,7 @@ export function DefaultSolidProductCard(
|
|
|
247
250
|
() => !showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex())
|
|
248
251
|
);
|
|
249
252
|
|
|
250
|
-
|
|
253
|
+
const element = (
|
|
251
254
|
<ContainsColorSwatchesProvider>
|
|
252
255
|
<div
|
|
253
256
|
class={`d-product-card`}
|
|
@@ -289,7 +292,11 @@ export function DefaultSolidProductCard(
|
|
|
289
292
|
fallback={
|
|
290
293
|
<Show when={configuredOptions_().sizes}>
|
|
291
294
|
<LinkWrappedIfHaveSwatches>
|
|
292
|
-
<Sizes
|
|
295
|
+
<Sizes
|
|
296
|
+
sizesInStock_={sizesInStock_}
|
|
297
|
+
fontSizeRem_={() => titleOptions().font_size_rem}
|
|
298
|
+
widthAvailableForSizes_={widthAvailableForSizes}
|
|
299
|
+
/>
|
|
293
300
|
</LinkWrappedIfHaveSwatches>
|
|
294
301
|
</Show>
|
|
295
302
|
}
|
|
@@ -309,6 +316,7 @@ export function DefaultSolidProductCard(
|
|
|
309
316
|
sizesInStock_={sizesInStock_}
|
|
310
317
|
fontSizeRem_={() => titleOptions().font_size_rem}
|
|
311
318
|
ref_={ref_}
|
|
319
|
+
widthAvailableForSizes_={widthAvailableForSizes}
|
|
312
320
|
/>
|
|
313
321
|
)}
|
|
314
322
|
cardIsHovered_={cardIsHovered}
|
|
@@ -379,6 +387,17 @@ export function DefaultSolidProductCard(
|
|
|
379
387
|
</div>
|
|
380
388
|
</ContainsColorSwatchesProvider>
|
|
381
389
|
);
|
|
390
|
+
|
|
391
|
+
// Now that we have created the ShopifyContainedImage, we can hook into its resize observer to know how many sizes we can fit into the size container
|
|
392
|
+
const context = useListing();
|
|
393
|
+
if (context) {
|
|
394
|
+
const signal = context[shopifyContainedImageContextSymbol] as
|
|
395
|
+
| Signal<[Accessor<number>, Accessor<number>] | undefined>
|
|
396
|
+
| undefined;
|
|
397
|
+
createEffect(() => setWidthAvailableForSizes(signal?.[0]?.()?.[0]?.()));
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
return element;
|
|
382
401
|
}
|
|
383
402
|
|
|
384
403
|
/**
|
|
@@ -586,23 +605,36 @@ function Sizes({
|
|
|
586
605
|
sizesInStock_,
|
|
587
606
|
ref_,
|
|
588
607
|
fontSizeRem_,
|
|
608
|
+
widthAvailableForSizes_,
|
|
589
609
|
}: {
|
|
590
610
|
sizesInStock_: Accessor<Map<string, boolean>>;
|
|
591
611
|
ref_?: (el: HTMLDivElement) => void;
|
|
592
612
|
fontSizeRem_: Accessor<number>;
|
|
613
|
+
widthAvailableForSizes_: Accessor<number | undefined>;
|
|
593
614
|
}) {
|
|
594
|
-
const keys = () => [...sizesInStock_().keys()];
|
|
595
|
-
const
|
|
596
|
-
const
|
|
615
|
+
const keys = createMemo(() => [...sizesInStock_().keys()]);
|
|
616
|
+
const gap = createMemo(() => ((widthAvailableForSizes_() as number) <= 250 ? 12 : 16));
|
|
617
|
+
const showMax = createMemo(() => {
|
|
618
|
+
const fontSizeCircaPx = fontSizeRem_() * 16;
|
|
619
|
+
const availableWidth = widthAvailableForSizes_();
|
|
620
|
+
if (availableWidth && availableWidth < fontSizeCircaPx * 7 + gap() * 7 && keys().length > 4) {
|
|
621
|
+
return 2;
|
|
622
|
+
}
|
|
623
|
+
return 7;
|
|
624
|
+
});
|
|
625
|
+
const keysToShow = createMemo(() => keys().slice(0, showMax()));
|
|
626
|
+
const hidden = createMemo(() => keys().length - keysToShow().length);
|
|
597
627
|
|
|
598
628
|
return (
|
|
599
629
|
<Show when={keysToShow().length > 1}>
|
|
600
630
|
<div
|
|
601
631
|
class="sizes"
|
|
632
|
+
classList={{ small: (widthAvailableForSizes_() as number) < 250 }}
|
|
602
633
|
ref={el => {
|
|
603
634
|
ref_?.(el);
|
|
604
635
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
605
636
|
createEffect(() => el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
637
|
+
createEffect(() => el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
606
638
|
}}
|
|
607
639
|
>
|
|
608
640
|
<For each={sortSizes(keysToShow())}>
|