@depict-ai/portal-components 2.7.6 → 2.7.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.
- package/dist/index.d.ts +2 -1
- package/dist/main.js +117 -95
- package/dist/module.js +118 -96
- package/package.json +8 -8
- package/src/specialForShopify/DefaultSolidProductCard.tsx +99 -60
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.7";
|
|
7
7
|
type TextOptions = {
|
|
8
8
|
/** Enabled */
|
|
9
9
|
enabled: boolean;
|
|
@@ -41,6 +41,7 @@ type ProductCardSchema = {
|
|
|
41
41
|
use_hover_image: boolean;
|
|
42
42
|
/** Image Carousel */
|
|
43
43
|
image_carousel: boolean;
|
|
44
|
+
image_aspect_ratio: number;
|
|
44
45
|
};
|
|
45
46
|
export function ReactDefaultProductCard(react_props: {
|
|
46
47
|
options: ProductCardSchema;
|
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.7";
|
|
22
22
|
|
|
23
23
|
|
|
24
24
|
|
|
@@ -68,7 +68,6 @@ const $3375ddd88f77967d$var$sizeOrder = [
|
|
|
68
68
|
"One Size",
|
|
69
69
|
"Onesize"
|
|
70
70
|
];
|
|
71
|
-
const $3375ddd88f77967d$var$imageAspectRatio = 1;
|
|
72
71
|
const $3375ddd88f77967d$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $7jsgb$solidjs.createContext)();
|
|
73
72
|
let $3375ddd88f77967d$var$colorCanvasContext;
|
|
74
73
|
function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOptions_ = ()=>({
|
|
@@ -106,7 +105,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
106
105
|
},
|
|
107
106
|
use_hover_image: true,
|
|
108
107
|
image_carousel: true,
|
|
109
|
-
color_options: true
|
|
108
|
+
color_options: true,
|
|
109
|
+
image_aspect_ratio: 1
|
|
110
110
|
})) {
|
|
111
111
|
const variantDisplays = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_displays);
|
|
112
112
|
const defaultVariantIndex = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_index);
|
|
@@ -114,6 +114,14 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
114
114
|
const [cardIsHovered, setCardIsHovered] = (0, $7jsgb$solidjs.createSignal)(false);
|
|
115
115
|
const variantToShow = (0, $7jsgb$solidjs.createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
|
|
116
116
|
const noHoverSupport_ = (0, $7jsgb$depictaiuilatest.media_query_to_accessor)("(hover: none)");
|
|
117
|
+
const [salePrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.sale_price);
|
|
118
|
+
const [originalPrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.original_price);
|
|
119
|
+
const onSale = (0, $7jsgb$solidjs.createMemo)(()=>(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Suspense), {
|
|
120
|
+
get children () {
|
|
121
|
+
return originalPrice() !== salePrice();
|
|
122
|
+
}
|
|
123
|
+
}));
|
|
124
|
+
const aspectRatio_ = (0, $7jsgb$solidjs.createMemo)(()=>configuredOptions_().image_aspect_ratio);
|
|
117
125
|
const sizesInStock_ = (0, $7jsgb$solidjs.createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
|
|
118
126
|
d.size_name,
|
|
119
127
|
d.in_stock
|
|
@@ -128,13 +136,6 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
128
136
|
}
|
|
129
137
|
]).filter(([colorName])=>colorName) // in case color_name is null
|
|
130
138
|
));
|
|
131
|
-
const [salePrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.sale_price);
|
|
132
|
-
const [originalPrice] = (0, $7jsgb$solidjs.createResource)(variantToShow, (v)=>v?.original_price);
|
|
133
|
-
const onSale = (0, $7jsgb$solidjs.createMemo)(()=>(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Suspense), {
|
|
134
|
-
get children () {
|
|
135
|
-
return originalPrice() !== salePrice();
|
|
136
|
-
}
|
|
137
|
-
}));
|
|
138
139
|
const swatchContainerHeight = (0, $7jsgb$solidjs.createMemo)(()=>{
|
|
139
140
|
// To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
|
|
140
141
|
let considerSize = [];
|
|
@@ -168,8 +169,10 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
168
169
|
})();
|
|
169
170
|
const Title = (props)=>(()=>{
|
|
170
171
|
var _el$2 = $3375ddd88f77967d$var$_tmpl$2();
|
|
171
|
-
|
|
172
|
-
|
|
172
|
+
(0, $7jsgb$solidjsweb.use)((el)=>{
|
|
173
|
+
props.ref_?.(el);
|
|
174
|
+
$3375ddd88f77967d$var$setStyleForTextOptions(el, titleOptions);
|
|
175
|
+
}, _el$2);
|
|
173
176
|
(0, $7jsgb$solidjsweb.insert)(_el$2, ()=>variantToShow()?.title ?? [
|
|
174
177
|
(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.TextPlaceholder), {
|
|
175
178
|
height: "1em",
|
|
@@ -180,17 +183,19 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
180
183
|
width: "20ch"
|
|
181
184
|
})
|
|
182
185
|
]);
|
|
183
|
-
(0, $7jsgb$solidjsweb.effect)((
|
|
184
|
-
var _v$3 = variantToShow()?.title, _v$4 = $3375ddd88f77967d$var$styleForTextOptions(titleOptions());
|
|
185
|
-
_v$3 !== _p$.e && (0, $7jsgb$solidjsweb.setAttribute)(_el$2, "title", _p$.e = _v$3);
|
|
186
|
-
_p$.t = (0, $7jsgb$solidjsweb.style)(_el$2, _v$4, _p$.t);
|
|
187
|
-
return _p$;
|
|
188
|
-
}, {
|
|
189
|
-
e: undefined,
|
|
190
|
-
t: undefined
|
|
191
|
-
});
|
|
186
|
+
(0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.setAttribute)(_el$2, "title", variantToShow()?.title));
|
|
192
187
|
return _el$2;
|
|
193
188
|
})();
|
|
189
|
+
const mainStyle = ()=>{
|
|
190
|
+
const { alignment: alignment } = configuredOptions_();
|
|
191
|
+
const flexAlignment = alignment === "center" ? alignment : "flex-" + alignment;
|
|
192
|
+
return {
|
|
193
|
+
"--flex-alignment": flexAlignment,
|
|
194
|
+
"--alignment": alignment
|
|
195
|
+
};
|
|
196
|
+
};
|
|
197
|
+
(0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
|
|
198
|
+
(0, $7jsgb$solidjs.createEffect)(()=>(0, $7jsgb$depictaiutilisharedlatest.dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
|
|
194
199
|
(0, $7jsgb$solidjs.createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
195
200
|
return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$ContainsColorSwatchesProvider, {
|
|
196
201
|
get children () {
|
|
@@ -204,7 +209,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
204
209
|
image_urls_: ()=>variantToShow()?.image_urls,
|
|
205
210
|
video_: ()=>variantToShow()?.videos?.[0],
|
|
206
211
|
configuredOptions_: configuredOptions_,
|
|
207
|
-
cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered()
|
|
212
|
+
cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered(),
|
|
213
|
+
aspectRatio_: aspectRatio_
|
|
208
214
|
});
|
|
209
215
|
}
|
|
210
216
|
}), null);
|
|
@@ -355,7 +361,7 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
355
361
|
})();
|
|
356
362
|
}
|
|
357
363
|
}), null);
|
|
358
|
-
(0, $7jsgb$solidjsweb.effect)(()=>
|
|
364
|
+
(0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$3, mainStyle(), _$p));
|
|
359
365
|
return _el$3;
|
|
360
366
|
}
|
|
361
367
|
});
|
|
@@ -476,8 +482,11 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
476
482
|
(0, $7jsgb$solidjs.onCleanup)(()=>setContainsColorSwatches(false));
|
|
477
483
|
return (()=>{
|
|
478
484
|
var _el$4 = $3375ddd88f77967d$var$_tmpl$5();
|
|
479
|
-
|
|
480
|
-
|
|
485
|
+
(0, $7jsgb$solidjsweb.use)((el)=>{
|
|
486
|
+
ref_?.(el);
|
|
487
|
+
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
488
|
+
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(el.style, "--swatch-container-height", wantedContainerHeightRem_() && wantedContainerHeightRem_() + "rem"));
|
|
489
|
+
}, _el$4);
|
|
481
490
|
(0, $7jsgb$solidjsweb.insert)(_el$4, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
|
|
482
491
|
get each () {
|
|
483
492
|
return entriesToShow();
|
|
@@ -503,11 +512,11 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
503
512
|
(0, $7jsgb$solidjsweb.setAttribute)(_el$6, "href", pageUrl_);
|
|
504
513
|
(0, $7jsgb$solidjsweb.setAttribute)(_el$6, "title", colorName);
|
|
505
514
|
(0, $7jsgb$solidjsweb.effect)((_p$)=>{
|
|
506
|
-
var _v$
|
|
507
|
-
_p$.e = (0, $7jsgb$solidjsweb.style)(_el$6, _v$
|
|
508
|
-
_v$
|
|
509
|
-
_v$
|
|
510
|
-
_v$
|
|
515
|
+
var _v$3 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$4 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$5 = !!thisColorIsDefaultColor(), _v$6 = !!($3375ddd88f77967d$var$isLightColor(hexColor_) || invalidColor());
|
|
516
|
+
_p$.e = (0, $7jsgb$solidjsweb.style)(_el$6, _v$3, _p$.e);
|
|
517
|
+
_v$4 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$4);
|
|
518
|
+
_v$5 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$5);
|
|
519
|
+
_v$6 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$6);
|
|
511
520
|
return _p$;
|
|
512
521
|
}, {
|
|
513
522
|
e: undefined,
|
|
@@ -527,7 +536,6 @@ function $3375ddd88f77967d$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
527
536
|
return $3375ddd88f77967d$var$_tmpl$4();
|
|
528
537
|
}
|
|
529
538
|
}), null);
|
|
530
|
-
(0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$4, isNaN(wantedContainerHeightRem_()) ? "" : `--swatch-container-height:${wantedContainerHeightRem_()}rem`, _$p));
|
|
531
539
|
return _el$4;
|
|
532
540
|
})();
|
|
533
541
|
})();
|
|
@@ -546,8 +554,11 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
546
554
|
},
|
|
547
555
|
get children () {
|
|
548
556
|
var _el$7 = $3375ddd88f77967d$var$_tmpl$8();
|
|
549
|
-
|
|
550
|
-
|
|
557
|
+
(0, $7jsgb$solidjsweb.use)((el)=>{
|
|
558
|
+
ref_?.(el);
|
|
559
|
+
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
560
|
+
(0, $7jsgb$solidjs.createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
561
|
+
}, _el$7);
|
|
551
562
|
(0, $7jsgb$solidjsweb.insert)(_el$7, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.For), {
|
|
552
563
|
get each () {
|
|
553
564
|
return $3375ddd88f77967d$var$sortSizes(keysToShow());
|
|
@@ -580,29 +591,23 @@ function $3375ddd88f77967d$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
580
591
|
return _el$8;
|
|
581
592
|
}
|
|
582
593
|
}), null);
|
|
583
|
-
(0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$7, `--font-size-rem:${fontSizeRem_()}rem`, _$p));
|
|
584
594
|
return _el$7;
|
|
585
595
|
}
|
|
586
596
|
});
|
|
587
597
|
}
|
|
588
|
-
function $3375ddd88f77967d$var$
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
},
|
|
600
|
-
...options.bg_color && {
|
|
601
|
-
"--background": options.bg_color
|
|
602
|
-
}
|
|
603
|
-
};
|
|
598
|
+
function $3375ddd88f77967d$var$setPropertyIfExists(style, property, value) {
|
|
599
|
+
if (value) style.setProperty(property, value);
|
|
600
|
+
else style.removeProperty(property);
|
|
601
|
+
}
|
|
602
|
+
function $3375ddd88f77967d$var$setStyleForTextOptions({ style: style }, options) {
|
|
603
|
+
// Doing this instead of just using style={} because AnimatedRowSwitch needs to be able to set inline styling without it being overridden
|
|
604
|
+
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--font-size-rem", options().font_size_rem + "rem"));
|
|
605
|
+
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--font-weight", options().bold && "bold"));
|
|
606
|
+
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--font-style", options().italic && "italic"));
|
|
607
|
+
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--color", options().color));
|
|
608
|
+
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--background", options().bg_color));
|
|
604
609
|
}
|
|
605
|
-
function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_ }) {
|
|
610
|
+
function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_ }) {
|
|
606
611
|
const isAlreadyInSlider = !!(0, $7jsgb$depictaiuilatest.useSlidableInformation)();
|
|
607
612
|
const containerClasses = ()=>[
|
|
608
613
|
"image-video",
|
|
@@ -613,38 +618,48 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
613
618
|
const hoverImageDisabled = (0, $7jsgb$solidjs.createMemo)(()=>!configuredOptions_().use_hover_image);
|
|
614
619
|
const video_urls = ()=>video_()?.video_urls;
|
|
615
620
|
const Container = (props)=>{
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
]))
|
|
629
|
-
}, previous));
|
|
630
|
-
// Scroll to beginning when changing what variant we're showing
|
|
631
|
-
(0, $7jsgb$solidjs.createEffect)((0, $7jsgb$solidjs.on)(image_urls_, ()=>insert_here.scrollTo({
|
|
632
|
-
left: 0,
|
|
633
|
-
behavior: "auto"
|
|
634
|
-
}), {
|
|
635
|
-
defer: true
|
|
636
|
-
}));
|
|
621
|
+
const resolved = (0, $7jsgb$solidjs.children)(()=>props.children);
|
|
622
|
+
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
623
|
+
get when () {
|
|
624
|
+
return slidable();
|
|
625
|
+
},
|
|
626
|
+
get fallback () {
|
|
627
|
+
return (()=>{
|
|
628
|
+
var _el$14 = $3375ddd88f77967d$var$_tmpl$11();
|
|
629
|
+
(0, $7jsgb$solidjsweb.insert)(_el$14, resolved);
|
|
630
|
+
(0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.className)(_el$14, containerClasses().join(" ")));
|
|
631
|
+
return _el$14;
|
|
632
|
+
})();
|
|
637
633
|
},
|
|
638
634
|
get children () {
|
|
639
|
-
return
|
|
635
|
+
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.SlidableItems), {
|
|
636
|
+
arrow_height_: 25,
|
|
637
|
+
arrow_width_: 12.5,
|
|
638
|
+
disable_fading_: true,
|
|
639
|
+
slider_ref_: (slider)=>{
|
|
640
|
+
const { container: container, insert_here: insert_here } = slider;
|
|
641
|
+
slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
|
|
642
|
+
(0, $7jsgb$solidjs.createRenderEffect)((previous)=>(0, $7jsgb$solidjsweb.classList)(container, {
|
|
643
|
+
products: true,
|
|
644
|
+
...Object.fromEntries(containerClasses().map((cls)=>[
|
|
645
|
+
cls,
|
|
646
|
+
true
|
|
647
|
+
]))
|
|
648
|
+
}, previous));
|
|
649
|
+
// Scroll to beginning when changing what variant we're showing
|
|
650
|
+
(0, $7jsgb$solidjs.createEffect)((0, $7jsgb$solidjs.on)(image_urls_, ()=>insert_here.scrollTo({
|
|
651
|
+
left: 0,
|
|
652
|
+
behavior: "auto"
|
|
653
|
+
}), {
|
|
654
|
+
defer: true
|
|
655
|
+
}));
|
|
656
|
+
},
|
|
657
|
+
get children () {
|
|
658
|
+
return resolved();
|
|
659
|
+
}
|
|
660
|
+
});
|
|
640
661
|
}
|
|
641
662
|
});
|
|
642
|
-
return (()=>{
|
|
643
|
-
var _el$14 = $3375ddd88f77967d$var$_tmpl$11();
|
|
644
|
-
(0, $7jsgb$solidjsweb.insert)(_el$14, ()=>props.children);
|
|
645
|
-
(0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.className)(_el$14, containerClasses().join(" ")));
|
|
646
|
-
return _el$14;
|
|
647
|
-
})();
|
|
648
663
|
};
|
|
649
664
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
650
665
|
get when () {
|
|
@@ -652,7 +667,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
652
667
|
},
|
|
653
668
|
get fallback () {
|
|
654
669
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ImagePlaceholder), {
|
|
655
|
-
aspectRatio
|
|
670
|
+
get aspectRatio () {
|
|
671
|
+
return aspectRatio_();
|
|
672
|
+
}
|
|
656
673
|
});
|
|
657
674
|
},
|
|
658
675
|
get children () {
|
|
@@ -666,7 +683,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
666
683
|
get children () {
|
|
667
684
|
var _el$15 = $3375ddd88f77967d$var$_tmpl$12();
|
|
668
685
|
(0, $7jsgb$solidjsweb.insert)(_el$15, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ImageContainer), {
|
|
669
|
-
aspectRatio
|
|
686
|
+
get aspectRatio () {
|
|
687
|
+
return aspectRatio_();
|
|
688
|
+
},
|
|
670
689
|
get children () {
|
|
671
690
|
return (0, $7jsgb$solidjsweb.createComponent)($3375ddd88f77967d$var$Video, {
|
|
672
691
|
get video_sources_ () {
|
|
@@ -698,7 +717,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
698
717
|
var _el$16 = $3375ddd88f77967d$var$_tmpl$13();
|
|
699
718
|
(0, $7jsgb$solidjsweb.insert)(_el$16, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ShopifyContainedImage), {
|
|
700
719
|
src: image_url,
|
|
701
|
-
aspectRatio
|
|
720
|
+
get aspectRatio () {
|
|
721
|
+
return aspectRatio_();
|
|
722
|
+
},
|
|
702
723
|
imgProps: {
|
|
703
724
|
alt: "Product image"
|
|
704
725
|
}
|
|
@@ -712,7 +733,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
712
733
|
get src () {
|
|
713
734
|
return image_urls_()[1];
|
|
714
735
|
},
|
|
715
|
-
aspectRatio
|
|
736
|
+
get aspectRatio () {
|
|
737
|
+
return aspectRatio_();
|
|
738
|
+
},
|
|
716
739
|
imgProps: {
|
|
717
740
|
alt: "Product image"
|
|
718
741
|
},
|
|
@@ -839,6 +862,7 @@ function $3375ddd88f77967d$var$Prices({ formatPrice_: formatPrice_, configuredOp
|
|
|
839
862
|
return [
|
|
840
863
|
(()=>{
|
|
841
864
|
var _el$20 = $3375ddd88f77967d$var$_tmpl$17();
|
|
865
|
+
(0, $7jsgb$solidjsweb.use)((el)=>$3375ddd88f77967d$var$setStyleForTextOptions(el, priceOptions), _el$20);
|
|
842
866
|
(0, $7jsgb$solidjsweb.insert)(_el$20, (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
843
867
|
get when () {
|
|
844
868
|
return variantToShow_();
|
|
@@ -863,7 +887,6 @@ function $3375ddd88f77967d$var$Prices({ formatPrice_: formatPrice_, configuredOp
|
|
|
863
887
|
});
|
|
864
888
|
}
|
|
865
889
|
}));
|
|
866
|
-
(0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$20, $3375ddd88f77967d$var$styleForTextOptions(priceOptions()), _$p));
|
|
867
890
|
return _el$20;
|
|
868
891
|
})(),
|
|
869
892
|
(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Suspense), {
|
|
@@ -877,8 +900,8 @@ function $3375ddd88f77967d$var$Prices({ formatPrice_: formatPrice_, configuredOp
|
|
|
877
900
|
" ",
|
|
878
901
|
(()=>{
|
|
879
902
|
var _el$21 = $3375ddd88f77967d$var$_tmpl$18();
|
|
903
|
+
(0, $7jsgb$solidjsweb.use)((el)=>$3375ddd88f77967d$var$setStyleForTextOptions(el, originalPriceOptions), _el$21);
|
|
880
904
|
(0, $7jsgb$solidjsweb.insert)(_el$21, ()=>formatPrice_?.(originalPrice_()));
|
|
881
|
-
(0, $7jsgb$solidjsweb.effect)((_$p)=>(0, $7jsgb$solidjsweb.style)(_el$21, $3375ddd88f77967d$var$styleForTextOptions(originalPriceOptions()), _$p));
|
|
882
905
|
return _el$21;
|
|
883
906
|
})()
|
|
884
907
|
];
|
|
@@ -950,21 +973,19 @@ function $3375ddd88f77967d$var$InComponentOrDiv(props) {
|
|
|
950
973
|
const resolved = (0, $7jsgb$solidjs.children)(()=>props.children);
|
|
951
974
|
return (0, $7jsgb$solidjs.createMemo)(()=>{
|
|
952
975
|
const Component = props.component_;
|
|
953
|
-
if (Component)
|
|
954
|
-
|
|
976
|
+
if (Component) // Written like this because the JSX transform mutates our props object: https://github.com/ryansolid/dom-expressions/pull/316#issuecomment-2066925544
|
|
977
|
+
return (0, $7jsgb$solidjsweb.createComponent)(Component, {
|
|
978
|
+
get class () {
|
|
955
979
|
return props.class_;
|
|
956
980
|
},
|
|
957
|
-
ref (
|
|
958
|
-
|
|
959
|
-
typeof _ref$4 === "function" ? _ref$4(r$) : props.ref_ = r$;
|
|
981
|
+
get ref () {
|
|
982
|
+
return props.ref_;
|
|
960
983
|
},
|
|
961
|
-
|
|
962
|
-
return resolved();
|
|
963
|
-
}
|
|
984
|
+
children: resolved
|
|
964
985
|
});
|
|
965
986
|
return (()=>{
|
|
966
987
|
var _el$22 = $3375ddd88f77967d$var$_tmpl$11();
|
|
967
|
-
(0, $7jsgb$solidjsweb.use)((el)=>props
|
|
988
|
+
(0, $7jsgb$solidjsweb.use)((el)=>props?.ref_?.(el), _el$22);
|
|
968
989
|
(0, $7jsgb$solidjsweb.insert)(_el$22, resolved);
|
|
969
990
|
(0, $7jsgb$solidjsweb.effect)(()=>(0, $7jsgb$solidjsweb.className)(_el$22, props.class_));
|
|
970
991
|
return _el$22;
|
|
@@ -986,7 +1007,8 @@ function $70cc6bd7e3f1dd4b$export$d1a48be4967fe67c(react_props) {
|
|
|
986
1007
|
formatPrice: (price)=>price && (0, $7jsgb$depictaiutilisharedlatest.standard_price_format)(price)
|
|
987
1008
|
}, ()=>props_store.options);
|
|
988
1009
|
},
|
|
989
|
-
|
|
1010
|
+
// Work around in case https://github.com/solidjs/solid/issues/2139 potentially arises
|
|
1011
|
+
props: structuredClone(react_props),
|
|
990
1012
|
className: "depict"
|
|
991
1013
|
});
|
|
992
1014
|
}
|
package/dist/module.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {add_to_version_info as $2MCgq$add_to_version_info, standard_price_format as $2MCgq$standard_price_format, catchify as $2MCgq$catchify, dlog as $2MCgq$dlog, dwarn as $2MCgq$dwarn} from "@depict-ai/utilishared/latest";
|
|
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,
|
|
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
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";
|
|
@@ -7,7 +7,7 @@ import {createContext as $2MCgq$createContext, createMemo as $2MCgq$createMemo,
|
|
|
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.7";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -57,7 +57,6 @@ const $29535f590238371c$var$sizeOrder = [
|
|
|
57
57
|
"One Size",
|
|
58
58
|
"Onesize"
|
|
59
59
|
];
|
|
60
|
-
const $29535f590238371c$var$imageAspectRatio = 1;
|
|
61
60
|
const $29535f590238371c$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $2MCgq$createContext)();
|
|
62
61
|
let $29535f590238371c$var$colorCanvasContext;
|
|
63
62
|
function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_ = ()=>({
|
|
@@ -95,7 +94,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
95
94
|
},
|
|
96
95
|
use_hover_image: true,
|
|
97
96
|
image_carousel: true,
|
|
98
|
-
color_options: true
|
|
97
|
+
color_options: true,
|
|
98
|
+
image_aspect_ratio: 1
|
|
99
99
|
})) {
|
|
100
100
|
const variantDisplays = (0, $2MCgq$createMemo)(()=>display()?.variant_displays);
|
|
101
101
|
const defaultVariantIndex = (0, $2MCgq$createMemo)(()=>display()?.variant_index);
|
|
@@ -103,6 +103,14 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
103
103
|
const [cardIsHovered, setCardIsHovered] = (0, $2MCgq$createSignal)(false);
|
|
104
104
|
const variantToShow = (0, $2MCgq$createMemo)(()=>variantDisplays()?.[showVariantIndex()]);
|
|
105
105
|
const noHoverSupport_ = (0, $2MCgq$media_query_to_accessor)("(hover: none)");
|
|
106
|
+
const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
|
|
107
|
+
const [originalPrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.original_price);
|
|
108
|
+
const onSale = (0, $2MCgq$createMemo)(()=>(0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
|
|
109
|
+
get children () {
|
|
110
|
+
return originalPrice() !== salePrice();
|
|
111
|
+
}
|
|
112
|
+
}));
|
|
113
|
+
const aspectRatio_ = (0, $2MCgq$createMemo)(()=>configuredOptions_().image_aspect_ratio);
|
|
106
114
|
const sizesInStock_ = (0, $2MCgq$createMemo)(()=>new Map(variantDisplays()?.map((d)=>[
|
|
107
115
|
d.size_name,
|
|
108
116
|
d.in_stock
|
|
@@ -117,13 +125,6 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
117
125
|
}
|
|
118
126
|
]).filter(([colorName])=>colorName) // in case color_name is null
|
|
119
127
|
));
|
|
120
|
-
const [salePrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.sale_price);
|
|
121
|
-
const [originalPrice] = (0, $2MCgq$createResource)(variantToShow, (v)=>v?.original_price);
|
|
122
|
-
const onSale = (0, $2MCgq$createMemo)(()=>(0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
|
|
123
|
-
get children () {
|
|
124
|
-
return originalPrice() !== salePrice();
|
|
125
|
-
}
|
|
126
|
-
}));
|
|
127
128
|
const swatchContainerHeight = (0, $2MCgq$createMemo)(()=>{
|
|
128
129
|
// To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
|
|
129
130
|
let considerSize = [];
|
|
@@ -157,8 +158,10 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
157
158
|
})();
|
|
158
159
|
const Title = (props)=>(()=>{
|
|
159
160
|
var _el$2 = $29535f590238371c$var$_tmpl$2();
|
|
160
|
-
|
|
161
|
-
|
|
161
|
+
(0, $2MCgq$use)((el)=>{
|
|
162
|
+
props.ref_?.(el);
|
|
163
|
+
$29535f590238371c$var$setStyleForTextOptions(el, titleOptions);
|
|
164
|
+
}, _el$2);
|
|
162
165
|
(0, $2MCgq$insert)(_el$2, ()=>variantToShow()?.title ?? [
|
|
163
166
|
(0, $2MCgq$createComponent)((0, $2MCgq$TextPlaceholder), {
|
|
164
167
|
height: "1em",
|
|
@@ -169,17 +172,19 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
169
172
|
width: "20ch"
|
|
170
173
|
})
|
|
171
174
|
]);
|
|
172
|
-
(0, $2MCgq$effect)((
|
|
173
|
-
var _v$3 = variantToShow()?.title, _v$4 = $29535f590238371c$var$styleForTextOptions(titleOptions());
|
|
174
|
-
_v$3 !== _p$.e && (0, $2MCgq$setAttribute)(_el$2, "title", _p$.e = _v$3);
|
|
175
|
-
_p$.t = (0, $2MCgq$style)(_el$2, _v$4, _p$.t);
|
|
176
|
-
return _p$;
|
|
177
|
-
}, {
|
|
178
|
-
e: undefined,
|
|
179
|
-
t: undefined
|
|
180
|
-
});
|
|
175
|
+
(0, $2MCgq$effect)(()=>(0, $2MCgq$setAttribute)(_el$2, "title", variantToShow()?.title));
|
|
181
176
|
return _el$2;
|
|
182
177
|
})();
|
|
178
|
+
const mainStyle = ()=>{
|
|
179
|
+
const { alignment: alignment } = configuredOptions_();
|
|
180
|
+
const flexAlignment = alignment === "center" ? alignment : "flex-" + alignment;
|
|
181
|
+
return {
|
|
182
|
+
"--flex-alignment": flexAlignment,
|
|
183
|
+
"--alignment": alignment
|
|
184
|
+
};
|
|
185
|
+
};
|
|
186
|
+
(0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
|
|
187
|
+
(0, $2MCgq$createEffect)(()=>(0, $2MCgq$dlog)("Got passed display", JSON.parse(JSON.stringify(display()))));
|
|
183
188
|
(0, $2MCgq$createEffect)(()=>noHoverSupport_() && setCardIsHovered(false));
|
|
184
189
|
return (0, $2MCgq$createComponent)($29535f590238371c$var$ContainsColorSwatchesProvider, {
|
|
185
190
|
get children () {
|
|
@@ -193,7 +198,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
193
198
|
image_urls_: ()=>variantToShow()?.image_urls,
|
|
194
199
|
video_: ()=>variantToShow()?.videos?.[0],
|
|
195
200
|
configuredOptions_: configuredOptions_,
|
|
196
|
-
cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered()
|
|
201
|
+
cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered(),
|
|
202
|
+
aspectRatio_: aspectRatio_
|
|
197
203
|
});
|
|
198
204
|
}
|
|
199
205
|
}), null);
|
|
@@ -344,7 +350,7 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
344
350
|
})();
|
|
345
351
|
}
|
|
346
352
|
}), null);
|
|
347
|
-
(0, $2MCgq$effect)(()=>
|
|
353
|
+
(0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$3, mainStyle(), _$p));
|
|
348
354
|
return _el$3;
|
|
349
355
|
}
|
|
350
356
|
});
|
|
@@ -465,8 +471,11 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
465
471
|
(0, $2MCgq$onCleanup)(()=>setContainsColorSwatches(false));
|
|
466
472
|
return (()=>{
|
|
467
473
|
var _el$4 = $29535f590238371c$var$_tmpl$5();
|
|
468
|
-
|
|
469
|
-
|
|
474
|
+
(0, $2MCgq$use)((el)=>{
|
|
475
|
+
ref_?.(el);
|
|
476
|
+
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
477
|
+
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(el.style, "--swatch-container-height", wantedContainerHeightRem_() && wantedContainerHeightRem_() + "rem"));
|
|
478
|
+
}, _el$4);
|
|
470
479
|
(0, $2MCgq$insert)(_el$4, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
|
|
471
480
|
get each () {
|
|
472
481
|
return entriesToShow();
|
|
@@ -492,11 +501,11 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
492
501
|
(0, $2MCgq$setAttribute)(_el$6, "href", pageUrl_);
|
|
493
502
|
(0, $2MCgq$setAttribute)(_el$6, "title", colorName);
|
|
494
503
|
(0, $2MCgq$effect)((_p$)=>{
|
|
495
|
-
var _v$
|
|
496
|
-
_p$.e = (0, $2MCgq$style)(_el$6, _v$
|
|
497
|
-
_v$
|
|
498
|
-
_v$
|
|
499
|
-
_v$
|
|
504
|
+
var _v$3 = `--background:${invalidColor() ? "white" : hexColor_}`, _v$4 = !!(colorsAtIndex_()?.[showVariantIndex_()] === colorName), _v$5 = !!thisColorIsDefaultColor(), _v$6 = !!($29535f590238371c$var$isLightColor(hexColor_) || invalidColor());
|
|
505
|
+
_p$.e = (0, $2MCgq$style)(_el$6, _v$3, _p$.e);
|
|
506
|
+
_v$4 !== _p$.t && _el$6.classList.toggle("selected", _p$.t = _v$4);
|
|
507
|
+
_v$5 !== _p$.a && _el$6.classList.toggle("first", _p$.a = _v$5);
|
|
508
|
+
_v$6 !== _p$.o && _el$6.classList.toggle("light-colored", _p$.o = _v$6);
|
|
500
509
|
return _p$;
|
|
501
510
|
}, {
|
|
502
511
|
e: undefined,
|
|
@@ -516,7 +525,6 @@ function $29535f590238371c$var$ColorSwatches({ colorMap_: colorMap_, setShowVari
|
|
|
516
525
|
return $29535f590238371c$var$_tmpl$4();
|
|
517
526
|
}
|
|
518
527
|
}), null);
|
|
519
|
-
(0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$4, isNaN(wantedContainerHeightRem_()) ? "" : `--swatch-container-height:${wantedContainerHeightRem_()}rem`, _$p));
|
|
520
528
|
return _el$4;
|
|
521
529
|
})();
|
|
522
530
|
})();
|
|
@@ -535,8 +543,11 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
535
543
|
},
|
|
536
544
|
get children () {
|
|
537
545
|
var _el$7 = $29535f590238371c$var$_tmpl$8();
|
|
538
|
-
|
|
539
|
-
|
|
546
|
+
(0, $2MCgq$use)((el)=>{
|
|
547
|
+
ref_?.(el);
|
|
548
|
+
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
549
|
+
(0, $2MCgq$createEffect)(()=>el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
550
|
+
}, _el$7);
|
|
540
551
|
(0, $2MCgq$insert)(_el$7, (0, $2MCgq$createComponent)((0, $2MCgq$For), {
|
|
541
552
|
get each () {
|
|
542
553
|
return $29535f590238371c$var$sortSizes(keysToShow());
|
|
@@ -569,29 +580,23 @@ function $29535f590238371c$var$Sizes({ sizesInStock_: sizesInStock_, ref_: ref_,
|
|
|
569
580
|
return _el$8;
|
|
570
581
|
}
|
|
571
582
|
}), null);
|
|
572
|
-
(0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$7, `--font-size-rem:${fontSizeRem_()}rem`, _$p));
|
|
573
583
|
return _el$7;
|
|
574
584
|
}
|
|
575
585
|
});
|
|
576
586
|
}
|
|
577
|
-
function $29535f590238371c$var$
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
},
|
|
589
|
-
...options.bg_color && {
|
|
590
|
-
"--background": options.bg_color
|
|
591
|
-
}
|
|
592
|
-
};
|
|
587
|
+
function $29535f590238371c$var$setPropertyIfExists(style, property, value) {
|
|
588
|
+
if (value) style.setProperty(property, value);
|
|
589
|
+
else style.removeProperty(property);
|
|
590
|
+
}
|
|
591
|
+
function $29535f590238371c$var$setStyleForTextOptions({ style: style }, options) {
|
|
592
|
+
// Doing this instead of just using style={} because AnimatedRowSwitch needs to be able to set inline styling without it being overridden
|
|
593
|
+
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--font-size-rem", options().font_size_rem + "rem"));
|
|
594
|
+
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--font-weight", options().bold && "bold"));
|
|
595
|
+
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--font-style", options().italic && "italic"));
|
|
596
|
+
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--color", options().color));
|
|
597
|
+
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--background", options().bg_color));
|
|
593
598
|
}
|
|
594
|
-
function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_ }) {
|
|
599
|
+
function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_ }) {
|
|
595
600
|
const isAlreadyInSlider = !!(0, $2MCgq$useSlidableInformation)();
|
|
596
601
|
const containerClasses = ()=>[
|
|
597
602
|
"image-video",
|
|
@@ -602,38 +607,48 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
602
607
|
const hoverImageDisabled = (0, $2MCgq$createMemo)(()=>!configuredOptions_().use_hover_image);
|
|
603
608
|
const video_urls = ()=>video_()?.video_urls;
|
|
604
609
|
const Container = (props)=>{
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
]))
|
|
618
|
-
}, previous));
|
|
619
|
-
// Scroll to beginning when changing what variant we're showing
|
|
620
|
-
(0, $2MCgq$createEffect)((0, $2MCgq$on)(image_urls_, ()=>insert_here.scrollTo({
|
|
621
|
-
left: 0,
|
|
622
|
-
behavior: "auto"
|
|
623
|
-
}), {
|
|
624
|
-
defer: true
|
|
625
|
-
}));
|
|
610
|
+
const resolved = (0, $2MCgq$children)(()=>props.children);
|
|
611
|
+
return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
612
|
+
get when () {
|
|
613
|
+
return slidable();
|
|
614
|
+
},
|
|
615
|
+
get fallback () {
|
|
616
|
+
return (()=>{
|
|
617
|
+
var _el$14 = $29535f590238371c$var$_tmpl$11();
|
|
618
|
+
(0, $2MCgq$insert)(_el$14, resolved);
|
|
619
|
+
(0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$14, containerClasses().join(" ")));
|
|
620
|
+
return _el$14;
|
|
621
|
+
})();
|
|
626
622
|
},
|
|
627
623
|
get children () {
|
|
628
|
-
return
|
|
624
|
+
return (0, $2MCgq$createComponent)((0, $2MCgq$SlidableItems), {
|
|
625
|
+
arrow_height_: 25,
|
|
626
|
+
arrow_width_: 12.5,
|
|
627
|
+
disable_fading_: true,
|
|
628
|
+
slider_ref_: (slider)=>{
|
|
629
|
+
const { container: container, insert_here: insert_here } = slider;
|
|
630
|
+
slider.stepstoslide = 1; // In case anyone enables the hidden buttons using css
|
|
631
|
+
(0, $2MCgq$createRenderEffect)((previous)=>(0, $2MCgq$classList)(container, {
|
|
632
|
+
products: true,
|
|
633
|
+
...Object.fromEntries(containerClasses().map((cls)=>[
|
|
634
|
+
cls,
|
|
635
|
+
true
|
|
636
|
+
]))
|
|
637
|
+
}, previous));
|
|
638
|
+
// Scroll to beginning when changing what variant we're showing
|
|
639
|
+
(0, $2MCgq$createEffect)((0, $2MCgq$on)(image_urls_, ()=>insert_here.scrollTo({
|
|
640
|
+
left: 0,
|
|
641
|
+
behavior: "auto"
|
|
642
|
+
}), {
|
|
643
|
+
defer: true
|
|
644
|
+
}));
|
|
645
|
+
},
|
|
646
|
+
get children () {
|
|
647
|
+
return resolved();
|
|
648
|
+
}
|
|
649
|
+
});
|
|
629
650
|
}
|
|
630
651
|
});
|
|
631
|
-
return (()=>{
|
|
632
|
-
var _el$14 = $29535f590238371c$var$_tmpl$11();
|
|
633
|
-
(0, $2MCgq$insert)(_el$14, ()=>props.children);
|
|
634
|
-
(0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$14, containerClasses().join(" ")));
|
|
635
|
-
return _el$14;
|
|
636
|
-
})();
|
|
637
652
|
};
|
|
638
653
|
return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
639
654
|
get when () {
|
|
@@ -641,7 +656,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
641
656
|
},
|
|
642
657
|
get fallback () {
|
|
643
658
|
return (0, $2MCgq$createComponent)((0, $2MCgq$ImagePlaceholder), {
|
|
644
|
-
aspectRatio
|
|
659
|
+
get aspectRatio () {
|
|
660
|
+
return aspectRatio_();
|
|
661
|
+
}
|
|
645
662
|
});
|
|
646
663
|
},
|
|
647
664
|
get children () {
|
|
@@ -655,7 +672,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
655
672
|
get children () {
|
|
656
673
|
var _el$15 = $29535f590238371c$var$_tmpl$12();
|
|
657
674
|
(0, $2MCgq$insert)(_el$15, (0, $2MCgq$createComponent)((0, $2MCgq$ImageContainer), {
|
|
658
|
-
aspectRatio
|
|
675
|
+
get aspectRatio () {
|
|
676
|
+
return aspectRatio_();
|
|
677
|
+
},
|
|
659
678
|
get children () {
|
|
660
679
|
return (0, $2MCgq$createComponent)($29535f590238371c$var$Video, {
|
|
661
680
|
get video_sources_ () {
|
|
@@ -687,7 +706,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
687
706
|
var _el$16 = $29535f590238371c$var$_tmpl$13();
|
|
688
707
|
(0, $2MCgq$insert)(_el$16, (0, $2MCgq$createComponent)((0, $2MCgq$ShopifyContainedImage), {
|
|
689
708
|
src: image_url,
|
|
690
|
-
aspectRatio
|
|
709
|
+
get aspectRatio () {
|
|
710
|
+
return aspectRatio_();
|
|
711
|
+
},
|
|
691
712
|
imgProps: {
|
|
692
713
|
alt: "Product image"
|
|
693
714
|
}
|
|
@@ -701,7 +722,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
701
722
|
get src () {
|
|
702
723
|
return image_urls_()[1];
|
|
703
724
|
},
|
|
704
|
-
aspectRatio
|
|
725
|
+
get aspectRatio () {
|
|
726
|
+
return aspectRatio_();
|
|
727
|
+
},
|
|
705
728
|
imgProps: {
|
|
706
729
|
alt: "Product image"
|
|
707
730
|
},
|
|
@@ -828,6 +851,7 @@ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOp
|
|
|
828
851
|
return [
|
|
829
852
|
(()=>{
|
|
830
853
|
var _el$20 = $29535f590238371c$var$_tmpl$17();
|
|
854
|
+
(0, $2MCgq$use)((el)=>$29535f590238371c$var$setStyleForTextOptions(el, priceOptions), _el$20);
|
|
831
855
|
(0, $2MCgq$insert)(_el$20, (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
832
856
|
get when () {
|
|
833
857
|
return variantToShow_();
|
|
@@ -852,7 +876,6 @@ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOp
|
|
|
852
876
|
});
|
|
853
877
|
}
|
|
854
878
|
}));
|
|
855
|
-
(0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$20, $29535f590238371c$var$styleForTextOptions(priceOptions()), _$p));
|
|
856
879
|
return _el$20;
|
|
857
880
|
})(),
|
|
858
881
|
(0, $2MCgq$createComponent)((0, $2MCgq$Suspense), {
|
|
@@ -866,8 +889,8 @@ function $29535f590238371c$var$Prices({ formatPrice_: formatPrice_, configuredOp
|
|
|
866
889
|
" ",
|
|
867
890
|
(()=>{
|
|
868
891
|
var _el$21 = $29535f590238371c$var$_tmpl$18();
|
|
892
|
+
(0, $2MCgq$use)((el)=>$29535f590238371c$var$setStyleForTextOptions(el, originalPriceOptions), _el$21);
|
|
869
893
|
(0, $2MCgq$insert)(_el$21, ()=>formatPrice_?.(originalPrice_()));
|
|
870
|
-
(0, $2MCgq$effect)((_$p)=>(0, $2MCgq$style)(_el$21, $29535f590238371c$var$styleForTextOptions(originalPriceOptions()), _$p));
|
|
871
894
|
return _el$21;
|
|
872
895
|
})()
|
|
873
896
|
];
|
|
@@ -939,21 +962,19 @@ function $29535f590238371c$var$InComponentOrDiv(props) {
|
|
|
939
962
|
const resolved = (0, $2MCgq$children)(()=>props.children);
|
|
940
963
|
return (0, $2MCgq$createMemo)(()=>{
|
|
941
964
|
const Component = props.component_;
|
|
942
|
-
if (Component)
|
|
943
|
-
|
|
965
|
+
if (Component) // Written like this because the JSX transform mutates our props object: https://github.com/ryansolid/dom-expressions/pull/316#issuecomment-2066925544
|
|
966
|
+
return (0, $2MCgq$createComponent)(Component, {
|
|
967
|
+
get class () {
|
|
944
968
|
return props.class_;
|
|
945
969
|
},
|
|
946
|
-
ref (
|
|
947
|
-
|
|
948
|
-
typeof _ref$4 === "function" ? _ref$4(r$) : props.ref_ = r$;
|
|
970
|
+
get ref () {
|
|
971
|
+
return props.ref_;
|
|
949
972
|
},
|
|
950
|
-
|
|
951
|
-
return resolved();
|
|
952
|
-
}
|
|
973
|
+
children: resolved
|
|
953
974
|
});
|
|
954
975
|
return (()=>{
|
|
955
976
|
var _el$22 = $29535f590238371c$var$_tmpl$11();
|
|
956
|
-
(0, $2MCgq$use)((el)=>props
|
|
977
|
+
(0, $2MCgq$use)((el)=>props?.ref_?.(el), _el$22);
|
|
957
978
|
(0, $2MCgq$insert)(_el$22, resolved);
|
|
958
979
|
(0, $2MCgq$effect)(()=>(0, $2MCgq$className)(_el$22, props.class_));
|
|
959
980
|
return _el$22;
|
|
@@ -975,7 +996,8 @@ function $474e9d712b745d60$export$d1a48be4967fe67c(react_props) {
|
|
|
975
996
|
formatPrice: (price)=>price && (0, $2MCgq$standard_price_format)(price)
|
|
976
997
|
}, ()=>props_store.options);
|
|
977
998
|
},
|
|
978
|
-
|
|
999
|
+
// Work around in case https://github.com/solidjs/solid/issues/2139 potentially arises
|
|
1000
|
+
props: structuredClone(react_props),
|
|
979
1001
|
className: "depict"
|
|
980
1002
|
});
|
|
981
1003
|
}
|
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.7",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -92,7 +92,7 @@
|
|
|
92
92
|
"@types/node": "^18.11.11",
|
|
93
93
|
"@types/react": "^18.0.26",
|
|
94
94
|
"@types/react-dom": "^18.0.10",
|
|
95
|
-
"babel-preset-solid": "^1.8.
|
|
95
|
+
"babel-preset-solid": "^1.8.16",
|
|
96
96
|
"react": "^18.2.0",
|
|
97
97
|
"react-dom": "^18.2.0",
|
|
98
98
|
"ts-jest": "^29.0.5"
|
|
@@ -100,12 +100,12 @@
|
|
|
100
100
|
"dependencies": {
|
|
101
101
|
"@babel/runtime": "latest",
|
|
102
102
|
"@babel/runtime-corejs3": "^7.22.6",
|
|
103
|
-
"@depict-ai/plp-styling": "^4.4.
|
|
104
|
-
"@depict-ai/react-ui": "^4.8.
|
|
105
|
-
"@depict-ai/types": "^5.4.
|
|
106
|
-
"@depict-ai/ui": "^4.8.
|
|
107
|
-
"@depict-ai/utilishared": "^2.4.
|
|
103
|
+
"@depict-ai/plp-styling": "^4.4.13",
|
|
104
|
+
"@depict-ai/react-ui": "^4.8.6",
|
|
105
|
+
"@depict-ai/types": "^5.4.4",
|
|
106
|
+
"@depict-ai/ui": "^4.8.15",
|
|
107
|
+
"@depict-ai/utilishared": "^2.4.5",
|
|
108
108
|
"parcel": "^2.10.3",
|
|
109
|
-
"solid-js": "^1.8.
|
|
109
|
+
"solid-js": "^1.8.16"
|
|
110
110
|
}
|
|
111
111
|
}
|
|
@@ -1,40 +1,40 @@
|
|
|
1
1
|
import {
|
|
2
|
+
ImageContainer,
|
|
2
3
|
ImagePlaceholder,
|
|
4
|
+
media_query_to_accessor,
|
|
3
5
|
ModernDisplayWithPageUrl,
|
|
4
6
|
SDKRenderingInfo,
|
|
5
7
|
ShopifyContainedImage,
|
|
8
|
+
SlidableItems,
|
|
6
9
|
TextPlaceholder,
|
|
7
10
|
useProductCardIndex,
|
|
8
11
|
useProductCardIsVisible,
|
|
9
|
-
SlidableItems,
|
|
10
|
-
ImageContainer,
|
|
11
|
-
media_query_to_accessor,
|
|
12
12
|
useSlidableInformation,
|
|
13
13
|
useVisibilityState,
|
|
14
14
|
} from "@depict-ai/ui/latest";
|
|
15
|
-
import {
|
|
15
|
+
import { catchify, dlog, dwarn } from "@depict-ai/utilishared/latest";
|
|
16
16
|
import {
|
|
17
|
+
type Accessor,
|
|
18
|
+
children,
|
|
19
|
+
createContext,
|
|
20
|
+
createEffect,
|
|
21
|
+
createMemo,
|
|
22
|
+
createRenderEffect,
|
|
23
|
+
createResource,
|
|
24
|
+
createSignal,
|
|
25
|
+
For,
|
|
17
26
|
type JSX,
|
|
27
|
+
on,
|
|
28
|
+
onCleanup,
|
|
18
29
|
type Resource,
|
|
19
|
-
type
|
|
20
|
-
createResource,
|
|
30
|
+
type Setter,
|
|
21
31
|
Show,
|
|
32
|
+
type Signal,
|
|
22
33
|
Suspense,
|
|
23
|
-
For,
|
|
24
|
-
createEffect,
|
|
25
|
-
createSignal,
|
|
26
|
-
createMemo,
|
|
27
|
-
type Setter,
|
|
28
|
-
type Accessor,
|
|
29
34
|
untrack,
|
|
30
|
-
on,
|
|
31
|
-
children,
|
|
32
|
-
createRenderEffect,
|
|
33
|
-
onCleanup,
|
|
34
35
|
useContext,
|
|
35
|
-
createContext,
|
|
36
36
|
} from "solid-js";
|
|
37
|
-
import { classList } from "solid-js/web";
|
|
37
|
+
import { classList, createComponent } from "solid-js/web";
|
|
38
38
|
// You can import from the solid-js library here and leverage its reactivity to create an interactive UI.
|
|
39
39
|
// Also, Depict packages can be imported (you must import /latest from those).
|
|
40
40
|
|
|
@@ -76,6 +76,7 @@ export type ProductCardSchema = {
|
|
|
76
76
|
use_hover_image: boolean;
|
|
77
77
|
/** Image Carousel */
|
|
78
78
|
image_carousel: boolean;
|
|
79
|
+
image_aspect_ratio: number;
|
|
79
80
|
};
|
|
80
81
|
|
|
81
82
|
const sizeOrder = [
|
|
@@ -94,7 +95,6 @@ const sizeOrder = [
|
|
|
94
95
|
"One Size",
|
|
95
96
|
"Onesize",
|
|
96
97
|
];
|
|
97
|
-
const imageAspectRatio = 1;
|
|
98
98
|
const ContainsColorSwatchesContext = /*@__PURE__*/ createContext<Signal<boolean>>();
|
|
99
99
|
let colorCanvasContext: CanvasRenderingContext2D | undefined | null;
|
|
100
100
|
|
|
@@ -148,6 +148,7 @@ export function DefaultSolidProductCard(
|
|
|
148
148
|
use_hover_image: true,
|
|
149
149
|
image_carousel: true,
|
|
150
150
|
color_options: true,
|
|
151
|
+
image_aspect_ratio: 1,
|
|
151
152
|
})
|
|
152
153
|
) {
|
|
153
154
|
const variantDisplays = createMemo(() => display()?.variant_displays);
|
|
@@ -156,6 +157,10 @@ export function DefaultSolidProductCard(
|
|
|
156
157
|
const [cardIsHovered, setCardIsHovered] = createSignal(false);
|
|
157
158
|
const variantToShow = createMemo(() => variantDisplays()?.[showVariantIndex() as number]);
|
|
158
159
|
const noHoverSupport_ = media_query_to_accessor("(hover: none)");
|
|
160
|
+
const [salePrice] = createResource(variantToShow, v => v?.sale_price);
|
|
161
|
+
const [originalPrice] = createResource(variantToShow, v => v?.original_price);
|
|
162
|
+
const onSale = createMemo(() => <Suspense>{originalPrice() !== salePrice()}</Suspense>);
|
|
163
|
+
const aspectRatio_ = createMemo(() => configuredOptions_().image_aspect_ratio);
|
|
159
164
|
const sizesInStock_ = createMemo(
|
|
160
165
|
() =>
|
|
161
166
|
new Map(
|
|
@@ -183,10 +188,6 @@ export function DefaultSolidProductCard(
|
|
|
183
188
|
.filter(([colorName]) => colorName) // in case color_name is null
|
|
184
189
|
)
|
|
185
190
|
);
|
|
186
|
-
const [salePrice] = createResource(variantToShow, v => v?.sale_price);
|
|
187
|
-
const [originalPrice] = createResource(variantToShow, v => v?.original_price);
|
|
188
|
-
const onSale = createMemo(() => <Suspense>{originalPrice() !== salePrice()}</Suspense>);
|
|
189
|
-
|
|
190
191
|
const swatchContainerHeight = createMemo(() => {
|
|
191
192
|
// To avoid the product cards switching around as one hovers and price switches to the swatches, we have to make the swatches container have the same height as the price one
|
|
192
193
|
let considerSize: number[] = [];
|
|
@@ -224,8 +225,10 @@ export function DefaultSolidProductCard(
|
|
|
224
225
|
<div
|
|
225
226
|
class="d-title line-clamp"
|
|
226
227
|
title={variantToShow()?.title}
|
|
227
|
-
|
|
228
|
-
|
|
228
|
+
ref={el => {
|
|
229
|
+
props.ref_?.(el);
|
|
230
|
+
setStyleForTextOptions(el, titleOptions);
|
|
231
|
+
}}
|
|
229
232
|
>
|
|
230
233
|
{variantToShow()?.title ?? (
|
|
231
234
|
<>
|
|
@@ -235,6 +238,14 @@ export function DefaultSolidProductCard(
|
|
|
235
238
|
)}
|
|
236
239
|
</div>
|
|
237
240
|
);
|
|
241
|
+
const mainStyle = () => {
|
|
242
|
+
const { alignment } = configuredOptions_();
|
|
243
|
+
const flexAlignment = alignment === "center" ? alignment : "flex-" + alignment;
|
|
244
|
+
return { "--flex-alignment": flexAlignment, "--alignment": alignment };
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
createEffect(() => dlog("Got passed options", JSON.parse(JSON.stringify(configuredOptions_()))));
|
|
248
|
+
createEffect(() => dlog("Got passed display", JSON.parse(JSON.stringify(display()))));
|
|
238
249
|
|
|
239
250
|
createEffect(() => noHoverSupport_() && setCardIsHovered(false));
|
|
240
251
|
|
|
@@ -242,7 +253,7 @@ export function DefaultSolidProductCard(
|
|
|
242
253
|
<ContainsColorSwatchesProvider>
|
|
243
254
|
<div
|
|
244
255
|
class={`d-product-card`}
|
|
245
|
-
style={
|
|
256
|
+
style={mainStyle()}
|
|
246
257
|
onMouseEnter={catchify(() => !noHoverSupport_() && setCardIsHovered(true))}
|
|
247
258
|
onMouseLeave={catchify(() => !noHoverSupport_() && setCardIsHovered(false))}
|
|
248
259
|
>
|
|
@@ -252,6 +263,7 @@ export function DefaultSolidProductCard(
|
|
|
252
263
|
video_={() => variantToShow()?.videos?.[0]}
|
|
253
264
|
configuredOptions_={configuredOptions_}
|
|
254
265
|
cardIsHovered_={() => showVariantIndex() === display()?.variant_index && cardIsHovered()}
|
|
266
|
+
aspectRatio_={aspectRatio_}
|
|
255
267
|
/>
|
|
256
268
|
</LinkWrapped>
|
|
257
269
|
<Show
|
|
@@ -507,12 +519,17 @@ function ColorSwatches({
|
|
|
507
519
|
return (
|
|
508
520
|
<div
|
|
509
521
|
class="d-swatches"
|
|
510
|
-
ref={
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
522
|
+
ref={el => {
|
|
523
|
+
ref_?.(el);
|
|
524
|
+
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
525
|
+
createEffect(() =>
|
|
526
|
+
setPropertyIfExists(
|
|
527
|
+
el.style,
|
|
528
|
+
"--swatch-container-height",
|
|
529
|
+
wantedContainerHeightRem_() && wantedContainerHeightRem_() + "rem"
|
|
530
|
+
)
|
|
531
|
+
);
|
|
532
|
+
}}
|
|
516
533
|
>
|
|
517
534
|
<For each={entriesToShow()}>
|
|
518
535
|
{([colorName, { pageUrl_, hexColor_, variantIndex_ }]) => {
|
|
@@ -549,7 +566,7 @@ function ColorSwatches({
|
|
|
549
566
|
// Value first take canvas color because it's more likely to exist for for example Aubergine
|
|
550
567
|
style={`--background:${invalidColor() ? "white" : hexColor_}`}
|
|
551
568
|
classList={{
|
|
552
|
-
selected: colorsAtIndex_?.[showVariantIndex_()!] === colorName,
|
|
569
|
+
selected: colorsAtIndex_()?.[showVariantIndex_()!] === colorName,
|
|
553
570
|
first: thisColorIsDefaultColor(),
|
|
554
571
|
"light-colored": isLightColor(hexColor_) || invalidColor(),
|
|
555
572
|
}}
|
|
@@ -584,7 +601,14 @@ function Sizes({
|
|
|
584
601
|
|
|
585
602
|
return (
|
|
586
603
|
<Show when={keysToShow().length > 1}>
|
|
587
|
-
<div
|
|
604
|
+
<div
|
|
605
|
+
class="sizes"
|
|
606
|
+
ref={el => {
|
|
607
|
+
ref_?.(el);
|
|
608
|
+
// Do like this so we don't override other styles set by AnimateRowSwitch
|
|
609
|
+
createEffect(() => el.style.setProperty("--font-size-rem", fontSizeRem_() + "rem"));
|
|
610
|
+
}}
|
|
611
|
+
>
|
|
588
612
|
<For each={sortSizes(keysToShow())}>
|
|
589
613
|
{size => (
|
|
590
614
|
<Show when={sizesInStock_().get(size)} fallback={<s>{size}</s>}>
|
|
@@ -600,14 +624,21 @@ function Sizes({
|
|
|
600
624
|
);
|
|
601
625
|
}
|
|
602
626
|
|
|
603
|
-
function
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
627
|
+
function setPropertyIfExists(style: CSSStyleDeclaration, property: string, value?: string | false | 0) {
|
|
628
|
+
if (value) {
|
|
629
|
+
style.setProperty(property, value);
|
|
630
|
+
} else {
|
|
631
|
+
style.removeProperty(property);
|
|
632
|
+
}
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
function setStyleForTextOptions({ style }: HTMLElement, options: Accessor<TextOptions>) {
|
|
636
|
+
// Doing this instead of just using style={} because AnimatedRowSwitch needs to be able to set inline styling without it being overridden
|
|
637
|
+
createEffect(() => setPropertyIfExists(style, "--font-size-rem", options().font_size_rem + "rem"));
|
|
638
|
+
createEffect(() => setPropertyIfExists(style, "--font-weight", options().bold && "bold"));
|
|
639
|
+
createEffect(() => setPropertyIfExists(style, "--font-style", options().italic && "italic"));
|
|
640
|
+
createEffect(() => setPropertyIfExists(style, "--color", options().color));
|
|
641
|
+
createEffect(() => setPropertyIfExists(style, "--background", options().bg_color));
|
|
611
642
|
}
|
|
612
643
|
|
|
613
644
|
function ImagesAndVideos({
|
|
@@ -615,11 +646,13 @@ function ImagesAndVideos({
|
|
|
615
646
|
video_,
|
|
616
647
|
configuredOptions_,
|
|
617
648
|
cardIsHovered_,
|
|
649
|
+
aspectRatio_,
|
|
618
650
|
}: {
|
|
619
651
|
image_urls_: Accessor<undefined | string[]>;
|
|
620
652
|
video_: Accessor<undefined | { preview_image_url: string; video_urls: string[] }>;
|
|
621
653
|
configuredOptions_: Accessor<ProductCardSchema>;
|
|
622
654
|
cardIsHovered_: Accessor<boolean>;
|
|
655
|
+
aspectRatio_: Accessor<number>;
|
|
623
656
|
}) {
|
|
624
657
|
const isAlreadyInSlider = !!useSlidableInformation();
|
|
625
658
|
const containerClasses = () => ["image-video", "border-radius-" + configuredOptions_().image_radius] as const;
|
|
@@ -627,9 +660,11 @@ function ImagesAndVideos({
|
|
|
627
660
|
const slidable = createMemo(() => !isAlreadyInSlider && configuredOptions_().image_carousel);
|
|
628
661
|
const hoverImageDisabled = createMemo(() => !configuredOptions_().use_hover_image);
|
|
629
662
|
const video_urls = () => video_()?.video_urls;
|
|
663
|
+
|
|
630
664
|
const Container = (props: { children: JSX.Element }) => {
|
|
631
|
-
|
|
632
|
-
|
|
665
|
+
const resolved = children(() => props.children);
|
|
666
|
+
return (
|
|
667
|
+
<Show when={slidable()} fallback={<div class={containerClasses().join(" ")}>{resolved()}</div>}>
|
|
633
668
|
<SlidableItems
|
|
634
669
|
arrow_height_={25}
|
|
635
670
|
arrow_width_={12.5}
|
|
@@ -650,19 +685,18 @@ function ImagesAndVideos({
|
|
|
650
685
|
createEffect(on(image_urls_, () => insert_here.scrollTo({ left: 0, behavior: "auto" }), { defer: true }));
|
|
651
686
|
}}
|
|
652
687
|
>
|
|
653
|
-
{
|
|
688
|
+
{resolved()}
|
|
654
689
|
</SlidableItems>
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
return <div class={containerClasses().join(" ")}>{props.children}</div>;
|
|
690
|
+
</Show>
|
|
691
|
+
);
|
|
658
692
|
};
|
|
659
693
|
|
|
660
694
|
return (
|
|
661
|
-
<Show when={image_urls_()} fallback={<ImagePlaceholder aspectRatio={
|
|
695
|
+
<Show when={image_urls_()} fallback={<ImagePlaceholder aspectRatio={aspectRatio_()} />}>
|
|
662
696
|
<Container>
|
|
663
697
|
<Show when={video_urls()?.length}>
|
|
664
698
|
<div class="media-item video">
|
|
665
|
-
<ImageContainer aspectRatio={
|
|
699
|
+
<ImageContainer aspectRatio={aspectRatio_()}>
|
|
666
700
|
<Video
|
|
667
701
|
video_sources_={video_urls() as [string, ...string[]]}
|
|
668
702
|
poster_={video_()?.preview_image_url || image_urls_()?.[0]}
|
|
@@ -680,13 +714,13 @@ function ImagesAndVideos({
|
|
|
680
714
|
{/* Hover to see JSDOc for ShopifyContainedImage */}
|
|
681
715
|
<ShopifyContainedImage
|
|
682
716
|
src={image_url}
|
|
683
|
-
aspectRatio={
|
|
717
|
+
aspectRatio={aspectRatio_()}
|
|
684
718
|
imgProps={{ alt: "Product image" }}
|
|
685
719
|
/>
|
|
686
720
|
<Show when={!index() && image_urls_()?.[1] && !hoverImageDisabled()}>
|
|
687
721
|
<ShopifyContainedImage
|
|
688
722
|
src={image_urls_()![1]}
|
|
689
|
-
aspectRatio={
|
|
723
|
+
aspectRatio={aspectRatio_()}
|
|
690
724
|
imgProps={{ alt: "Product image" }}
|
|
691
725
|
class={`hover${cardIsHovered_() ? " visible" : ""}`}
|
|
692
726
|
/>
|
|
@@ -806,7 +840,7 @@ function Prices({
|
|
|
806
840
|
return (
|
|
807
841
|
<Show when={priceOptions().enabled}>
|
|
808
842
|
<InComponentOrDiv component_={wrapperComponent_()} class_="price-container" ref_={ref_}>
|
|
809
|
-
<span class="price"
|
|
843
|
+
<span class="price" ref={el => setStyleForTextOptions(el, priceOptions)}>
|
|
810
844
|
<Show
|
|
811
845
|
when={variantToShow_()}
|
|
812
846
|
fallback={
|
|
@@ -825,7 +859,7 @@ function Prices({
|
|
|
825
859
|
{/* Only show original price if it exists and deviates from the salePrice */}
|
|
826
860
|
<Show when={originalPrice_() !== salePrice_() && originalPriceOptions().enabled}>
|
|
827
861
|
{" "}
|
|
828
|
-
<span class="original-price"
|
|
862
|
+
<span class="original-price" ref={el => setStyleForTextOptions(el, originalPriceOptions)}>
|
|
829
863
|
{formatPrice_?.(originalPrice_())}
|
|
830
864
|
</span>
|
|
831
865
|
</Show>
|
|
@@ -919,14 +953,19 @@ function InComponentOrDiv(props: {
|
|
|
919
953
|
return createMemo(() => {
|
|
920
954
|
const Component = props.component_;
|
|
921
955
|
if (Component) {
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
956
|
+
// Written like this because the JSX transform mutates our props object: https://github.com/ryansolid/dom-expressions/pull/316#issuecomment-2066925544
|
|
957
|
+
return createComponent(Component, {
|
|
958
|
+
get class() {
|
|
959
|
+
return props.class_;
|
|
960
|
+
},
|
|
961
|
+
get ref() {
|
|
962
|
+
return props.ref_;
|
|
963
|
+
},
|
|
964
|
+
children: resolved as unknown as JSX.Element,
|
|
965
|
+
});
|
|
927
966
|
}
|
|
928
967
|
return (
|
|
929
|
-
<div class={props.class_} ref={el => props
|
|
968
|
+
<div class={props.class_} ref={el => props?.ref_?.(el)}>
|
|
930
969
|
{resolved()}
|
|
931
970
|
</div>
|
|
932
971
|
);
|