basklee-nuxt 0.9.10 → 0.9.11
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/README.md +1 -1
- package/package.json +1 -1
- package/templates/app/components/basklee/products/StorefrontProduct.README.md +2 -0
- package/templates/app/components/basklee/products/StorefrontProduct.vue +62 -15
- package/templates/app/utils/basklee/productGallery.ts +37 -0
- package/templates/app/utils/basklee/reviewLabels.ts +3 -0
package/README.md
CHANGED
|
@@ -201,7 +201,7 @@ Product details, saved items and the cart.
|
|
|
201
201
|
|
|
202
202
|
| Component | Name | What it does |
|
|
203
203
|
| --- | --- | --- |
|
|
204
|
-
| **Product details** | `StorefrontProduct` | Loads and displays a published product or a secret-key preview with images, purchase choices, details and reviews. |
|
|
204
|
+
| **Product details** | `StorefrontProduct` | Loads and displays a published product or a secret-key preview with images and videos, purchase choices, details and reviews. |
|
|
205
205
|
| **Page path** | `BaskleeBreadcrumbs` | Linked path from the storefront home page through parent categories to the current page. |
|
|
206
206
|
| **Product characteristics** | `ProductSpecificationsDialog` | Every characteristic of the product in a dialog over the page. |
|
|
207
207
|
| **Product reviews** | `ProductReviews` | Reviews, replies, ratings and the user’s submissions. |
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "basklee-nuxt",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.11",
|
|
4
4
|
"description": "Nuxt 4 storefront for your Basklee marketplace: setup CLI, server API gateway, typed store and ready-made catalog, cart, checkout and account components in English, Russian and Spanish, plus an Android app build. Powered by Basklee: https://basklee.com",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -20,6 +20,8 @@ Above the gallery and the purchase column, `BaskleeBreadcrumbs` shows the path t
|
|
|
20
20
|
|
|
21
21
|
The gallery uses `product.images.full`, falling back to `product.images.small` when empty. On wide screens the thumbnails form a column as tall as the main image beside it; on narrow screens they form a row below it. The strip has no scrollbar: when more thumbnails exist than fit, arrow buttons at its ends move it by one thumbnail, and each button disappears at the first or last position. The selected thumbnail has a dark border and scrolls into view when the photo changes. The thumbnails are one keyboard stop: arrow keys select the previous or next photo, Home and End the first and last. The previous and next buttons over the main image cycle through the photos. A tap, click or Enter on the main image opens the photos in `ProductReviewImageViewer`; the photo chosen there stays selected on the page.
|
|
22
22
|
|
|
23
|
+
The product's videos (`product.videos`, uploaded on the Video tab of the panel) follow the photos in the same gallery, in the order the backend sends them; a video without a file is left out. A video's thumbnail shows its `preview` frame under a round play mark and is labelled Product video. Choosing it puts a `<video>` with the browser's controls in the main image's place (`preload="metadata"`, `playsinline`, the preview as the poster, never playing by itself); choosing another item stops it. The previous and next buttons, swipes and thumbnail keys go through photos and videos alike; the full-screen viewer shows the photos only. A product with a video and no photo shows the gallery with that video.
|
|
24
|
+
|
|
23
25
|
On wide screens the gallery and the purchase column end at the same height: the taller of the two sets it, and the photo area takes the whole height with the photo centred in it at its own proportions, never stretched or cropped. When the purchase column is short, the photo area keeps a height that still shows the photo.
|
|
24
26
|
|
|
25
27
|
Beside the gallery, the purchase column keeps its place in the layout and scrolls with the page. It shows the product name and, when `feedback_stat.c_feedbacks` is positive, the average `feedback_stat.avg_raiting` with the review count as a link to the reviews section. Below it, `ProductCard` in `details` mode shows the badges and price, then About this product and Characteristics, then the selected main variant as “variant name: value”, the variant choices, the stock notice and the actions. Changing the variant updates the gallery, heading, description, characteristics and reviews.
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
import { safeArticleHtml } from '@/utils/basklee/richText';
|
|
35
35
|
import { htmlTextParagraphs } from '@/utils/basklee/htmlText';
|
|
36
36
|
import {
|
|
37
|
+
productMediaItems,
|
|
37
38
|
thumbnailKeyTarget,
|
|
38
39
|
thumbnailRailEdges,
|
|
39
40
|
thumbnailScrollTarget,
|
|
@@ -178,6 +179,13 @@
|
|
|
178
179
|
const images = product.value?.images;
|
|
179
180
|
return images?.full?.length ? images.full : (images?.small ?? []);
|
|
180
181
|
});
|
|
182
|
+
// The gallery: the photos, then the product's videos (Video tab of the
|
|
183
|
+
// panel). A video plays in the large photo's place; the full-screen viewer
|
|
184
|
+
// keeps to the photos, which come first, so their numbers are the same.
|
|
185
|
+
const media = computed(() => productMediaItems(product.value));
|
|
186
|
+
const current = computed(
|
|
187
|
+
() => media.value[image.value] ?? media.value[0],
|
|
188
|
+
);
|
|
181
189
|
// The first request in the browser shows a placeholder with the page
|
|
182
190
|
// layout; a later retry after an error shows it again. A product loaded
|
|
183
191
|
// during the server render is shown at once.
|
|
@@ -503,7 +511,7 @@
|
|
|
503
511
|
}
|
|
504
512
|
|
|
505
513
|
function showImage(index: number) {
|
|
506
|
-
const count =
|
|
514
|
+
const count = media.value.length;
|
|
507
515
|
image.value = (index + count) % count;
|
|
508
516
|
}
|
|
509
517
|
|
|
@@ -530,7 +538,7 @@
|
|
|
530
538
|
showImage(
|
|
531
539
|
productPhotoAfterSwipe(
|
|
532
540
|
image.value,
|
|
533
|
-
|
|
541
|
+
media.value.length,
|
|
534
542
|
touch.clientX - start.x,
|
|
535
543
|
touch.clientY - start.y,
|
|
536
544
|
),
|
|
@@ -641,7 +649,7 @@
|
|
|
641
649
|
|
|
642
650
|
// Arrow keys, Home and End move between thumbnails, which form one tab stop.
|
|
643
651
|
function thumbnailKeydown(event: KeyboardEvent, index: number) {
|
|
644
|
-
const target = thumbnailKeyTarget(event.key, index,
|
|
652
|
+
const target = thumbnailKeyTarget(event.key, index, media.value.length);
|
|
645
653
|
|
|
646
654
|
if (target === undefined) {
|
|
647
655
|
return;
|
|
@@ -784,7 +792,7 @@
|
|
|
784
792
|
revealThumbnail(index);
|
|
785
793
|
});
|
|
786
794
|
// Another variant's photos start from the first thumbnail.
|
|
787
|
-
watch(
|
|
795
|
+
watch(media, async () => {
|
|
788
796
|
await nextTick();
|
|
789
797
|
|
|
790
798
|
if (rail.value) {
|
|
@@ -840,20 +848,41 @@
|
|
|
840
848
|
class="grid items-start gap-8 @min-[960px]/product:grid-cols-[minmax(0,7fr)_minmax(0,5fr)] @min-[960px]/product:items-stretch @min-[960px]/product:gap-x-12 @min-[1200px]/product:gap-x-20"
|
|
841
849
|
>
|
|
842
850
|
<section
|
|
843
|
-
v-if="
|
|
851
|
+
v-if="media.length"
|
|
844
852
|
class="grid min-w-0 gap-3 @min-[560px]/product:grid-cols-[72px_minmax(0,1fr)] @min-[560px]/product:gap-4 @min-[960px]/product:col-start-1 @min-[960px]/product:row-start-1"
|
|
845
853
|
:aria-label="labels.gallery"
|
|
846
854
|
data-product-gallery
|
|
847
855
|
>
|
|
848
856
|
<div
|
|
849
857
|
class="relative min-w-0 @min-[560px]/product:col-start-2 @min-[560px]/product:row-start-1 @min-[960px]/product:min-h-96"
|
|
850
|
-
:class="{ 'touch-pan-y':
|
|
858
|
+
:class="{ 'touch-pan-y': media.length > 1 }"
|
|
851
859
|
data-product-main-image
|
|
852
860
|
@touchstart.passive="startSwipe"
|
|
853
861
|
@touchend="endSwipe"
|
|
854
862
|
>
|
|
863
|
+
<video
|
|
864
|
+
v-if="current?.kind === 'video'"
|
|
865
|
+
:key="current.key"
|
|
866
|
+
:src="current.src"
|
|
867
|
+
:poster="current.preview || undefined"
|
|
868
|
+
:aria-label="labels.productVideo"
|
|
869
|
+
controls
|
|
870
|
+
playsinline
|
|
871
|
+
preload="metadata"
|
|
872
|
+
data-product-video
|
|
873
|
+
class="
|
|
874
|
+
box-border aspect-square h-auto max-h-[70vh] w-full
|
|
875
|
+
bg-basklee-surface object-contain
|
|
876
|
+
@min-[560px]/product:aspect-[4/5]
|
|
877
|
+
@min-[960px]/product:absolute @min-[960px]/product:inset-0
|
|
878
|
+
@min-[960px]/product:m-auto @min-[960px]/product:aspect-auto
|
|
879
|
+
@min-[960px]/product:h-full
|
|
880
|
+
@min-[960px]/product:max-h-[calc(100vh-12rem)]
|
|
881
|
+
"
|
|
882
|
+
/>
|
|
855
883
|
<BaskleeImage
|
|
856
|
-
|
|
884
|
+
v-else-if="current"
|
|
885
|
+
:src="current.src"
|
|
857
886
|
:alt="title"
|
|
858
887
|
:width="800"
|
|
859
888
|
:height="1000"
|
|
@@ -877,7 +906,7 @@
|
|
|
877
906
|
@min-[960px]/product:max-h-[calc(100vh-12rem)]
|
|
878
907
|
"
|
|
879
908
|
/>
|
|
880
|
-
<template v-if="
|
|
909
|
+
<template v-if="media.length > 1">
|
|
881
910
|
<button
|
|
882
911
|
type="button"
|
|
883
912
|
class="absolute left-2 top-1/2 -translate-y-1/2 grid h-10 w-10 place-items-center rounded-full p-0 cursor-pointer border border-solid border-basklee-border bg-basklee-surface/90 text-basklee-text outline-none transition-colors motion-reduce:transition-none hover:border-basklee-text focus-visible:border-basklee-text"
|
|
@@ -917,7 +946,7 @@
|
|
|
917
946
|
</template>
|
|
918
947
|
</div>
|
|
919
948
|
<div
|
|
920
|
-
v-if="
|
|
949
|
+
v-if="media.length > 1"
|
|
921
950
|
class="relative min-w-0 @min-[560px]/product:col-start-1 @min-[560px]/product:row-start-1 @min-[560px]/product:h-0 @min-[560px]/product:min-h-full"
|
|
922
951
|
data-product-thumbnail-rail
|
|
923
952
|
>
|
|
@@ -928,27 +957,45 @@
|
|
|
928
957
|
@scroll.passive="updateRail"
|
|
929
958
|
>
|
|
930
959
|
<button
|
|
931
|
-
v-for="(
|
|
932
|
-
:key="
|
|
960
|
+
v-for="(item, index) in media"
|
|
961
|
+
:key="item.key"
|
|
933
962
|
type="button"
|
|
934
|
-
class="box-border h-[70px] w-14 shrink-0 p-1 @min-[560px]/product:h-[90px] @min-[560px]/product:w-[72px] cursor-pointer border border-solid bg-basklee-surface outline-none transition-[opacity,border-color] motion-reduce:transition-none hover:opacity-100 focus-visible:border-2 focus-visible:border-basklee-text"
|
|
963
|
+
class="relative box-border h-[70px] w-14 shrink-0 p-1 @min-[560px]/product:h-[90px] @min-[560px]/product:w-[72px] cursor-pointer border border-solid bg-basklee-surface outline-none transition-[opacity,border-color] motion-reduce:transition-none hover:opacity-100 focus-visible:border-2 focus-visible:border-basklee-text"
|
|
935
964
|
:class="
|
|
936
965
|
index === image
|
|
937
966
|
? 'border-basklee-text opacity-100'
|
|
938
967
|
: 'border-transparent opacity-75'
|
|
939
968
|
"
|
|
940
|
-
:aria-label="`${labels.gallery} ${index + 1}`"
|
|
969
|
+
:aria-label="`${item.kind === 'video' ? labels.productVideo : labels.gallery} ${index + 1}`"
|
|
941
970
|
:aria-pressed="index === image"
|
|
942
971
|
:tabindex="index === image ? 0 : -1"
|
|
943
972
|
:data-product-thumbnail="index"
|
|
973
|
+
:data-product-thumbnail-video="item.kind === 'video' || undefined"
|
|
944
974
|
@click="image = index"
|
|
945
975
|
@keydown="thumbnailKeydown($event, index)"
|
|
946
976
|
>
|
|
947
977
|
<BaskleeImage
|
|
948
|
-
|
|
978
|
+
v-if="item.kind === 'image' || item.preview"
|
|
979
|
+
:src="item.kind === 'image' ? item.src : (item.preview as string)"
|
|
949
980
|
alt=""
|
|
950
|
-
class="h-full w-full
|
|
981
|
+
class="h-full w-full"
|
|
982
|
+
:class="item.kind === 'image' ? 'object-contain' : 'object-cover'"
|
|
951
983
|
/>
|
|
984
|
+
<span
|
|
985
|
+
v-if="item.kind === 'video'"
|
|
986
|
+
class="absolute inset-0 m-auto grid h-7 w-7 place-items-center rounded-full bg-basklee-text/80 text-basklee-surface"
|
|
987
|
+
aria-hidden="true"
|
|
988
|
+
data-product-video-mark
|
|
989
|
+
>
|
|
990
|
+
<svg
|
|
991
|
+
viewBox="0 0 24 24"
|
|
992
|
+
class="ml-0.5 h-3.5 w-3.5"
|
|
993
|
+
fill="currentColor"
|
|
994
|
+
aria-hidden="true"
|
|
995
|
+
>
|
|
996
|
+
<path d="M8 5v14l11-7z" />
|
|
997
|
+
</svg>
|
|
998
|
+
</span>
|
|
952
999
|
</button>
|
|
953
1000
|
</div>
|
|
954
1001
|
<button
|
|
@@ -70,3 +70,40 @@ export function thumbnailKeyTarget(
|
|
|
70
70
|
|
|
71
71
|
return undefined;
|
|
72
72
|
}
|
|
73
|
+
|
|
74
|
+
export type ProductMediaItem =
|
|
75
|
+
| { kind: 'image'; key: string; src: string }
|
|
76
|
+
| { kind: 'video'; key: string; src: string; preview: string | null };
|
|
77
|
+
|
|
78
|
+
export interface IProductMediaSources {
|
|
79
|
+
images?: { full?: string[] | null; small?: string[] | null } | null;
|
|
80
|
+
videos?:
|
|
81
|
+
| { id: number; product_video: string | null; preview: string | null }[]
|
|
82
|
+
| null;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
// The pictures and videos of a product in the order its gallery shows them:
|
|
86
|
+
// the full images first (the small copies when it has none), then the videos
|
|
87
|
+
// in the order the backend sends them. A video without a file is left out.
|
|
88
|
+
export function productMediaItems(
|
|
89
|
+
product: IProductMediaSources | null | undefined,
|
|
90
|
+
): ProductMediaItem[] {
|
|
91
|
+
const images = product?.images;
|
|
92
|
+
const photos = images?.full?.length ? images.full : (images?.small ?? []);
|
|
93
|
+
const items = photos.map(
|
|
94
|
+
(src, index): ProductMediaItem => ({ kind: 'image', key: `image-${index}`, src }),
|
|
95
|
+
);
|
|
96
|
+
|
|
97
|
+
for (const video of product?.videos ?? []) {
|
|
98
|
+
if (video.product_video) {
|
|
99
|
+
items.push({
|
|
100
|
+
kind: 'video',
|
|
101
|
+
key: `video-${video.id}`,
|
|
102
|
+
src: video.product_video,
|
|
103
|
+
preview: video.preview,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
return items;
|
|
109
|
+
}
|
|
@@ -52,6 +52,7 @@ const en = {
|
|
|
52
52
|
zoomIn: 'Show at full size',
|
|
53
53
|
zoomOut: 'Fit to screen',
|
|
54
54
|
nextImage: 'Next image',
|
|
55
|
+
productVideo: 'Product video',
|
|
55
56
|
thumbnailsBack: 'Show previous thumbnails',
|
|
56
57
|
thumbnailsForward: 'Show next thumbnails',
|
|
57
58
|
characteristics: 'Characteristics',
|
|
@@ -133,6 +134,7 @@ const ru: typeof en = {
|
|
|
133
134
|
zoomIn: 'Показать в полный размер',
|
|
134
135
|
zoomOut: 'Вписать в экран',
|
|
135
136
|
nextImage: 'Следующая фотография',
|
|
137
|
+
productVideo: 'Видео товара',
|
|
136
138
|
thumbnailsBack: 'Показать предыдущие миниатюры',
|
|
137
139
|
thumbnailsForward: 'Показать следующие миниатюры',
|
|
138
140
|
characteristics: 'Характеристики',
|
|
@@ -215,6 +217,7 @@ const es: typeof en = {
|
|
|
215
217
|
zoomIn: 'Ver a tamaño completo',
|
|
216
218
|
zoomOut: 'Ajustar a la pantalla',
|
|
217
219
|
nextImage: 'Imagen siguiente',
|
|
220
|
+
productVideo: 'Vídeo del producto',
|
|
218
221
|
thumbnailsBack: 'Ver miniaturas anteriores',
|
|
219
222
|
thumbnailsForward: 'Ver miniaturas siguientes',
|
|
220
223
|
characteristics: 'Características',
|