@depict-ai/portal-components 2.7.16 → 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 +30 -11
- package/dist/module.js +31 -12
- package/package.json +2 -2
- package/src/specialForShopify/DefaultSolidProductCard.tsx +40 -7
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
|
|
|
@@ -91,11 +91,12 @@ const $3375ddd88f77967d$var$sizeOrder = [
|
|
|
91
91
|
];
|
|
92
92
|
const $3375ddd88f77967d$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $7jsgb$solidjs.createContext)();
|
|
93
93
|
let $3375ddd88f77967d$var$colorCanvasContext;
|
|
94
|
-
function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOptions_) {
|
|
94
|
+
function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOptions_, overrideAspectRatio) {
|
|
95
95
|
const variantDisplays = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_displays);
|
|
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);
|
|
@@ -105,7 +106,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
105
106
|
return originalPrice() !== salePrice();
|
|
106
107
|
}
|
|
107
108
|
}));
|
|
108
|
-
const aspectRatio_ = (0, $7jsgb$solidjs.createMemo)(()=>configuredOptions_().image_aspect_ratio);
|
|
109
|
+
const aspectRatio_ = (0, $7jsgb$solidjs.createMemo)(()=>overrideAspectRatio?.() || configuredOptions_().image_aspect_ratio);
|
|
109
110
|
const hasSizes = ()=>configuredOptions_().sizes && sizesInStock_().size > 1;
|
|
110
111
|
const sizesInStock_ = (0, $7jsgb$solidjs.createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
|
|
111
112
|
d.size_name,
|
|
@@ -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
|
|
|
@@ -80,11 +80,12 @@ const $29535f590238371c$var$sizeOrder = [
|
|
|
80
80
|
];
|
|
81
81
|
const $29535f590238371c$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $2MCgq$createContext)();
|
|
82
82
|
let $29535f590238371c$var$colorCanvasContext;
|
|
83
|
-
function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_) {
|
|
83
|
+
function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_, overrideAspectRatio) {
|
|
84
84
|
const variantDisplays = (0, $2MCgq$createMemo)(()=>display()?.variant_displays);
|
|
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);
|
|
@@ -94,7 +95,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
94
95
|
return originalPrice() !== salePrice();
|
|
95
96
|
}
|
|
96
97
|
}));
|
|
97
|
-
const aspectRatio_ = (0, $2MCgq$createMemo)(()=>configuredOptions_().image_aspect_ratio);
|
|
98
|
+
const aspectRatio_ = (0, $2MCgq$createMemo)(()=>overrideAspectRatio?.() || configuredOptions_().image_aspect_ratio);
|
|
98
99
|
const hasSizes = ()=>configuredOptions_().sizes && sizesInStock_().size > 1;
|
|
99
100
|
const sizesInStock_ = (0, $2MCgq$createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
|
|
100
101
|
d.size_name,
|
|
@@ -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
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depict-ai/portal-components",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.18",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -101,7 +101,7 @@
|
|
|
101
101
|
"dependencies": {
|
|
102
102
|
"@babel/runtime": "latest",
|
|
103
103
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
104
|
-
"@depict-ai/plp-styling": "^4.4.
|
|
104
|
+
"@depict-ai/plp-styling": "^4.4.17",
|
|
105
105
|
"@depict-ai/react-ui": "^4.8.6",
|
|
106
106
|
"@depict-ai/types": "^5.4.4",
|
|
107
107
|
"@depict-ai/ui": "^4.8.16",
|
|
@@ -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 {
|
|
@@ -130,18 +132,20 @@ export function DefaultSolidProductCard(
|
|
|
130
132
|
// In development (product card editor), a fallback formatting will be used.
|
|
131
133
|
formatPrice: <T extends number | undefined>(price: T) => T extends undefined ? undefined : string;
|
|
132
134
|
}),
|
|
133
|
-
configuredOptions_: Accessor<ProductCardSchema
|
|
135
|
+
configuredOptions_: Accessor<ProductCardSchema>,
|
|
136
|
+
overrideAspectRatio?: Accessor<number>
|
|
134
137
|
) {
|
|
135
138
|
const variantDisplays = createMemo(() => display()?.variant_displays);
|
|
136
139
|
const defaultVariantIndex = createMemo(() => display()?.variant_index);
|
|
137
140
|
const [showVariantIndex, setShowVariantIndex] = createSignal<number | undefined>(untrack(defaultVariantIndex));
|
|
138
141
|
const [cardIsHovered, setCardIsHovered] = createSignal(false);
|
|
142
|
+
const [widthAvailableForSizes, setWidthAvailableForSizes] = createSignal<number | undefined>();
|
|
139
143
|
const variantToShow = createMemo(() => variantDisplays()?.[showVariantIndex() as number]);
|
|
140
144
|
const noHoverSupport_ = media_query_to_accessor("(hover: none)");
|
|
141
145
|
const [salePrice] = createResource(variantToShow, v => v?.sale_price);
|
|
142
146
|
const [originalPrice] = createResource(variantToShow, v => v?.original_price);
|
|
143
147
|
const onSale = createMemo(() => <Suspense>{originalPrice() !== salePrice()}</Suspense>);
|
|
144
|
-
const aspectRatio_ = createMemo(() => configuredOptions_().image_aspect_ratio);
|
|
148
|
+
const aspectRatio_ = createMemo(() => overrideAspectRatio?.() || configuredOptions_().image_aspect_ratio);
|
|
145
149
|
const hasSizes = () => configuredOptions_().sizes && sizesInStock_().size > 1;
|
|
146
150
|
const sizesInStock_ = createMemo(
|
|
147
151
|
() =>
|
|
@@ -246,7 +250,7 @@ export function DefaultSolidProductCard(
|
|
|
246
250
|
() => !showVariantIndex() && defaultVariantIndex() != undefined && setShowVariantIndex(defaultVariantIndex())
|
|
247
251
|
);
|
|
248
252
|
|
|
249
|
-
|
|
253
|
+
const element = (
|
|
250
254
|
<ContainsColorSwatchesProvider>
|
|
251
255
|
<div
|
|
252
256
|
class={`d-product-card`}
|
|
@@ -288,7 +292,11 @@ export function DefaultSolidProductCard(
|
|
|
288
292
|
fallback={
|
|
289
293
|
<Show when={configuredOptions_().sizes}>
|
|
290
294
|
<LinkWrappedIfHaveSwatches>
|
|
291
|
-
<Sizes
|
|
295
|
+
<Sizes
|
|
296
|
+
sizesInStock_={sizesInStock_}
|
|
297
|
+
fontSizeRem_={() => titleOptions().font_size_rem}
|
|
298
|
+
widthAvailableForSizes_={widthAvailableForSizes}
|
|
299
|
+
/>
|
|
292
300
|
</LinkWrappedIfHaveSwatches>
|
|
293
301
|
</Show>
|
|
294
302
|
}
|
|
@@ -308,6 +316,7 @@ export function DefaultSolidProductCard(
|
|
|
308
316
|
sizesInStock_={sizesInStock_}
|
|
309
317
|
fontSizeRem_={() => titleOptions().font_size_rem}
|
|
310
318
|
ref_={ref_}
|
|
319
|
+
widthAvailableForSizes_={widthAvailableForSizes}
|
|
311
320
|
/>
|
|
312
321
|
)}
|
|
313
322
|
cardIsHovered_={cardIsHovered}
|
|
@@ -378,6 +387,17 @@ export function DefaultSolidProductCard(
|
|
|
378
387
|
</div>
|
|
379
388
|
</ContainsColorSwatchesProvider>
|
|
380
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;
|
|
381
401
|
}
|
|
382
402
|
|
|
383
403
|
/**
|
|
@@ -585,23 +605,36 @@ function Sizes({
|
|
|
585
605
|
sizesInStock_,
|
|
586
606
|
ref_,
|
|
587
607
|
fontSizeRem_,
|
|
608
|
+
widthAvailableForSizes_,
|
|
588
609
|
}: {
|
|
589
610
|
sizesInStock_: Accessor<Map<string, boolean>>;
|
|
590
611
|
ref_?: (el: HTMLDivElement) => void;
|
|
591
612
|
fontSizeRem_: Accessor<number>;
|
|
613
|
+
widthAvailableForSizes_: Accessor<number | undefined>;
|
|
592
614
|
}) {
|
|
593
|
-
const keys = () => [...sizesInStock_().keys()];
|
|
594
|
-
const
|
|
595
|
-
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);
|
|
596
627
|
|
|
597
628
|
return (
|
|
598
629
|
<Show when={keysToShow().length > 1}>
|
|
599
630
|
<div
|
|
600
631
|
class="sizes"
|
|
632
|
+
classList={{ small: (widthAvailableForSizes_() as number) < 250 }}
|
|
601
633
|
ref={el => {
|
|
602
634
|
ref_?.(el);
|
|
603
635
|
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
604
636
|
createEffect(() => el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
637
|
+
createEffect(() => el.style.setProperty("--sizes-gap", gap() + "px"));
|
|
605
638
|
}}
|
|
606
639
|
>
|
|
607
640
|
<For each={sortSizes(keysToShow())}>
|