cloudcommerce 0.18.2 → 0.20.0
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/.github/renovate.json +1 -2
- package/CHANGELOG.md +48 -0
- package/package.json +6 -6
- package/packages/api/package.json +1 -1
- package/packages/apps/affilate-program/package.json +2 -2
- package/packages/apps/correios/package.json +1 -1
- package/packages/apps/custom-payment/package.json +1 -1
- package/packages/apps/custom-shipping/package.json +1 -1
- package/packages/apps/datafrete/package.json +2 -2
- package/packages/apps/discounts/package.json +1 -1
- package/packages/apps/emails/package.json +2 -2
- package/packages/apps/fb-conversions/package.json +2 -2
- package/packages/apps/flash-courier/package.json +1 -1
- package/packages/apps/frenet/package.json +2 -2
- package/packages/apps/galaxpay/package.json +2 -2
- package/packages/apps/google-analytics/package.json +2 -2
- package/packages/apps/jadlog/package.json +1 -1
- package/packages/apps/loyalty-points/package.json +1 -1
- package/packages/apps/melhor-envio/package.json +2 -2
- package/packages/apps/mercadopago/package.json +2 -2
- package/packages/apps/pagarme/package.json +2 -2
- package/packages/apps/paghiper/package.json +2 -2
- package/packages/apps/pix/package.json +2 -2
- package/packages/apps/tiny-erp/package.json +2 -2
- package/packages/apps/webhooks/package.json +2 -2
- package/packages/cli/package.json +1 -1
- package/packages/config/package.json +1 -1
- package/packages/emails/package.json +1 -1
- package/packages/events/package.json +2 -2
- package/packages/feeds/package.json +1 -1
- package/packages/firebase/package.json +2 -2
- package/packages/i18n/package.json +1 -1
- package/packages/modules/package.json +2 -2
- package/packages/passport/package.json +2 -2
- package/packages/ssr/lib/firebase/serve-storefront.js +75 -72
- package/packages/ssr/lib/firebase/serve-storefront.js.map +1 -1
- package/packages/ssr/package.json +3 -3
- package/packages/ssr/src/firebase/serve-storefront.ts +83 -84
- package/packages/storefront/.eslintrc.cjs +1 -1
- package/packages/storefront/config/storefront.tailwind.cjs +5 -8
- package/packages/storefront/dist/client/_astro/Carousel.62c97a79.js +1 -0
- package/packages/storefront/dist/client/_astro/HeroSlider.eb156f18.js +1 -0
- package/packages/storefront/dist/client/_astro/PitchBar.ed85833a.js +1 -0
- package/packages/storefront/dist/client/_astro/ProductShelf.9e290480.js +1 -0
- package/packages/storefront/dist/client/_astro/ShopHeader.0c884bbe.js +4 -0
- package/packages/storefront/dist/client/_astro/_...slug_.c2da43fb.css +1 -0
- package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.4cb7dd76.js +1 -0
- package/packages/storefront/dist/client/_astro/api.4984c5be.js +1 -0
- package/packages/storefront/dist/client/_astro/client.8035a95a.js +1 -0
- package/packages/storefront/dist/client/_astro/img.abbe849f.js +1 -0
- package/packages/storefront/dist/client/_astro/index.b93f3d06.js +1 -0
- package/packages/storefront/dist/client/sw.js +1 -1
- package/packages/storefront/dist/server/chunks/{_...4cff750f.mjs → _...9e22b578.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{account@_@astro.9bc80fb8.mjs → account@_@astro.89e4cf60.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{astro.2df8d1c5.mjs → astro.45d3047f.mjs} +10 -3
- package/packages/storefront/dist/server/chunks/{endpoint@_@js.36a1cfa7.mjs → endpoint@_@js.f880a152.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{fallback@_@astro.6af59549.mjs → fallback@_@astro.89538855.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{index@_@astro.846e70bb.mjs → index@_@astro.548cf7ad.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/{index@_@astro.1ea814dc.mjs → index@_@astro.56fdd6da.mjs} +3 -3
- package/packages/storefront/dist/server/chunks/pages/{_...slug_.astro.906634b2.mjs → _...slug_.astro.bde9380b.mjs} +125 -36
- package/packages/storefront/dist/server/chunks/pages/{account.astro.f630663e.mjs → account.astro.f07cf19e.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{endpoint.js.ffec1d05.mjs → endpoint.js.d4e37801.mjs} +1 -1
- package/packages/storefront/dist/server/chunks/pages/{fallback.astro.0a073a86.mjs → fallback.astro.e2e8a0e4.mjs} +2 -2
- package/packages/storefront/dist/server/chunks/pages/{index.astro.fb8fe537.mjs → index.astro.3760ebe3.mjs} +443 -321
- package/packages/storefront/dist/server/entry.mjs +9 -9
- package/packages/storefront/dist/server/renderers.mjs +2 -2
- package/packages/storefront/package.json +5 -5
- package/packages/storefront/src/images/get-built-picture.ts +1 -0
- package/packages/storefront/src/images/use-ssr-picture.ts +11 -6
- package/packages/storefront/src/lib/components/{HeroPicture.astro → BannerPictures.astro} +19 -13
- package/packages/storefront/src/lib/composables/use-banner.ts +38 -0
- package/packages/storefront/src/lib/composables/use-hero-slider.ts +4 -18
- package/packages/storefront/src/lib/composables/use-product-card.ts +10 -11
- package/packages/storefront/src/lib/layouts/{main/use-page-sections.ts → use-page-main.ts} +59 -12
- package/packages/storefront/src/lib/ssr-context.ts +1 -1
- package/packages/storefront/src/lib/state/shopping-cart/parse-product.ts +6 -3
- package/packages/storefront/src/lib/state/shopping-cart.ts +3 -3
- package/packages/storefront/src/lib/state/use-cms-preview.ts +1 -1
- package/packages/types/package.json +1 -1
- package/packages/storefront/dist/client/_astro/Carousel.533b4b19.js +0 -1
- package/packages/storefront/dist/client/_astro/HeroSlider.359c76cc.js +0 -1
- package/packages/storefront/dist/client/_astro/PitchBar.75d2999f.js +0 -1
- package/packages/storefront/dist/client/_astro/Prices.bd0d3474.js +0 -1
- package/packages/storefront/dist/client/_astro/ProductShelf.83c66e3e.js +0 -1
- package/packages/storefront/dist/client/_astro/ShopHeader.a06de422.js +0 -4
- package/packages/storefront/dist/client/_astro/_...slug_.b19aabfc.css +0 -1
- package/packages/storefront/dist/client/_astro/_plugin-vue_export-helper.4e6dc3af.js +0 -1
- package/packages/storefront/dist/client/_astro/api.7f62c1ff.js +0 -1
- package/packages/storefront/dist/client/_astro/client.24201f93.js +0 -1
- package/packages/storefront/dist/client/_astro/img.22ad29ec.js +0 -1
- package/packages/storefront/dist/client/_astro/index.ddc27a3a.js +0 -1
- package/packages/storefront/dist/client/_astro/modules-info.d6bd555b.js +0 -1
- package/packages/storefront/dist/client/_astro/runtime-dom.esm-bundler.578d6e91.js +0 -1
- package/packages/storefront/dist/client/img/uploads/banner1.png +0 -0
- package/packages/storefront/dist/client/img/uploads/banner2.png +0 -0
- package/packages/storefront/dist/client/img/uploads/favicon.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headless.png +0 -0
- package/packages/storefront/dist/client/img/uploads/headphone.png +0 -0
- package/packages/storefront/dist/client/img/uploads/passion.png +0 -0
- package/packages/storefront/dist/client/img/uploads/pwa-reliable.png +0 -0
- package/packages/storefront/dist/client/img/uploads/rect89.png +0 -0
- package/packages/storefront/dist/client/img/uploads/ssl-safe.png +0 -0
- package/packages/storefront/src/lib/layouts/main/use-page-hero.ts +0 -47
|
@@ -1,51 +1,205 @@
|
|
|
1
|
-
import { c as createAstro, a as createComponent, r as renderTemplate, d as renderComponent, m as maybeRenderHead, b as addAttribute, u as unescapeHTML, F as Fragment$1 } from '../astro.
|
|
2
|
-
import { b as $$Picture, p as parseShippingPhrase, _ as _export_sfc, C as Carousel, c as CarouselControl, d as availableExtraDiscount, e as installmentsOption, f as discountOption, g as loyaltyPointsPrograms, l as loadRouteContext, $ as $$PageHeader, a as $$Base } from './_...slug_.astro.
|
|
1
|
+
import { c as createAstro, a as createComponent, r as renderTemplate, d as renderComponent, m as maybeRenderHead, b as addAttribute, u as unescapeHTML, F as Fragment$1 } from '../astro.45d3047f.mjs';
|
|
2
|
+
import { b as $$Picture, p as parseShippingPhrase, _ as _export_sfc, C as Carousel, c as CarouselControl, d as availableExtraDiscount, e as installmentsOption, f as discountOption, g as loyaltyPointsPrograms, h as addProductToCart, l as loadRouteContext, $ as $$PageHeader, a as $$Base } from './_...slug_.astro.bde9380b.mjs';
|
|
3
|
+
import { ref, shallowReactive, computed, useSSRContext, defineComponent, mergeProps, createVNode, resolveDynamicComponent, withCtx, renderSlot, createTextVNode, toDisplayString, withDirectives, vShow, openBlock, createBlock, Fragment, renderList, resolveComponent, createCommentVNode, withModifiers, withAsyncContext } from 'vue';
|
|
3
4
|
import api from '@cloudcommerce/api';
|
|
4
|
-
import { computed, useSSRContext, defineComponent, mergeProps, withCtx, createVNode, withDirectives, vShow, resolveDynamicComponent, createTextVNode, toDisplayString, openBlock, createBlock, Fragment, renderList, renderSlot, createCommentVNode, ref, shallowReactive, resolveComponent, withAsyncContext } from 'vue';
|
|
5
|
-
import { ssrRenderAttrs, ssrRenderComponent, ssrRenderStyle, ssrRenderList, ssrRenderClass, ssrRenderAttr, ssrRenderSlot, ssrRenderVNode, ssrInterpolate } from 'vue/server-renderer';
|
|
6
5
|
import { inStock, price, name, img, onPromotion } from '@ecomplus/utils';
|
|
6
|
+
import { ssrRenderAttrs, ssrRenderVNode, ssrRenderSlot, ssrInterpolate, ssrRenderComponent, ssrRenderStyle, ssrRenderList, ssrRenderClass, ssrRenderAttr } from 'vue/server-renderer';
|
|
7
7
|
import { useElementHover, watchOnce } from '@vueuse/core';
|
|
8
8
|
|
|
9
|
+
const useProductShelf = (props) => {
|
|
10
|
+
const title = ref(props.title || "");
|
|
11
|
+
const titleLink = ref(props.titleLink || "");
|
|
12
|
+
const isFetching = ref(false);
|
|
13
|
+
let fetching = null;
|
|
14
|
+
const fetchError = ref(null);
|
|
15
|
+
const products = shallowReactive(props.products || []);
|
|
16
|
+
if (!props.products) {
|
|
17
|
+
isFetching.value = true;
|
|
18
|
+
fetching = (async () => {
|
|
19
|
+
let searchQuery = props.searchQuery || "";
|
|
20
|
+
let collection;
|
|
21
|
+
if (props.collectionId) {
|
|
22
|
+
try {
|
|
23
|
+
const { data } = await api.get(`collections/${props.collectionId}`);
|
|
24
|
+
collection = data;
|
|
25
|
+
} catch (err) {
|
|
26
|
+
console.error(err);
|
|
27
|
+
fetchError.value = err;
|
|
28
|
+
}
|
|
29
|
+
const productIds = collection?.products;
|
|
30
|
+
if (Array.isArray(productIds) && productIds.length) {
|
|
31
|
+
searchQuery += `&_id=${productIds.slice(0, 60).join(",")}`;
|
|
32
|
+
}
|
|
33
|
+
if (!title.value && title.value !== null && collection?.name) {
|
|
34
|
+
title.value = collection?.name;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const limit = props.limit || 24;
|
|
38
|
+
const offset = props.page ? (props.page - 1) * limit : 0;
|
|
39
|
+
let endpointQuery = `offset=${offset}&limit=${limit}`;
|
|
40
|
+
if (props.sort) {
|
|
41
|
+
endpointQuery += `&sort=${props.sort}`;
|
|
42
|
+
}
|
|
43
|
+
endpointQuery += searchQuery;
|
|
44
|
+
try {
|
|
45
|
+
const { data } = await api.get(`search/v1?${endpointQuery}`);
|
|
46
|
+
if (props.isShuffle) {
|
|
47
|
+
let m = data.result.filter((item) => {
|
|
48
|
+
return item.available && inStock(item);
|
|
49
|
+
}).length;
|
|
50
|
+
let t;
|
|
51
|
+
let i;
|
|
52
|
+
while (m) {
|
|
53
|
+
i = Math.floor(Math.random() * m--);
|
|
54
|
+
t = data.result[m];
|
|
55
|
+
data.result[m] = data.result[i];
|
|
56
|
+
data.result[i] = t;
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
data.result.forEach((item) => products.push(item));
|
|
60
|
+
} catch (err) {
|
|
61
|
+
console.error(err);
|
|
62
|
+
fetchError.value = err;
|
|
63
|
+
}
|
|
64
|
+
isFetching.value = false;
|
|
65
|
+
})();
|
|
66
|
+
}
|
|
67
|
+
return {
|
|
68
|
+
title,
|
|
69
|
+
titleLink,
|
|
70
|
+
isFetching,
|
|
71
|
+
fetching,
|
|
72
|
+
fetchError,
|
|
73
|
+
products
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const now = Date.now();
|
|
78
|
+
const parseBanners = (banners) => {
|
|
79
|
+
const validBanners = [];
|
|
80
|
+
banners.forEach(({
|
|
81
|
+
img,
|
|
82
|
+
start,
|
|
83
|
+
end,
|
|
84
|
+
mobile_img: mobileImg,
|
|
85
|
+
button_link: buttonLink,
|
|
86
|
+
button_text: buttonText,
|
|
87
|
+
...rest
|
|
88
|
+
}) => {
|
|
89
|
+
if (start && new Date(start).getTime() < now)
|
|
90
|
+
return;
|
|
91
|
+
if (end && new Date(end).getTime() > now)
|
|
92
|
+
return;
|
|
93
|
+
validBanners.push({
|
|
94
|
+
...rest,
|
|
95
|
+
img,
|
|
96
|
+
mobileImg,
|
|
97
|
+
buttonLink,
|
|
98
|
+
buttonText
|
|
99
|
+
});
|
|
100
|
+
});
|
|
101
|
+
return validBanners;
|
|
102
|
+
};
|
|
9
103
|
const usePageHero = async ({ routeContext }) => {
|
|
10
104
|
const { cmsContent } = routeContext;
|
|
11
105
|
const heroSlider = { slides: [] };
|
|
12
106
|
const heroContent = cmsContent?.hero;
|
|
13
107
|
if (heroContent) {
|
|
14
108
|
heroSlider.autoplay = heroContent.autoplay;
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
109
|
+
if (heroContent.slides) {
|
|
110
|
+
heroSlider.slides = parseBanners(heroContent.slides);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return { heroSlider };
|
|
114
|
+
};
|
|
115
|
+
const usePageSections = async ({ routeContext }) => {
|
|
116
|
+
const sectionsContent = routeContext.cmsContent?.sections;
|
|
117
|
+
const sections = [];
|
|
118
|
+
if (sectionsContent) {
|
|
119
|
+
await Promise.all(sectionsContent.map(async ({ type, ...sectionContent }, index) => {
|
|
120
|
+
if (type === "product-shelf") {
|
|
121
|
+
const {
|
|
122
|
+
collection_id: collectionIdAndInfo,
|
|
123
|
+
headless: isHeadless,
|
|
124
|
+
shuffle: isShuffle,
|
|
125
|
+
...rest
|
|
126
|
+
} = sectionContent;
|
|
127
|
+
let { sort, title } = sectionContent;
|
|
128
|
+
switch (sort) {
|
|
129
|
+
case "offers":
|
|
130
|
+
sort = "-price_discount";
|
|
131
|
+
break;
|
|
132
|
+
case "news":
|
|
133
|
+
sort = "-_id";
|
|
134
|
+
break;
|
|
135
|
+
case "lowest_price":
|
|
136
|
+
sort = "price";
|
|
137
|
+
break;
|
|
138
|
+
case "highest_price":
|
|
139
|
+
sort = "-price";
|
|
140
|
+
break;
|
|
141
|
+
}
|
|
142
|
+
let collectionId = null;
|
|
143
|
+
let searchQuery;
|
|
144
|
+
let titleLink;
|
|
145
|
+
if (collectionIdAndInfo) {
|
|
146
|
+
const [_id, resource, name, path] = collectionIdAndInfo.split(":");
|
|
147
|
+
collectionId = _id;
|
|
148
|
+
if (resource === "categories") {
|
|
149
|
+
searchQuery = `&categories._id=${_id}`;
|
|
150
|
+
} else if (resource === "brands") {
|
|
151
|
+
searchQuery = `&brands._id=${_id}`;
|
|
152
|
+
}
|
|
153
|
+
if (!title && title !== null && name) {
|
|
154
|
+
title = name;
|
|
155
|
+
}
|
|
156
|
+
titleLink = path;
|
|
157
|
+
}
|
|
158
|
+
const props = {
|
|
159
|
+
...rest,
|
|
160
|
+
collectionId,
|
|
161
|
+
searchQuery,
|
|
162
|
+
sort,
|
|
163
|
+
title: isHeadless ? null : title,
|
|
164
|
+
titleLink,
|
|
165
|
+
isShuffle
|
|
166
|
+
};
|
|
167
|
+
const { fetching, products } = useProductShelf(props);
|
|
168
|
+
await fetching;
|
|
169
|
+
sections[index] = {
|
|
170
|
+
type,
|
|
171
|
+
props: {
|
|
172
|
+
...rest,
|
|
173
|
+
collectionId,
|
|
174
|
+
searchQuery,
|
|
175
|
+
sort,
|
|
176
|
+
title: isHeadless ? null : title,
|
|
177
|
+
titleLink,
|
|
178
|
+
isShuffle,
|
|
179
|
+
products
|
|
180
|
+
}
|
|
181
|
+
};
|
|
30
182
|
return;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
183
|
+
}
|
|
184
|
+
if (type === "banners-grid") {
|
|
185
|
+
sections[index] = {
|
|
186
|
+
type,
|
|
187
|
+
props: {
|
|
188
|
+
banners: parseBanners(sectionContent.banners || [])
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
39
193
|
}
|
|
40
194
|
return {
|
|
41
|
-
|
|
195
|
+
sections
|
|
42
196
|
};
|
|
43
197
|
};
|
|
44
198
|
|
|
45
|
-
const $$Astro$
|
|
46
|
-
const $$
|
|
47
|
-
const Astro2 = $$result.createAstro($$Astro$
|
|
48
|
-
Astro2.self = $$
|
|
199
|
+
const $$Astro$5 = createAstro("https://ecom2-demo.web.app");
|
|
200
|
+
const $$BannerPictures = createComponent(async ($$result, $$props, $$slots) => {
|
|
201
|
+
const Astro2 = $$result.createAstro($$Astro$5, $$props, $$slots);
|
|
202
|
+
Astro2.self = $$BannerPictures;
|
|
49
203
|
const {
|
|
50
204
|
img,
|
|
51
205
|
alt,
|
|
@@ -53,7 +207,9 @@ const $$HeroPicture = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
53
207
|
title,
|
|
54
208
|
subtitle,
|
|
55
209
|
buttonText,
|
|
56
|
-
index
|
|
210
|
+
index,
|
|
211
|
+
class: className = "max-w-screen-2xl",
|
|
212
|
+
mobileClass = "max-w-screen-sm"
|
|
57
213
|
} = Astro2.props;
|
|
58
214
|
const hasHeader = title || subtitle || buttonText;
|
|
59
215
|
let { widths, mobileWidths } = Astro2.props;
|
|
@@ -70,19 +226,37 @@ const $$HeroPicture = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
70
226
|
if (!mobileWidths?.length) {
|
|
71
227
|
mobileWidths = [720, 856];
|
|
72
228
|
}
|
|
73
|
-
return renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": img, "alt": alt || "", "widths": widths, "fetchpriority": index === 0 ? "high" : "low", "loading": index === 0 ? "eager" : "lazy", "class": `${mobileImg ? "hidden md:block" : ""}
|
|
74
|
-
${mobileImg && renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": mobileImg, "alt": alt || "", "widths": mobileWidths, "fetchpriority": index === 0 ? "high" : "low", "loading": index === 0 ? "eager" : "lazy", "class":
|
|
75
|
-
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/components/
|
|
229
|
+
return renderTemplate`${img && renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": img, "alt": alt || "", "widths": widths, "fetchpriority": index === 0 ? "high" : "low", "loading": index === 0 ? "eager" : "lazy", "class": `${mobileImg ? "hidden md:block " : ""}mx-auto ${className}` })}`}
|
|
230
|
+
${mobileImg && renderTemplate`${renderComponent($$result, "Picture", $$Picture, { "src": mobileImg, "alt": alt || "", "widths": mobileWidths, "fetchpriority": index === 0 ? "high" : "low", "loading": index === 0 ? "eager" : "lazy", "class": `md:hidden mx-auto ${mobileClass}` })}`}`;
|
|
231
|
+
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/lib/components/BannerPictures.astro");
|
|
232
|
+
|
|
233
|
+
const useBanner = (props) => {
|
|
234
|
+
const parsedTitle = computed(() => {
|
|
235
|
+
return props.title ? parseShippingPhrase(props.title).value : "";
|
|
236
|
+
});
|
|
237
|
+
const parsedSubtitle = computed(() => {
|
|
238
|
+
return props.subtitle ? parseShippingPhrase(props.subtitle).value : "";
|
|
239
|
+
});
|
|
240
|
+
const parsedButtonText = computed(() => {
|
|
241
|
+
return props.buttonText ? parseShippingPhrase(props.buttonText).value : "";
|
|
242
|
+
});
|
|
243
|
+
const hasHeader = computed(() => {
|
|
244
|
+
return Boolean(parsedTitle.value || parsedSubtitle.value || parsedButtonText.value);
|
|
245
|
+
});
|
|
246
|
+
return {
|
|
247
|
+
parsedTitle,
|
|
248
|
+
parsedSubtitle,
|
|
249
|
+
parsedButtonText,
|
|
250
|
+
hasHeader
|
|
251
|
+
};
|
|
252
|
+
};
|
|
76
253
|
|
|
77
254
|
const useHeroSlider = (props) => {
|
|
78
255
|
const parsedSlides = computed(() => {
|
|
79
256
|
return props.slides.map((slide) => {
|
|
80
|
-
const title = slide.title ? parseShippingPhrase(slide.title).value : "";
|
|
81
|
-
const subtitle = slide.subtitle ? parseShippingPhrase(slide.subtitle).value : "";
|
|
82
|
-
const buttonText = slide.buttonText ? parseShippingPhrase(slide.buttonText).value : "";
|
|
83
257
|
return {
|
|
84
258
|
...slide,
|
|
85
|
-
|
|
259
|
+
...useBanner(slide)
|
|
86
260
|
};
|
|
87
261
|
});
|
|
88
262
|
});
|
|
@@ -91,6 +265,108 @@ const useHeroSlider = (props) => {
|
|
|
91
265
|
};
|
|
92
266
|
};
|
|
93
267
|
|
|
268
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
269
|
+
__name: "Banner",
|
|
270
|
+
props: {
|
|
271
|
+
img: {},
|
|
272
|
+
alt: {},
|
|
273
|
+
mobileImg: {},
|
|
274
|
+
href: {},
|
|
275
|
+
title: {},
|
|
276
|
+
subtitle: {},
|
|
277
|
+
buttonLink: {},
|
|
278
|
+
buttonText: {},
|
|
279
|
+
headingTag: { default: "h3" }
|
|
280
|
+
},
|
|
281
|
+
setup(__props, { expose: __expose }) {
|
|
282
|
+
__expose();
|
|
283
|
+
const props = __props;
|
|
284
|
+
const {
|
|
285
|
+
hasHeader,
|
|
286
|
+
parsedTitle,
|
|
287
|
+
parsedSubtitle,
|
|
288
|
+
parsedButtonText
|
|
289
|
+
} = useBanner(props);
|
|
290
|
+
const __returned__ = { props, hasHeader, parsedTitle, parsedSubtitle, parsedButtonText };
|
|
291
|
+
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
292
|
+
return __returned__;
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
function _sfc_ssrRender$4(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
|
|
296
|
+
_push(`<div${ssrRenderAttrs(mergeProps({
|
|
297
|
+
class: ["mx-auto overflow-x-hidden", $setup.hasHeader ? "grid grid-cols-1 md:grid-cols-2 items-center" : null]
|
|
298
|
+
}, _attrs))}>`);
|
|
299
|
+
ssrRenderVNode(_push, createVNode(resolveDynamicComponent($props.href ? "a-link" : "span"), {
|
|
300
|
+
href: $props.href,
|
|
301
|
+
class: $setup.hasHeader ? "basis-1/2 grow-0 md:order-last" : null
|
|
302
|
+
}, {
|
|
303
|
+
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
304
|
+
if (_push2) {
|
|
305
|
+
ssrRenderSlot(_ctx.$slots, "picture", {}, null, _push2, _parent2, _scopeId);
|
|
306
|
+
} else {
|
|
307
|
+
return [
|
|
308
|
+
renderSlot(_ctx.$slots, "picture")
|
|
309
|
+
];
|
|
310
|
+
}
|
|
311
|
+
}),
|
|
312
|
+
_: 3
|
|
313
|
+
}), _parent);
|
|
314
|
+
if ($setup.hasHeader) {
|
|
315
|
+
_push(`<div class="basis-1/2 grow-0 p-12 xl:ps-32 mb-3 md:mb-0">`);
|
|
316
|
+
if ($setup.parsedTitle) {
|
|
317
|
+
ssrRenderVNode(_push, createVNode(resolveDynamicComponent($props.headingTag), { class: "ui-title mt-1" }, {
|
|
318
|
+
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
319
|
+
if (_push2) {
|
|
320
|
+
_push2(`${ssrInterpolate($setup.parsedTitle)}`);
|
|
321
|
+
} else {
|
|
322
|
+
return [
|
|
323
|
+
createTextVNode(toDisplayString($setup.parsedTitle), 1)
|
|
324
|
+
];
|
|
325
|
+
}
|
|
326
|
+
}),
|
|
327
|
+
_: 1
|
|
328
|
+
}), _parent);
|
|
329
|
+
} else {
|
|
330
|
+
_push(`<!---->`);
|
|
331
|
+
}
|
|
332
|
+
if ($setup.parsedSubtitle) {
|
|
333
|
+
_push(`<p class="text-lg mt-4 md:mt-6">${ssrInterpolate($setup.parsedSubtitle)}</p>`);
|
|
334
|
+
} else {
|
|
335
|
+
_push(`<!---->`);
|
|
336
|
+
}
|
|
337
|
+
if ($setup.parsedButtonText) {
|
|
338
|
+
ssrRenderVNode(_push, createVNode(resolveDynamicComponent($props.buttonLink ? "a-link" : "span"), {
|
|
339
|
+
href: $props.buttonLink,
|
|
340
|
+
class: "ui-btn-lg ui-btn-contrast min-w-[150px] mt-7 md:mt-10"
|
|
341
|
+
}, {
|
|
342
|
+
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
343
|
+
if (_push2) {
|
|
344
|
+
_push2(`${ssrInterpolate($setup.parsedButtonText)}`);
|
|
345
|
+
} else {
|
|
346
|
+
return [
|
|
347
|
+
createTextVNode(toDisplayString($setup.parsedButtonText), 1)
|
|
348
|
+
];
|
|
349
|
+
}
|
|
350
|
+
}),
|
|
351
|
+
_: 1
|
|
352
|
+
}), _parent);
|
|
353
|
+
} else {
|
|
354
|
+
_push(`<!---->`);
|
|
355
|
+
}
|
|
356
|
+
_push(`</div>`);
|
|
357
|
+
} else {
|
|
358
|
+
_push(`<!---->`);
|
|
359
|
+
}
|
|
360
|
+
_push(`</div>`);
|
|
361
|
+
}
|
|
362
|
+
const _sfc_setup$4 = _sfc_main$4.setup;
|
|
363
|
+
_sfc_main$4.setup = (props, ctx) => {
|
|
364
|
+
const ssrContext = useSSRContext();
|
|
365
|
+
(ssrContext.modules || (ssrContext.modules = /* @__PURE__ */ new Set())).add("src/components/Banner.vue");
|
|
366
|
+
return _sfc_setup$4 ? _sfc_setup$4(props, ctx) : void 0;
|
|
367
|
+
};
|
|
368
|
+
const Banner = /* @__PURE__ */ _export_sfc(_sfc_main$4, [["ssrRender", _sfc_ssrRender$4]]);
|
|
369
|
+
|
|
94
370
|
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
95
371
|
__name: "HeroSlider",
|
|
96
372
|
props: {
|
|
@@ -101,14 +377,17 @@ const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
|
101
377
|
__expose();
|
|
102
378
|
const props = __props;
|
|
103
379
|
const { parsedSlides } = useHeroSlider(props);
|
|
104
|
-
const __returned__ = { props, parsedSlides, Carousel, CarouselControl };
|
|
380
|
+
const __returned__ = { props, parsedSlides, Carousel, CarouselControl, Banner };
|
|
105
381
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
106
382
|
return __returned__;
|
|
107
383
|
}
|
|
108
384
|
});
|
|
109
385
|
function _sfc_ssrRender$3(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
|
|
110
386
|
_push(`<section${ssrRenderAttrs(mergeProps({ class: "relative mx-auto" }, _attrs))}>`);
|
|
111
|
-
_push(ssrRenderComponent($setup["Carousel"], {
|
|
387
|
+
_push(ssrRenderComponent($setup["Carousel"], {
|
|
388
|
+
autoplay: $props.autoplay,
|
|
389
|
+
class: "secondary [&>*]:items-center"
|
|
390
|
+
}, {
|
|
112
391
|
controls: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
113
392
|
if (_push2) {
|
|
114
393
|
_push2(`<div style="${ssrRenderStyle($setup.parsedSlides.length > 1 ? null : { display: "none" })}" class="absolute z-10 bottom-5 flex justify-end items-center w-screen right-5 xl:right-auto xl:max-w-screen-xl xl:left-1/2 xl:-ms-[640px]"${_scopeId}><div class="relative w-20 h-10 rounded-full bg-white/50 text-primary shadow-sm ring-1 ring-black/5"${_scopeId}>`);
|
|
@@ -170,38 +449,20 @@ function _sfc_ssrRender$3(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
170
449
|
if (_push2) {
|
|
171
450
|
_push2(`<!--[-->`);
|
|
172
451
|
ssrRenderList($setup.parsedSlides, (slide, i) => {
|
|
173
|
-
_push2(`<li class="shrink-0 basis-full
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
}),
|
|
188
|
-
_: 2
|
|
189
|
-
}), _parent2, _scopeId);
|
|
190
|
-
if (slide.subtitle) {
|
|
191
|
-
_push2(`<p class="text-lg mt-4 md:mt-6"${_scopeId}>${ssrInterpolate(slide.subtitle)}</p>`);
|
|
192
|
-
} else {
|
|
193
|
-
_push2(`<!---->`);
|
|
194
|
-
}
|
|
195
|
-
if (slide.buttonText) {
|
|
196
|
-
_push2(`<a${ssrRenderAttr("href", slide.buttonLink)} class="ui-btn-lg ui-btn-contrast min-w-[150px] mt-7 md:mt-10"${_scopeId}>${ssrInterpolate(slide.buttonText)}</a>`);
|
|
197
|
-
} else {
|
|
198
|
-
_push2(`<!---->`);
|
|
199
|
-
}
|
|
200
|
-
_push2(`</div>`);
|
|
201
|
-
} else {
|
|
202
|
-
_push2(`<!---->`);
|
|
203
|
-
}
|
|
204
|
-
_push2(`</div></li>`);
|
|
452
|
+
_push2(`<li class="shrink-0 basis-full"${_scopeId}>`);
|
|
453
|
+
_push2(ssrRenderComponent($setup["Banner"], mergeProps({ ...slide, headingTag: i === 0 ? "h2" : "h3" }, { class: "w-screen max-w-screen-2xl" }), {
|
|
454
|
+
picture: withCtx((_2, _push3, _parent3, _scopeId2) => {
|
|
455
|
+
if (_push3) {
|
|
456
|
+
ssrRenderSlot(_ctx.$slots, `picture-${i}`, {}, null, _push3, _parent3, _scopeId2);
|
|
457
|
+
} else {
|
|
458
|
+
return [
|
|
459
|
+
renderSlot(_ctx.$slots, `picture-${i}`)
|
|
460
|
+
];
|
|
461
|
+
}
|
|
462
|
+
}),
|
|
463
|
+
_: 2
|
|
464
|
+
}, _parent2, _scopeId));
|
|
465
|
+
_push2(`</li>`);
|
|
205
466
|
});
|
|
206
467
|
_push2(`<!--]-->`);
|
|
207
468
|
} else {
|
|
@@ -209,38 +470,14 @@ function _sfc_ssrRender$3(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
209
470
|
(openBlock(true), createBlock(Fragment, null, renderList($setup.parsedSlides, (slide, i) => {
|
|
210
471
|
return openBlock(), createBlock("li", {
|
|
211
472
|
key: i,
|
|
212
|
-
class: "shrink-0 basis-full
|
|
473
|
+
class: "shrink-0 basis-full"
|
|
213
474
|
}, [
|
|
214
|
-
createVNode("
|
|
215
|
-
|
|
216
|
-
}, [
|
|
217
|
-
createVNode("a", {
|
|
218
|
-
href: slide.href,
|
|
219
|
-
class: slide.hasHeader ? "basis-1/2 grow-0 md:order-last" : null
|
|
220
|
-
}, [
|
|
475
|
+
createVNode($setup["Banner"], mergeProps({ ...slide, headingTag: i === 0 ? "h2" : "h3" }, { class: "w-screen max-w-screen-2xl" }), {
|
|
476
|
+
picture: withCtx(() => [
|
|
221
477
|
renderSlot(_ctx.$slots, `picture-${i}`)
|
|
222
|
-
]
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
class: "basis-1/2 grow-0 p-12 xl:ps-32 mb-3 md:mb-0"
|
|
226
|
-
}, [
|
|
227
|
-
(openBlock(), createBlock(resolveDynamicComponent(i === 0 ? "h2" : "h3"), { class: "ui-title mt-1" }, {
|
|
228
|
-
default: withCtx(() => [
|
|
229
|
-
createTextVNode(toDisplayString(slide.title), 1)
|
|
230
|
-
]),
|
|
231
|
-
_: 2
|
|
232
|
-
}, 1024)),
|
|
233
|
-
slide.subtitle ? (openBlock(), createBlock("p", {
|
|
234
|
-
key: 0,
|
|
235
|
-
class: "text-lg mt-4 md:mt-6"
|
|
236
|
-
}, toDisplayString(slide.subtitle), 1)) : createCommentVNode("", true),
|
|
237
|
-
slide.buttonText ? (openBlock(), createBlock("a", {
|
|
238
|
-
key: 1,
|
|
239
|
-
href: slide.buttonLink,
|
|
240
|
-
class: "ui-btn-lg ui-btn-contrast min-w-[150px] mt-7 md:mt-10"
|
|
241
|
-
}, toDisplayString(slide.buttonText), 9, ["href"])) : createCommentVNode("", true)
|
|
242
|
-
])) : createCommentVNode("", true)
|
|
243
|
-
], 2)
|
|
478
|
+
]),
|
|
479
|
+
_: 2
|
|
480
|
+
}, 1040)
|
|
244
481
|
]);
|
|
245
482
|
}), 128))
|
|
246
483
|
];
|
|
@@ -258,158 +495,30 @@ _sfc_main$3.setup = (props, ctx) => {
|
|
|
258
495
|
};
|
|
259
496
|
const HeroSlider = /* @__PURE__ */ _export_sfc(_sfc_main$3, [["ssrRender", _sfc_ssrRender$3]]);
|
|
260
497
|
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
const
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
try {
|
|
275
|
-
const { data } = await api.get(`collections/${props.collectionId}`);
|
|
276
|
-
collection = data;
|
|
277
|
-
} catch (err) {
|
|
278
|
-
console.error(err);
|
|
279
|
-
fetchError.value = err;
|
|
280
|
-
}
|
|
281
|
-
const productIds = collection?.products;
|
|
282
|
-
if (Array.isArray(productIds) && productIds.length) {
|
|
283
|
-
searchQuery += `&_id=${productIds.slice(0, 60).join(",")}`;
|
|
284
|
-
}
|
|
285
|
-
if (!title.value && title.value !== null && collection?.name) {
|
|
286
|
-
title.value = collection?.name;
|
|
287
|
-
}
|
|
288
|
-
}
|
|
289
|
-
const limit = props.limit || 24;
|
|
290
|
-
const offset = props.page ? (props.page - 1) * limit : 0;
|
|
291
|
-
let endpointQuery = `offset=${offset}&limit=${limit}`;
|
|
292
|
-
if (props.sort) {
|
|
293
|
-
endpointQuery += `&sort=${props.sort}`;
|
|
294
|
-
}
|
|
295
|
-
endpointQuery += searchQuery;
|
|
296
|
-
try {
|
|
297
|
-
const { data } = await api.get(`search/v1?${endpointQuery}`);
|
|
298
|
-
if (props.isShuffle) {
|
|
299
|
-
let m = data.result.filter((item) => {
|
|
300
|
-
return item.available && inStock(item);
|
|
301
|
-
}).length;
|
|
302
|
-
let t;
|
|
303
|
-
let i;
|
|
304
|
-
while (m) {
|
|
305
|
-
i = Math.floor(Math.random() * m--);
|
|
306
|
-
t = data.result[m];
|
|
307
|
-
data.result[m] = data.result[i];
|
|
308
|
-
data.result[i] = t;
|
|
309
|
-
}
|
|
310
|
-
}
|
|
311
|
-
data.result.forEach((item) => products.push(item));
|
|
312
|
-
} catch (err) {
|
|
313
|
-
console.error(err);
|
|
314
|
-
fetchError.value = err;
|
|
315
|
-
}
|
|
316
|
-
isFetching.value = false;
|
|
317
|
-
})();
|
|
318
|
-
}
|
|
319
|
-
return {
|
|
320
|
-
title,
|
|
321
|
-
titleLink,
|
|
322
|
-
isFetching,
|
|
323
|
-
fetching,
|
|
324
|
-
fetchError,
|
|
325
|
-
products
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
|
|
329
|
-
const usePageSections = async ({ routeContext }) => {
|
|
330
|
-
const sectionsContent = routeContext.cmsContent?.sections;
|
|
331
|
-
const sections = [];
|
|
332
|
-
if (sectionsContent) {
|
|
333
|
-
await Promise.all(sectionsContent.map(async ({ type, ...sectionContent }) => {
|
|
334
|
-
if (type === "product-shelf") {
|
|
335
|
-
const {
|
|
336
|
-
collection_id: collectionIdAndInfo,
|
|
337
|
-
headless: isHeadless,
|
|
338
|
-
shuffle: isShuffle,
|
|
339
|
-
...rest
|
|
340
|
-
} = sectionContent;
|
|
341
|
-
let { sort, title } = sectionContent;
|
|
342
|
-
switch (sort) {
|
|
343
|
-
case "offers":
|
|
344
|
-
sort = "-price_discount";
|
|
345
|
-
break;
|
|
346
|
-
case "news":
|
|
347
|
-
sort = "-_id";
|
|
348
|
-
break;
|
|
349
|
-
case "lowest_price":
|
|
350
|
-
sort = "price";
|
|
351
|
-
break;
|
|
352
|
-
case "highest_price":
|
|
353
|
-
sort = "-price";
|
|
354
|
-
break;
|
|
355
|
-
}
|
|
356
|
-
let collectionId = null;
|
|
357
|
-
let searchQuery;
|
|
358
|
-
let titleLink;
|
|
359
|
-
if (collectionIdAndInfo) {
|
|
360
|
-
const [_id, resource, name, path] = collectionIdAndInfo.split(":");
|
|
361
|
-
collectionId = _id;
|
|
362
|
-
if (resource === "categories") {
|
|
363
|
-
searchQuery = `&categories._id=${_id}`;
|
|
364
|
-
} else if (resource === "brands") {
|
|
365
|
-
searchQuery = `&brands._id=${_id}`;
|
|
366
|
-
}
|
|
367
|
-
if (!title && title !== null && name) {
|
|
368
|
-
title = name;
|
|
369
|
-
}
|
|
370
|
-
titleLink = path;
|
|
371
|
-
}
|
|
372
|
-
const props = {
|
|
373
|
-
...rest,
|
|
374
|
-
collectionId,
|
|
375
|
-
searchQuery,
|
|
376
|
-
sort,
|
|
377
|
-
title: isHeadless ? null : title,
|
|
378
|
-
titleLink,
|
|
379
|
-
isShuffle
|
|
380
|
-
};
|
|
381
|
-
const { fetching, products } = useProductShelf(props);
|
|
382
|
-
await fetching;
|
|
383
|
-
sections.push({
|
|
384
|
-
type,
|
|
385
|
-
props: {
|
|
386
|
-
...rest,
|
|
387
|
-
collectionId,
|
|
388
|
-
searchQuery,
|
|
389
|
-
sort,
|
|
390
|
-
title: isHeadless ? null : title,
|
|
391
|
-
titleLink,
|
|
392
|
-
isShuffle,
|
|
393
|
-
products
|
|
394
|
-
}
|
|
395
|
-
});
|
|
396
|
-
}
|
|
397
|
-
}));
|
|
398
|
-
}
|
|
399
|
-
return {
|
|
400
|
-
sections
|
|
401
|
-
};
|
|
402
|
-
};
|
|
498
|
+
const $$Astro$4 = createAstro("https://ecom2-demo.web.app");
|
|
499
|
+
const $$BannersGrid = createComponent(async ($$result, $$props, $$slots) => {
|
|
500
|
+
const Astro2 = $$result.createAstro($$Astro$4, $$props, $$slots);
|
|
501
|
+
Astro2.self = $$BannersGrid;
|
|
502
|
+
const { banners } = Astro2.props;
|
|
503
|
+
return renderTemplate`${maybeRenderHead()}<section class="ui-section">
|
|
504
|
+
<ul class="flex flex-wrap lg:flex-nowrap gap-4">
|
|
505
|
+
${banners.map((banner) => renderTemplate`<li class="lg:flex-1 [&_img]:w-full [&_img]:object-cover">
|
|
506
|
+
${renderComponent($$result, "Banner", Banner, { ...banner }, { "picture": ($$result2) => renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { ...banner, "slot": "picture" })}` })}
|
|
507
|
+
</li>`)}
|
|
508
|
+
</ul>
|
|
509
|
+
</section>`;
|
|
510
|
+
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/components/BannersGrid.astro");
|
|
403
511
|
|
|
404
512
|
const useProductCard = (props) => {
|
|
405
513
|
const isFetching = ref(false);
|
|
406
514
|
let fetching = null;
|
|
407
515
|
const fetchError = ref(null);
|
|
516
|
+
const { productId } = props;
|
|
408
517
|
const product = shallowReactive({
|
|
409
518
|
...props.product,
|
|
519
|
+
_id: props.product?._id || productId,
|
|
410
520
|
price: price(props.product || {})
|
|
411
521
|
});
|
|
412
|
-
const { productId } = props;
|
|
413
522
|
if (!props.product && productId) {
|
|
414
523
|
isFetching.value = true;
|
|
415
524
|
fetching = (async () => {
|
|
@@ -442,13 +551,6 @@ const useProductCard = (props) => {
|
|
|
442
551
|
if (img$1)
|
|
443
552
|
_images.push(img$1);
|
|
444
553
|
});
|
|
445
|
-
} else {
|
|
446
|
-
const { picture } = product;
|
|
447
|
-
if (picture) {
|
|
448
|
-
const img$1 = img(picture);
|
|
449
|
-
if (img$1)
|
|
450
|
-
_images.push(img$1);
|
|
451
|
-
}
|
|
452
554
|
}
|
|
453
555
|
return _images;
|
|
454
556
|
});
|
|
@@ -465,6 +567,11 @@ const useProductCard = (props) => {
|
|
|
465
567
|
}
|
|
466
568
|
return 0;
|
|
467
569
|
});
|
|
570
|
+
const hasVariations = computed(() => {
|
|
571
|
+
if (product.has_variations)
|
|
572
|
+
return true;
|
|
573
|
+
return Boolean(product.variations?.length);
|
|
574
|
+
});
|
|
468
575
|
return {
|
|
469
576
|
isFetching,
|
|
470
577
|
fetching,
|
|
@@ -475,7 +582,8 @@ const useProductCard = (props) => {
|
|
|
475
582
|
images,
|
|
476
583
|
isInStock,
|
|
477
584
|
isActive,
|
|
478
|
-
discountPercentage
|
|
585
|
+
discountPercentage,
|
|
586
|
+
hasVariations
|
|
479
587
|
};
|
|
480
588
|
};
|
|
481
589
|
|
|
@@ -697,7 +805,7 @@ function _sfc_ssrRender$2(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
697
805
|
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
698
806
|
if (_push2) {
|
|
699
807
|
if ($setup.cashbackValue && $props.hasCashback) {
|
|
700
|
-
_push2(`<div class="relative z-10"${_scopeId}><span${ssrRenderAttr("data-tooltip", "Receba $1 de volta".replace("$1", _ctx.$percentage($setup.cashbackPercentage)))}${_scopeId}><i class="i-
|
|
808
|
+
_push2(`<div class="relative z-10"${_scopeId}><span${ssrRenderAttr("data-tooltip", "Receba $1 de volta".replace("$1", _ctx.$percentage($setup.cashbackPercentage)))}${_scopeId}><i class="i-arrow-uturn-left mr-1"${_scopeId}></i><span class="font-medium"${_scopeId}>${ssrInterpolate(_ctx.$money($setup.cashbackValue))}</span><small${_scopeId}> cashback</small></span></div>`);
|
|
701
809
|
} else {
|
|
702
810
|
_push2(`<!---->`);
|
|
703
811
|
}
|
|
@@ -710,7 +818,7 @@ function _sfc_ssrRender$2(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
710
818
|
createVNode("span", {
|
|
711
819
|
"data-tooltip": "Receba $1 de volta".replace("$1", _ctx.$percentage($setup.cashbackPercentage))
|
|
712
820
|
}, [
|
|
713
|
-
createVNode("i", { class: "i-
|
|
821
|
+
createVNode("i", { class: "i-arrow-uturn-left mr-1" }),
|
|
714
822
|
createVNode("span", { class: "font-medium" }, toDisplayString(_ctx.$money($setup.cashbackValue)), 1),
|
|
715
823
|
createVNode("small", null, " cashback")
|
|
716
824
|
], 8, ["data-tooltip"])
|
|
@@ -816,7 +924,11 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
816
924
|
product,
|
|
817
925
|
title,
|
|
818
926
|
link,
|
|
819
|
-
images
|
|
927
|
+
images,
|
|
928
|
+
isInStock,
|
|
929
|
+
isActive,
|
|
930
|
+
discountPercentage,
|
|
931
|
+
hasVariations
|
|
820
932
|
} = useProductCard({
|
|
821
933
|
product: props.product,
|
|
822
934
|
productId: props.productId
|
|
@@ -827,7 +939,9 @@ const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
|
827
939
|
watchOnce(isHovered, () => {
|
|
828
940
|
wasHoveredOnce.value = true;
|
|
829
941
|
});
|
|
830
|
-
const __returned__ = { props, product, title, link, images, card, isHovered, wasHoveredOnce,
|
|
942
|
+
const __returned__ = { props, product, title, link, images, isInStock, isActive, discountPercentage, hasVariations, card, isHovered, wasHoveredOnce, get addProductToCart() {
|
|
943
|
+
return addProductToCart;
|
|
944
|
+
}, Prices };
|
|
831
945
|
Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
|
|
832
946
|
return __returned__;
|
|
833
947
|
}
|
|
@@ -866,9 +980,18 @@ function _sfc_ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
866
980
|
} else {
|
|
867
981
|
_push2(`<div class="w-full h-full bg-gradient-to-br from-base-50/20 to-base-100"${_scopeId}></div>`);
|
|
868
982
|
}
|
|
869
|
-
_push2(`</div></div
|
|
983
|
+
_push2(`</div></div>`);
|
|
984
|
+
if ($setup.discountPercentage) {
|
|
985
|
+
_push2(`<span class="uno-bm03rg"${_scopeId}> -<strong${_scopeId}>${ssrInterpolate($setup.discountPercentage)}</strong>% </span>`);
|
|
986
|
+
} else {
|
|
987
|
+
_push2(`<!---->`);
|
|
988
|
+
}
|
|
989
|
+
_push2(`<div class="relative flex flex-col grow justify-between p-4 group-hover:backdrop-blur-md bg-white/40 z-10"${_scopeId}>`);
|
|
870
990
|
ssrRenderVNode(_push2, createVNode(resolveDynamicComponent($props.headingTag), {
|
|
871
|
-
class: ["ui-link
|
|
991
|
+
class: ["ui-link no-underline line-clamp-2", [
|
|
992
|
+
$setup.isActive ? "text-base-700" : "text-base-500",
|
|
993
|
+
$setup.link ? "group-hover:underline group-hover:text-primary" : null
|
|
994
|
+
]]
|
|
872
995
|
}, {
|
|
873
996
|
default: withCtx((_2, _push3, _parent3, _scopeId2) => {
|
|
874
997
|
if (_push3) {
|
|
@@ -882,8 +1005,20 @@ function _sfc_ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
882
1005
|
_: 1
|
|
883
1006
|
}), _parent2, _scopeId);
|
|
884
1007
|
_push2(`<div class="pt-2"${_scopeId}>`);
|
|
885
|
-
|
|
886
|
-
|
|
1008
|
+
if ($setup.isActive) {
|
|
1009
|
+
_push2(`<div${_scopeId}>`);
|
|
1010
|
+
_push2(ssrRenderComponent($setup["Prices"], { product: $setup.product }, null, _parent2, _scopeId));
|
|
1011
|
+
_push2(`</div>`);
|
|
1012
|
+
} else {
|
|
1013
|
+
_push2(`<span class="ui-badge bg-warning-100 text-warning-700"${_scopeId}>${ssrInterpolate(!$setup.isInStock ? "Sem estoque" : "Inativo")}</span>`);
|
|
1014
|
+
}
|
|
1015
|
+
_push2(`</div>`);
|
|
1016
|
+
if ($setup.isActive && !$setup.hasVariations) {
|
|
1017
|
+
_push2(`<button class="uno-3suct9 ui-btn-sm ui-btn-primary"${_scopeId}><i class="i-plus-20-solid mr-0.5"${_scopeId}></i> ${ssrInterpolate("Adicionar ao carrinho")}</button>`);
|
|
1018
|
+
} else {
|
|
1019
|
+
_push2(`<!---->`);
|
|
1020
|
+
}
|
|
1021
|
+
_push2(`</div>`);
|
|
887
1022
|
} else {
|
|
888
1023
|
return [
|
|
889
1024
|
createVNode("div", { class: "aspect-square p-2 motion-safe:group-hover:scale-110 transition-transform" }, [
|
|
@@ -906,9 +1041,20 @@ function _sfc_ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
906
1041
|
}))
|
|
907
1042
|
])
|
|
908
1043
|
]),
|
|
909
|
-
|
|
1044
|
+
$setup.discountPercentage ? (openBlock(), createBlock("span", {
|
|
1045
|
+
key: 0,
|
|
1046
|
+
class: "uno-bm03rg"
|
|
1047
|
+
}, [
|
|
1048
|
+
createTextVNode(" -"),
|
|
1049
|
+
createVNode("strong", null, toDisplayString($setup.discountPercentage), 1),
|
|
1050
|
+
createTextVNode("% ")
|
|
1051
|
+
])) : createCommentVNode("", true),
|
|
1052
|
+
createVNode("div", { class: "relative flex flex-col grow justify-between p-4 group-hover:backdrop-blur-md bg-white/40 z-10" }, [
|
|
910
1053
|
(openBlock(), createBlock(resolveDynamicComponent($props.headingTag), {
|
|
911
|
-
class: ["ui-link
|
|
1054
|
+
class: ["ui-link no-underline line-clamp-2", [
|
|
1055
|
+
$setup.isActive ? "text-base-700" : "text-base-500",
|
|
1056
|
+
$setup.link ? "group-hover:underline group-hover:text-primary" : null
|
|
1057
|
+
]]
|
|
912
1058
|
}, {
|
|
913
1059
|
default: withCtx(() => [
|
|
914
1060
|
createTextVNode(toDisplayString($setup.title), 1)
|
|
@@ -916,8 +1062,21 @@ function _sfc_ssrRender$1(_ctx, _push, _parent, _attrs, $props, $setup, $data, $
|
|
|
916
1062
|
_: 1
|
|
917
1063
|
}, 8, ["class"])),
|
|
918
1064
|
createVNode("div", { class: "pt-2" }, [
|
|
919
|
-
|
|
920
|
-
|
|
1065
|
+
$setup.isActive ? (openBlock(), createBlock("div", { key: 0 }, [
|
|
1066
|
+
createVNode($setup["Prices"], { product: $setup.product }, null, 8, ["product"])
|
|
1067
|
+
])) : (openBlock(), createBlock("span", {
|
|
1068
|
+
key: 1,
|
|
1069
|
+
class: "ui-badge bg-warning-100 text-warning-700"
|
|
1070
|
+
}, toDisplayString(!$setup.isInStock ? "Sem estoque" : "Inativo"), 1))
|
|
1071
|
+
]),
|
|
1072
|
+
$setup.isActive && !$setup.hasVariations ? (openBlock(), createBlock("button", {
|
|
1073
|
+
key: 0,
|
|
1074
|
+
class: "uno-3suct9 ui-btn-sm ui-btn-primary",
|
|
1075
|
+
onClick: withModifiers(($event) => $setup.addProductToCart($setup.product), ["prevent"])
|
|
1076
|
+
}, [
|
|
1077
|
+
createVNode("i", { class: "i-plus-20-solid mr-0.5" }),
|
|
1078
|
+
createTextVNode(" " + toDisplayString("Adicionar ao carrinho"))
|
|
1079
|
+
], 8, ["onClick"])) : createCommentVNode("", true)
|
|
921
1080
|
])
|
|
922
1081
|
];
|
|
923
1082
|
}
|
|
@@ -967,11 +1126,14 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
|
967
1126
|
});
|
|
968
1127
|
function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $options) {
|
|
969
1128
|
const _component_ALink = resolveComponent("ALink");
|
|
970
|
-
_push(`<section${ssrRenderAttrs(mergeProps({ class: "
|
|
1129
|
+
_push(`<section${ssrRenderAttrs(mergeProps({ class: "ui-section" }, _attrs))}>`);
|
|
971
1130
|
if ($setup.title) {
|
|
972
|
-
_push(`<h2>`);
|
|
1131
|
+
_push(`<div class="max-w-prose mx-auto text-center mb-2"><h2 class="ui-text-brand text-3xl">`);
|
|
973
1132
|
if ($setup.titleLink) {
|
|
974
|
-
_push(ssrRenderComponent(_component_ALink, {
|
|
1133
|
+
_push(ssrRenderComponent(_component_ALink, {
|
|
1134
|
+
href: $setup.titleLink,
|
|
1135
|
+
class: "ui-link"
|
|
1136
|
+
}, {
|
|
975
1137
|
default: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
976
1138
|
if (_push2) {
|
|
977
1139
|
_push2(`${ssrInterpolate($setup.title)}`);
|
|
@@ -984,30 +1146,30 @@ function _sfc_ssrRender(_ctx, _push, _parent, _attrs, $props, $setup, $data, $op
|
|
|
984
1146
|
_: 1
|
|
985
1147
|
}, _parent));
|
|
986
1148
|
} else {
|
|
987
|
-
_push(
|
|
1149
|
+
_push(`<span class="text-base-700">${ssrInterpolate($setup.title)}</span>`);
|
|
988
1150
|
}
|
|
989
|
-
_push(`</h2>`);
|
|
1151
|
+
_push(`</h2></div>`);
|
|
990
1152
|
} else {
|
|
991
1153
|
_push(`<!---->`);
|
|
992
1154
|
}
|
|
993
1155
|
_push(ssrRenderComponent($setup["Carousel"], { class: "group/shelf" }, {
|
|
994
1156
|
controls: withCtx((_, _push2, _parent2, _scopeId) => {
|
|
995
1157
|
if (_push2) {
|
|
996
|
-
_push2(`<div style="${ssrRenderStyle($setup.products.length > 2 ? null : { display: "none" })}" class="text-3xl lg:text-
|
|
1158
|
+
_push2(`<div style="${ssrRenderStyle($setup.products.length > 2 ? null : { display: "none" })}" class="text-3xl lg:text-2xl leading-none text-primary lg:opacity-0 group-hover/shelf:opacity-90 transition-opacity"${_scopeId}>`);
|
|
997
1159
|
_push2(ssrRenderComponent($setup["CarouselControl"], {
|
|
998
|
-
class: "!top-1/2
|
|
1160
|
+
class: "!top-1/2 !-left-4 w-12 h-12 bg-transparent lg:bg-white/80 lg:hover:bg-primary-300/60 rounded-full lg:shadow-sm lg:ring-1 ring-black/5",
|
|
999
1161
|
"is-prev": ""
|
|
1000
1162
|
}, null, _parent2, _scopeId));
|
|
1001
|
-
_push2(ssrRenderComponent($setup["CarouselControl"], { class: "!top-1/2
|
|
1163
|
+
_push2(ssrRenderComponent($setup["CarouselControl"], { class: "!top-1/2 !-right-4 w-12 h-12 bg-transparent lg:bg-white/80 lg:hover:bg-primary-300/60 rounded-full lg:shadow-sm lg:ring-1 ring-black/5" }, null, _parent2, _scopeId));
|
|
1002
1164
|
_push2(`</div>`);
|
|
1003
1165
|
} else {
|
|
1004
1166
|
return [
|
|
1005
|
-
withDirectives(createVNode("div", { class: "text-3xl lg:text-
|
|
1167
|
+
withDirectives(createVNode("div", { class: "text-3xl lg:text-2xl leading-none text-primary lg:opacity-0 group-hover/shelf:opacity-90 transition-opacity" }, [
|
|
1006
1168
|
createVNode($setup["CarouselControl"], {
|
|
1007
|
-
class: "!top-1/2
|
|
1169
|
+
class: "!top-1/2 !-left-4 w-12 h-12 bg-transparent lg:bg-white/80 lg:hover:bg-primary-300/60 rounded-full lg:shadow-sm lg:ring-1 ring-black/5",
|
|
1008
1170
|
"is-prev": ""
|
|
1009
1171
|
}),
|
|
1010
|
-
createVNode($setup["CarouselControl"], { class: "!top-1/2
|
|
1172
|
+
createVNode($setup["CarouselControl"], { class: "!top-1/2 !-right-4 w-12 h-12 bg-transparent lg:bg-white/80 lg:hover:bg-primary-300/60 rounded-full lg:shadow-sm lg:ring-1 ring-black/5" })
|
|
1011
1173
|
], 512), [
|
|
1012
1174
|
[vShow, $setup.products.length > 2]
|
|
1013
1175
|
])
|
|
@@ -1059,6 +1221,8 @@ const $$Sections = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
1059
1221
|
switch (type) {
|
|
1060
1222
|
case "product-shelf":
|
|
1061
1223
|
return renderTemplate`${renderComponent($$result, "ProductShelf", ProductShelf, { ...props, "client:visible": true, "client:component-hydration": "visible", "client:component-path": "~/components/ProductShelf.vue", "client:component-export": "default" })}`;
|
|
1224
|
+
case "banners-grid":
|
|
1225
|
+
return renderTemplate`${renderComponent($$result, "BannersGrid", $$BannersGrid, { ...props })}`;
|
|
1062
1226
|
default:
|
|
1063
1227
|
return renderTemplate`<div${addAttribute(type, "data-section")}></div>`;
|
|
1064
1228
|
}
|
|
@@ -1073,51 +1237,9 @@ const $$Home = createComponent(async ($$result, $$props, $$slots) => {
|
|
|
1073
1237
|
const { routeContext } = Astro2.locals;
|
|
1074
1238
|
const { heroSlider } = await usePageHero({ routeContext });
|
|
1075
1239
|
const heroSlides = heroSlider.slides;
|
|
1076
|
-
const products = (await api.get("products")).data.result;
|
|
1077
1240
|
return renderTemplate`${maybeRenderHead()}<main>
|
|
1078
|
-
${heroSlider.slides.length && renderTemplate`${renderComponent($$result, "HeroSlider", HeroSlider, { ...heroSlider, "client:load": true, "client:component-hydration": "load", "client:component-path": "~/components/HeroSlider.vue", "client:component-export": "default" }, { "picture-0": ($$result2) => renderTemplate`${heroSlides[0] && renderTemplate`${renderComponent($$result2, "
|
|
1241
|
+
${heroSlider.slides.length && renderTemplate`${renderComponent($$result, "HeroSlider", HeroSlider, { ...heroSlider, "client:load": true, "client:component-hydration": "load", "client:component-path": "~/components/HeroSlider.vue", "client:component-export": "default" }, { "picture-0": ($$result2) => renderTemplate`${heroSlides[0] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-0", ...heroSlides[0], "index": 0 })}`}`, "picture-1": ($$result2) => renderTemplate`${heroSlides[1] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-1", ...heroSlides[1], "index": 1 })}`}`, "picture-2": ($$result2) => renderTemplate`${heroSlides[2] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-2", ...heroSlides[2], "index": 2 })}`}`, "picture-3": ($$result2) => renderTemplate`${heroSlides[3] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-3", ...heroSlides[3], "index": 3 })}`}`, "picture-4": ($$result2) => renderTemplate`${heroSlides[4] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-4", ...heroSlides[4], "index": 4 })}`}`, "picture-5": ($$result2) => renderTemplate`${heroSlides[5] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-5", ...heroSlides[5], "index": 5 })}`}`, "picture-6": ($$result2) => renderTemplate`${heroSlides[6] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-6", ...heroSlides[6], "index": 6 })}`}`, "picture-7": ($$result2) => renderTemplate`${heroSlides[7] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-7", ...heroSlides[7], "index": 7 })}`}`, "picture-8": ($$result2) => renderTemplate`${heroSlides[8] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-8", ...heroSlides[8], "index": 8 })}`}`, "picture-9": ($$result2) => renderTemplate`${heroSlides[9] && renderTemplate`${renderComponent($$result2, "BannerPictures", $$BannerPictures, { "slot": "picture-9", ...heroSlides[9], "index": 9 })}`}` })}`}
|
|
1079
1242
|
${renderComponent($$result, "Sections", $$Sections, {})}
|
|
1080
|
-
|
|
1081
|
-
<h1>Welcome to <span class="text-primary">Astro</span></h1>
|
|
1082
|
-
<ul role="list" class="mt-3 fs-20">
|
|
1083
|
-
${products.map((product) => renderTemplate`<li>
|
|
1084
|
-
<a${addAttribute(`/${product.slug}`, "href")}>${product.sku}</a>
|
|
1085
|
-
</li>`)}
|
|
1086
|
-
</ul>
|
|
1087
|
-
<div class="prose">
|
|
1088
|
-
<h1>Oi</h1>
|
|
1089
|
-
<p>Olá <a href="/">link</a></p>
|
|
1090
|
-
<ul>
|
|
1091
|
-
<li>So here is the first item in this list.</li>
|
|
1092
|
-
<li>In this example we're keeping the items short.</li>
|
|
1093
|
-
<li>Later, we'll use longer, more complex list items.</li>
|
|
1094
|
-
</ul>
|
|
1095
|
-
<details>
|
|
1096
|
-
<summary role="button">Accordion 1</summary>
|
|
1097
|
-
<p>…</p>
|
|
1098
|
-
</details>
|
|
1099
|
-
</div>
|
|
1100
|
-
<div>
|
|
1101
|
-
<h1>Oi</h1>
|
|
1102
|
-
<p>Olá <a href="/">link</a></p>
|
|
1103
|
-
<details>
|
|
1104
|
-
<summary role="button">Accordion 1</summary>
|
|
1105
|
-
<p>…</p>
|
|
1106
|
-
</details>
|
|
1107
|
-
</div>
|
|
1108
|
-
<div class="mt-2">
|
|
1109
|
-
<div>
|
|
1110
|
-
<label class="block">
|
|
1111
|
-
<span class="text-gray-700">Email address</span>
|
|
1112
|
-
<input type="email" class="mt-1 block w-full" placeholder="john@example.com">
|
|
1113
|
-
</label>
|
|
1114
|
-
<label class="inline-flex items-center">
|
|
1115
|
-
<input type="checkbox" checked>
|
|
1116
|
-
<span class="ml-2 font-brand">Email me news and special offers</span>
|
|
1117
|
-
</label>
|
|
1118
|
-
</div>
|
|
1119
|
-
</div>
|
|
1120
|
-
${renderComponent($$result, "Prices", Prices, { "price": 10, "client:load": true, "client:component-hydration": "load", "client:component-path": "~/components/Prices.vue", "client:component-export": "default" })}
|
|
1121
1243
|
</main>`;
|
|
1122
1244
|
}, "/home/leo/code/ecomplus/cloud-commerce/packages/storefront/src/main/Home.astro");
|
|
1123
1245
|
|