@depict-ai/portal-components 2.7.30 → 2.7.32
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 +20 -22
- package/dist/module.js +20 -22
- package/package.json +2 -2
- package/src/specialForShopify/DefaultSolidProductCard.tsx +14 -9
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { SearchFilter } from "@depict-ai/types/api/SearchResponse";
|
|
|
4
4
|
import { Locale } from "@depict-ai/react-ui/locales/latest";
|
|
5
5
|
import { ReactNode } from "react";
|
|
6
6
|
import { FeaturedInDisplay } from "@depict-ai/types/api/FeaturedInResponseV3";
|
|
7
|
-
export const version = "2.7.
|
|
7
|
+
export const version = "2.7.32";
|
|
8
8
|
type TextOptions = {
|
|
9
9
|
/** Enabled */
|
|
10
10
|
enabled: boolean;
|
package/dist/main.js
CHANGED
|
@@ -20,7 +20,7 @@ $parcel$export(module.exports, "ExpandingSection", () => $2214dc111b9e2866$expor
|
|
|
20
20
|
$parcel$export(module.exports, "ReactLookCard", () => $35bab9ff48bfe404$export$48787da2a5568bc);
|
|
21
21
|
$parcel$export(module.exports, "version", () => $0a017be3a74fcc94$export$83d89fbfd8236492);
|
|
22
22
|
/*! Depict.ai portal components */ // This is where the actual source of your React stuff should live
|
|
23
|
-
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.
|
|
23
|
+
const $0a017be3a74fcc94$export$83d89fbfd8236492 = "2.7.32";
|
|
24
24
|
|
|
25
25
|
|
|
26
26
|
|
|
@@ -95,7 +95,8 @@ const $3375ddd88f77967d$var$sizeOrder = [
|
|
|
95
95
|
];
|
|
96
96
|
const $3375ddd88f77967d$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $7jsgb$solidjs.createContext)();
|
|
97
97
|
let $3375ddd88f77967d$var$colorCanvasContext;
|
|
98
|
-
function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOptions_,
|
|
98
|
+
function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOptions_, // forceIsVisible_ used in Depict portal where we don't have a provider with an IntersectionObserver
|
|
99
|
+
overrideAspectRatio) {
|
|
99
100
|
const variantDisplays = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_displays);
|
|
100
101
|
const defaultVariantIndex = (0, $7jsgb$solidjs.createMemo)(()=>display()?.variant_index);
|
|
101
102
|
const [showVariantIndex, setShowVariantIndex] = (0, $7jsgb$solidjs.createSignal)((0, $7jsgb$solidjs.untrack)(defaultVariantIndex));
|
|
@@ -214,7 +215,8 @@ function $3375ddd88f77967d$export$f11681c54c860912(display, info, configuredOpti
|
|
|
214
215
|
configuredOptions_: configuredOptions_,
|
|
215
216
|
cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered(),
|
|
216
217
|
aspectRatio_: aspectRatio_,
|
|
217
|
-
noHoverSupport_: noHoverSupport_
|
|
218
|
+
noHoverSupport_: noHoverSupport_,
|
|
219
|
+
forceIsVisible_: ()=>configuredOptions_().forceIsVisible_
|
|
218
220
|
});
|
|
219
221
|
}
|
|
220
222
|
}), null);
|
|
@@ -629,14 +631,14 @@ function $3375ddd88f77967d$var$setStyleForTextOptions({ style: style }, options)
|
|
|
629
631
|
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--color", options().color));
|
|
630
632
|
(0, $7jsgb$solidjs.createEffect)(()=>$3375ddd88f77967d$var$setPropertyIfExists(style, "--background", options().bg_color));
|
|
631
633
|
}
|
|
632
|
-
function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_, noHoverSupport_: noHoverSupport_ }) {
|
|
634
|
+
function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_, noHoverSupport_: noHoverSupport_, forceIsVisible_: forceIsVisible_ }) {
|
|
633
635
|
const PLPLayout = (0, $7jsgb$depictaiuilatest.usePLPLayout)();
|
|
634
636
|
const containerClasses = ()=>[
|
|
635
637
|
"image-video",
|
|
636
638
|
"border-radius-" + configuredOptions_().image_radius
|
|
637
639
|
];
|
|
638
640
|
const productCardIsVisible = (0, $7jsgb$depictaiuilatest.useProductCardIsVisible)();
|
|
639
|
-
const hasBeenVisible = (0, $7jsgb$solidjs.createMemo)((prev)=>prev || productCardIsVisible());
|
|
641
|
+
const hasBeenVisible = (0, $7jsgb$solidjs.createMemo)((prev)=>prev || productCardIsVisible() || forceIsVisible_());
|
|
640
642
|
const slidable = (0, $7jsgb$solidjs.createMemo)(()=>// Don't make cards swipable inside of sliders (PLP slider or recs slider)
|
|
641
643
|
!((0, $7jsgb$depictaiuilatest.useSlidableInformation)() || PLPLayout?.()?.startsWith("slider")) && configuredOptions_().image_carousel && // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
|
|
642
644
|
hasBeenVisible());
|
|
@@ -716,7 +718,7 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
716
718
|
const [itemsWantingToBeRendered, setItemsWantingToBeRendered] = (0, $7jsgb$solidjs.createSignal)([], {
|
|
717
719
|
equals: false
|
|
718
720
|
});
|
|
719
|
-
// When slidable, only render items (and therefore fetch images) when the user actually tried swiping -> this is for better network performance
|
|
721
|
+
// When slidable, only render extra items (and therefore fetch images) when the user actually tried swiping -> this is for better network performance
|
|
720
722
|
const MaybeShowLazily = (props)=>{
|
|
721
723
|
const us = Symbol();
|
|
722
724
|
setItemsWantingToBeRendered((prev)=>{
|
|
@@ -724,14 +726,15 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
724
726
|
return prev;
|
|
725
727
|
});
|
|
726
728
|
(0, $7jsgb$solidjs.onCleanup)(()=>setItemsWantingToBeRendered((prev)=>prev.filter((item)=>item !== us)));
|
|
727
|
-
return
|
|
729
|
+
return(// After it has been swiped, render (and fetch the images) for the rest.
|
|
730
|
+
(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
728
731
|
get when () {
|
|
729
|
-
return !slidable() ||
|
|
732
|
+
return !slidable() || userTriedSliding() || itemsWantingToBeRendered().indexOf(us) < 2;
|
|
730
733
|
},
|
|
731
734
|
get children () {
|
|
732
735
|
return props.children;
|
|
733
736
|
}
|
|
734
|
-
});
|
|
737
|
+
}));
|
|
735
738
|
};
|
|
736
739
|
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
737
740
|
get when () {
|
|
@@ -767,6 +770,9 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
767
770
|
},
|
|
768
771
|
get poster_ () {
|
|
769
772
|
return video_()?.preview_image_url || image_urls_()?.[0];
|
|
773
|
+
},
|
|
774
|
+
get forceIsVisible_ () {
|
|
775
|
+
return forceIsVisible_();
|
|
770
776
|
}
|
|
771
777
|
});
|
|
772
778
|
}
|
|
@@ -830,17 +836,6 @@ function $3375ddd88f77967d$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
830
836
|
})
|
|
831
837
|
});
|
|
832
838
|
}
|
|
833
|
-
}),
|
|
834
|
-
(0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$solidjs.Show), {
|
|
835
|
-
get when () {
|
|
836
|
-
return (0, $7jsgb$solidjsweb.memo)(()=>!!(slidable() && itemsWantingToBeRendered().length > 1))() && !userTriedSliding();
|
|
837
|
-
},
|
|
838
|
-
get children () {
|
|
839
|
-
return (0, $7jsgb$solidjsweb.createComponent)((0, $7jsgb$depictaiuilatest.ImagePlaceholder), {
|
|
840
|
-
width: "100%",
|
|
841
|
-
height: ""
|
|
842
|
-
});
|
|
843
|
-
}
|
|
844
839
|
})
|
|
845
840
|
];
|
|
846
841
|
}
|
|
@@ -880,7 +875,7 @@ function $3375ddd88f77967d$var$Video(props) {
|
|
|
880
875
|
(0, $7jsgb$solidjsweb.use)((element)=>{
|
|
881
876
|
element.disablePictureInPicture = true;
|
|
882
877
|
(0, $7jsgb$solidjs.createEffect)(()=>{
|
|
883
|
-
if (isVisible() && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $7jsgb$depictaiutilisharedlatest.dwarn)("Error playing video", e));
|
|
878
|
+
if ((isVisible() || props.forceIsVisible_) && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $7jsgb$depictaiutilisharedlatest.dwarn)("Error playing video", e));
|
|
884
879
|
else element.pause();
|
|
885
880
|
});
|
|
886
881
|
}, _el$17);
|
|
@@ -1098,7 +1093,10 @@ function $70cc6bd7e3f1dd4b$export$d1a48be4967fe67c(react_props) {
|
|
|
1098
1093
|
set_on_index_change: ()=>{},
|
|
1099
1094
|
depictCardsDataset: {},
|
|
1100
1095
|
formatPrice: (price)=>price && (0, $7jsgb$depictaiutilisharedlatest.standard_price_format)(price)
|
|
1101
|
-
}, ()=>
|
|
1096
|
+
}, ()=>({
|
|
1097
|
+
...props_store?.options || $70cc6bd7e3f1dd4b$export$5c9921af2948d16a,
|
|
1098
|
+
forceIsVisible_: true
|
|
1099
|
+
}));
|
|
1102
1100
|
},
|
|
1103
1101
|
// Work around in case https://github.com/solidjs/solid/issues/2139 potentially arises
|
|
1104
1102
|
props: structuredClone(react_props),
|
package/dist/module.js
CHANGED
|
@@ -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.32";
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
|
|
@@ -82,7 +82,8 @@ const $29535f590238371c$var$sizeOrder = [
|
|
|
82
82
|
];
|
|
83
83
|
const $29535f590238371c$var$ContainsColorSwatchesContext = /*@__PURE__*/ (0, $2MCgq$createContext)();
|
|
84
84
|
let $29535f590238371c$var$colorCanvasContext;
|
|
85
|
-
function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_,
|
|
85
|
+
function $29535f590238371c$export$f11681c54c860912(display, info, configuredOptions_, // forceIsVisible_ used in Depict portal where we don't have a provider with an IntersectionObserver
|
|
86
|
+
overrideAspectRatio) {
|
|
86
87
|
const variantDisplays = (0, $2MCgq$createMemo)(()=>display()?.variant_displays);
|
|
87
88
|
const defaultVariantIndex = (0, $2MCgq$createMemo)(()=>display()?.variant_index);
|
|
88
89
|
const [showVariantIndex, setShowVariantIndex] = (0, $2MCgq$createSignal)((0, $2MCgq$untrack)(defaultVariantIndex));
|
|
@@ -201,7 +202,8 @@ function $29535f590238371c$export$f11681c54c860912(display, info, configuredOpti
|
|
|
201
202
|
configuredOptions_: configuredOptions_,
|
|
202
203
|
cardIsHovered_: ()=>showVariantIndex() === display()?.variant_index && cardIsHovered(),
|
|
203
204
|
aspectRatio_: aspectRatio_,
|
|
204
|
-
noHoverSupport_: noHoverSupport_
|
|
205
|
+
noHoverSupport_: noHoverSupport_,
|
|
206
|
+
forceIsVisible_: ()=>configuredOptions_().forceIsVisible_
|
|
205
207
|
});
|
|
206
208
|
}
|
|
207
209
|
}), null);
|
|
@@ -616,14 +618,14 @@ function $29535f590238371c$var$setStyleForTextOptions({ style: style }, options)
|
|
|
616
618
|
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--color", options().color));
|
|
617
619
|
(0, $2MCgq$createEffect)(()=>$29535f590238371c$var$setPropertyIfExists(style, "--background", options().bg_color));
|
|
618
620
|
}
|
|
619
|
-
function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_, noHoverSupport_: noHoverSupport_ }) {
|
|
621
|
+
function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video_: video_, configuredOptions_: configuredOptions_, cardIsHovered_: cardIsHovered_, aspectRatio_: aspectRatio_, noHoverSupport_: noHoverSupport_, forceIsVisible_: forceIsVisible_ }) {
|
|
620
622
|
const PLPLayout = (0, $2MCgq$usePLPLayout)();
|
|
621
623
|
const containerClasses = ()=>[
|
|
622
624
|
"image-video",
|
|
623
625
|
"border-radius-" + configuredOptions_().image_radius
|
|
624
626
|
];
|
|
625
627
|
const productCardIsVisible = (0, $2MCgq$useProductCardIsVisible)();
|
|
626
|
-
const hasBeenVisible = (0, $2MCgq$createMemo)((prev)=>prev || productCardIsVisible());
|
|
628
|
+
const hasBeenVisible = (0, $2MCgq$createMemo)((prev)=>prev || productCardIsVisible() || forceIsVisible_());
|
|
627
629
|
const slidable = (0, $2MCgq$createMemo)(()=>// Don't make cards swipable inside of sliders (PLP slider or recs slider)
|
|
628
630
|
!((0, $2MCgq$useSlidableInformation)() || PLPLayout?.()?.startsWith("slider")) && configuredOptions_().image_carousel && // Delay creation of slider until card has been visible. We can't do it until the user interacts with it because it sometimes glitches the hover effect, but initialising the slider takes some time (need to compute if the buttons should be shown, there's a Mutationobserver, etc) so it's good to not initialise all at once (for example when going back)
|
|
629
631
|
hasBeenVisible());
|
|
@@ -703,7 +705,7 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
703
705
|
const [itemsWantingToBeRendered, setItemsWantingToBeRendered] = (0, $2MCgq$createSignal)([], {
|
|
704
706
|
equals: false
|
|
705
707
|
});
|
|
706
|
-
// When slidable, only render items (and therefore fetch images) when the user actually tried swiping -> this is for better network performance
|
|
708
|
+
// When slidable, only render extra items (and therefore fetch images) when the user actually tried swiping -> this is for better network performance
|
|
707
709
|
const MaybeShowLazily = (props)=>{
|
|
708
710
|
const us = Symbol();
|
|
709
711
|
setItemsWantingToBeRendered((prev)=>{
|
|
@@ -711,14 +713,15 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
711
713
|
return prev;
|
|
712
714
|
});
|
|
713
715
|
(0, $2MCgq$onCleanup)(()=>setItemsWantingToBeRendered((prev)=>prev.filter((item)=>item !== us)));
|
|
714
|
-
return
|
|
716
|
+
return(// After it has been swiped, render (and fetch the images) for the rest.
|
|
717
|
+
(0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
715
718
|
get when () {
|
|
716
|
-
return !slidable() ||
|
|
719
|
+
return !slidable() || userTriedSliding() || itemsWantingToBeRendered().indexOf(us) < 2;
|
|
717
720
|
},
|
|
718
721
|
get children () {
|
|
719
722
|
return props.children;
|
|
720
723
|
}
|
|
721
|
-
});
|
|
724
|
+
}));
|
|
722
725
|
};
|
|
723
726
|
return (0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
724
727
|
get when () {
|
|
@@ -754,6 +757,9 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
754
757
|
},
|
|
755
758
|
get poster_ () {
|
|
756
759
|
return video_()?.preview_image_url || image_urls_()?.[0];
|
|
760
|
+
},
|
|
761
|
+
get forceIsVisible_ () {
|
|
762
|
+
return forceIsVisible_();
|
|
757
763
|
}
|
|
758
764
|
});
|
|
759
765
|
}
|
|
@@ -817,17 +823,6 @@ function $29535f590238371c$var$ImagesAndVideos({ image_urls_: image_urls_, video
|
|
|
817
823
|
})
|
|
818
824
|
});
|
|
819
825
|
}
|
|
820
|
-
}),
|
|
821
|
-
(0, $2MCgq$createComponent)((0, $2MCgq$Show), {
|
|
822
|
-
get when () {
|
|
823
|
-
return (0, $2MCgq$memo)(()=>!!(slidable() && itemsWantingToBeRendered().length > 1))() && !userTriedSliding();
|
|
824
|
-
},
|
|
825
|
-
get children () {
|
|
826
|
-
return (0, $2MCgq$createComponent)((0, $2MCgq$ImagePlaceholder), {
|
|
827
|
-
width: "100%",
|
|
828
|
-
height: ""
|
|
829
|
-
});
|
|
830
|
-
}
|
|
831
826
|
})
|
|
832
827
|
];
|
|
833
828
|
}
|
|
@@ -867,7 +862,7 @@ function $29535f590238371c$var$Video(props) {
|
|
|
867
862
|
(0, $2MCgq$use)((element)=>{
|
|
868
863
|
element.disablePictureInPicture = true;
|
|
869
864
|
(0, $2MCgq$createEffect)(()=>{
|
|
870
|
-
if (isVisible() && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $2MCgq$dwarn)("Error playing video", e));
|
|
865
|
+
if ((isVisible() || props.forceIsVisible_) && tabIsVisible() && !hiddenInImageCarousel()) element.play().catch((e)=>(0, $2MCgq$dwarn)("Error playing video", e));
|
|
871
866
|
else element.pause();
|
|
872
867
|
});
|
|
873
868
|
}, _el$17);
|
|
@@ -1085,7 +1080,10 @@ function $474e9d712b745d60$export$d1a48be4967fe67c(react_props) {
|
|
|
1085
1080
|
set_on_index_change: ()=>{},
|
|
1086
1081
|
depictCardsDataset: {},
|
|
1087
1082
|
formatPrice: (price)=>price && (0, $2MCgq$standard_price_format)(price)
|
|
1088
|
-
}, ()=>
|
|
1083
|
+
}, ()=>({
|
|
1084
|
+
...props_store?.options || $474e9d712b745d60$export$5c9921af2948d16a,
|
|
1085
|
+
forceIsVisible_: true
|
|
1086
|
+
}));
|
|
1089
1087
|
},
|
|
1090
1088
|
// Work around in case https://github.com/solidjs/solid/issues/2139 potentially arises
|
|
1091
1089
|
props: structuredClone(react_props),
|
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.32",
|
|
4
4
|
"packageManager": "yarn@3.2.2",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"main": "dist/main.js",
|
|
@@ -104,7 +104,7 @@
|
|
|
104
104
|
"@depict-ai/plp-styling": "^4.4.20",
|
|
105
105
|
"@depict-ai/react-ui": "^4.8.7",
|
|
106
106
|
"@depict-ai/types": "^5.4.5",
|
|
107
|
-
"@depict-ai/ui": "^4.8.
|
|
107
|
+
"@depict-ai/ui": "^4.8.22",
|
|
108
108
|
"@depict-ai/utilishared": "^2.4.7",
|
|
109
109
|
"parcel": "^2.10.3",
|
|
110
110
|
"solid-js": "^1.8.16"
|
|
@@ -134,7 +134,7 @@ export function DefaultSolidProductCard(
|
|
|
134
134
|
// In development (product card editor), a fallback formatting will be used.
|
|
135
135
|
formatPrice: <T extends number | undefined>(price: T) => T extends undefined ? undefined : string;
|
|
136
136
|
}),
|
|
137
|
-
configuredOptions_: Accessor<ProductCardSchema>,
|
|
137
|
+
configuredOptions_: Accessor<ProductCardSchema & { forceIsVisible_?: boolean }>, // forceIsVisible_ used in Depict portal where we don't have a provider with an IntersectionObserver
|
|
138
138
|
overrideAspectRatio?: Accessor<number>
|
|
139
139
|
) {
|
|
140
140
|
const variantDisplays = createMemo(() => display()?.variant_displays);
|
|
@@ -268,6 +268,7 @@ export function DefaultSolidProductCard(
|
|
|
268
268
|
cardIsHovered_={() => showVariantIndex() === display()?.variant_index && cardIsHovered()}
|
|
269
269
|
aspectRatio_={aspectRatio_}
|
|
270
270
|
noHoverSupport_={noHoverSupport_}
|
|
271
|
+
forceIsVisible_={() => configuredOptions_().forceIsVisible_}
|
|
271
272
|
/>
|
|
272
273
|
</LinkWrapped>
|
|
273
274
|
|
|
@@ -679,6 +680,7 @@ function ImagesAndVideos({
|
|
|
679
680
|
cardIsHovered_,
|
|
680
681
|
aspectRatio_,
|
|
681
682
|
noHoverSupport_,
|
|
683
|
+
forceIsVisible_,
|
|
682
684
|
}: {
|
|
683
685
|
image_urls_: Accessor<undefined | string[]>;
|
|
684
686
|
video_: Accessor<undefined | { preview_image_url: string; video_urls: string[] }>;
|
|
@@ -686,11 +688,12 @@ function ImagesAndVideos({
|
|
|
686
688
|
cardIsHovered_: Accessor<boolean>;
|
|
687
689
|
aspectRatio_: Accessor<number>;
|
|
688
690
|
noHoverSupport_: Accessor<boolean>;
|
|
691
|
+
forceIsVisible_: Accessor<boolean | undefined>;
|
|
689
692
|
}) {
|
|
690
693
|
const PLPLayout = usePLPLayout();
|
|
691
694
|
const containerClasses = () => ["image-video", "border-radius-" + configuredOptions_().image_radius] as const;
|
|
692
695
|
const productCardIsVisible = useProductCardIsVisible();
|
|
693
|
-
const hasBeenVisible = createMemo<boolean | undefined>(prev => prev || productCardIsVisible());
|
|
696
|
+
const hasBeenVisible = createMemo<boolean | undefined>(prev => prev || productCardIsVisible() || forceIsVisible_());
|
|
694
697
|
const slidable = createMemo(
|
|
695
698
|
() =>
|
|
696
699
|
// Don't make cards swipable inside of sliders (PLP slider or recs slider)
|
|
@@ -770,7 +773,7 @@ function ImagesAndVideos({
|
|
|
770
773
|
);
|
|
771
774
|
};
|
|
772
775
|
const [itemsWantingToBeRendered, setItemsWantingToBeRendered] = createSignal<symbol[]>([], { equals: false });
|
|
773
|
-
// When slidable, only render items (and therefore fetch images) when the user actually tried swiping -> this is for better network performance
|
|
776
|
+
// When slidable, only render extra items (and therefore fetch images) when the user actually tried swiping -> this is for better network performance
|
|
774
777
|
const MaybeShowLazily = (props: { children: JSX.Element }) => {
|
|
775
778
|
const us = Symbol();
|
|
776
779
|
setItemsWantingToBeRendered(prev => {
|
|
@@ -779,7 +782,11 @@ function ImagesAndVideos({
|
|
|
779
782
|
});
|
|
780
783
|
onCleanup(() => setItemsWantingToBeRendered(prev => prev.filter(item => item !== us)));
|
|
781
784
|
return (
|
|
782
|
-
|
|
785
|
+
// Render the first two items immediately, so the slider can be swiped and there is an image when it's done.
|
|
786
|
+
// After it has been swiped, render (and fetch the images) for the rest.
|
|
787
|
+
<Show when={!slidable() || userTriedSliding() || itemsWantingToBeRendered().indexOf(us) < 2}>
|
|
788
|
+
{props.children}
|
|
789
|
+
</Show>
|
|
783
790
|
);
|
|
784
791
|
};
|
|
785
792
|
|
|
@@ -793,6 +800,7 @@ function ImagesAndVideos({
|
|
|
793
800
|
<Video
|
|
794
801
|
video_sources_={video_urls() as [string, ...string[]]}
|
|
795
802
|
poster_={video_()?.preview_image_url || image_urls_()?.[0]}
|
|
803
|
+
forceIsVisible_={forceIsVisible_()}
|
|
796
804
|
/>
|
|
797
805
|
</ImageContainer>
|
|
798
806
|
</div>
|
|
@@ -826,15 +834,12 @@ function ImagesAndVideos({
|
|
|
826
834
|
)}
|
|
827
835
|
</For>
|
|
828
836
|
</Show>
|
|
829
|
-
<Show when={slidable() && itemsWantingToBeRendered().length > 1 && !userTriedSliding()}>
|
|
830
|
-
<ImagePlaceholder width="100%" height="" />
|
|
831
|
-
</Show>
|
|
832
837
|
</Container>
|
|
833
838
|
</Show>
|
|
834
839
|
);
|
|
835
840
|
}
|
|
836
841
|
|
|
837
|
-
function Video(props: { video_sources_: [string, ...string[]]; poster_?: string }) {
|
|
842
|
+
function Video(props: { video_sources_: [string, ...string[]]; poster_?: string; forceIsVisible_?: boolean }) {
|
|
838
843
|
// Making some assumptions for shopify here rn, change those if wanting to support other browsers too
|
|
839
844
|
|
|
840
845
|
const tabIsVisible = useVisibilityState();
|
|
@@ -875,7 +880,7 @@ function Video(props: { video_sources_: [string, ...string[]]; poster_?: string
|
|
|
875
880
|
ref={element => {
|
|
876
881
|
element.disablePictureInPicture = true;
|
|
877
882
|
createEffect(() => {
|
|
878
|
-
if (isVisible() && tabIsVisible() && !hiddenInImageCarousel()) {
|
|
883
|
+
if ((isVisible() || props.forceIsVisible_) && tabIsVisible() && !hiddenInImageCarousel()) {
|
|
879
884
|
element.play().catch(e => dwarn("Error playing video", e));
|
|
880
885
|
} else {
|
|
881
886
|
element.pause();
|