@revenexx/cover 0.2.25 → 0.2.27

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.
Files changed (83) hide show
  1. package/app/api/brands.ts +5 -0
  2. package/app/api/categories.ts +1 -0
  3. package/app/api/product.ts +2 -0
  4. package/app/app.config.ts +8 -0
  5. package/app/components/cart/quickadd/CartQuickAdd.vue +110 -34
  6. package/app/components/category/view/GridView.vue +34 -13
  7. package/app/components/category/view/ListView.vue +5 -5
  8. package/app/components/checkout/onepage/CheckoutDeliverySection.vue +29 -1
  9. package/app/components/checkout/onepage/CheckoutPaymentSection.vue +30 -1
  10. package/app/components/layout/AppLogo.vue +2 -1
  11. package/app/components/layout/footer/Footer.vue +9 -3
  12. package/app/components/layout/header/CategoryPanel.vue +92 -0
  13. package/app/components/layout/header/MainNav.vue +89 -2
  14. package/app/components/listing/ListingResults.vue +16 -2
  15. package/app/components/listing/ListingSubcategories.vue +124 -0
  16. package/app/components/product/card/Compact.vue +144 -0
  17. package/app/components/product/detail/ProductDetailAssociations.vue +96 -0
  18. package/app/components/product/detail/ProductDetailIdentity.vue +50 -5
  19. package/app/components/product/detail/ProductDetailVariantRow.vue +139 -0
  20. package/app/components/product/detail/ProductDetailVariants.vue +613 -0
  21. package/app/components/product/media/ProductMediaImage.vue +70 -0
  22. package/app/components/ui/forms/SearchInput.vue +14 -2
  23. package/app/components/ui/media/ImageSlider.vue +158 -0
  24. package/app/composables/useBranding.ts +22 -0
  25. package/app/composables/useBrands.ts +42 -0
  26. package/app/composables/useCategories.ts +55 -1
  27. package/app/composables/useProduct.ts +5 -4
  28. package/app/composables/useProductAssociations.ts +35 -0
  29. package/app/composables/useProductImage.ts +35 -2
  30. package/app/composables/useProductVariants.ts +46 -0
  31. package/app/composables/useSearchListing.ts +16 -5
  32. package/app/composables/useSubcategoryTiles.ts +36 -0
  33. package/app/config/navigation.ts +9 -0
  34. package/app/config/palette.ts +1 -0
  35. package/app/config/quickActions.ts +137 -0
  36. package/app/config/themes.ts +1 -0
  37. package/app/interfaces/brand.ts +16 -0
  38. package/app/interfaces/category.ts +45 -0
  39. package/app/interfaces/image-slider.ts +18 -0
  40. package/app/interfaces/product-associations.ts +32 -0
  41. package/app/interfaces/product-detail.ts +6 -0
  42. package/app/interfaces/product-variants.ts +73 -0
  43. package/i18n/locales/de/account.json +17 -0
  44. package/i18n/locales/de/cart.json +5 -1
  45. package/i18n/locales/de/checkout.json +2 -0
  46. package/i18n/locales/de/common.json +42 -2
  47. package/i18n/locales/de/editor.json +91 -0
  48. package/i18n/locales/de/product.json +48 -2
  49. package/i18n/locales/de/search.json +4 -2
  50. package/i18n/locales/en/account.json +17 -0
  51. package/i18n/locales/en/cart.json +4 -0
  52. package/i18n/locales/en/checkout.json +2 -0
  53. package/i18n/locales/en/common.json +42 -2
  54. package/i18n/locales/en/editor.json +91 -0
  55. package/i18n/locales/en/product.json +47 -1
  56. package/i18n/locales/en/search.json +3 -1
  57. package/nuxt.config.ts +10 -0
  58. package/package.json +3 -1
  59. package/public/img/brands/revenexx.svg +39 -0
  60. package/server/api/brands.get.ts +27 -0
  61. package/server/api/categories/[slug]/subcategories.get.ts +280 -0
  62. package/server/api/product/[id]/associations.get.ts +27 -0
  63. package/server/api/product/[id]/variants.get.ts +27 -0
  64. package/server/api/quick-actions.get.ts +43 -0
  65. package/server/api/typesense/search.post.ts +116 -13
  66. package/server/data/categories.json +5 -0
  67. package/server/data/product-associations.json +44 -0
  68. package/server/data/product-detail.json +346 -0
  69. package/server/data/product-list.json +340 -0
  70. package/server/data/product-variant-models.json +75 -0
  71. package/server/interfaces/brand.ts +17 -0
  72. package/server/interfaces/product.ts +14 -0
  73. package/server/services/ApiBrandService.ts +110 -0
  74. package/server/services/ApiProductService.ts +43 -9
  75. package/server/services/LocalFileProductService.ts +200 -6
  76. package/server/services/MockBrandService.ts +52 -0
  77. package/server/utils/brandService.ts +24 -0
  78. package/server/utils/contentTenant.ts +67 -0
  79. package/server/utils/liveCatalog.ts +744 -46
  80. package/server/utils/productService.ts +6 -1
  81. package/server/utils/productsSchema.ts +5 -2
  82. package/server/utils/revenexxCredentials.ts +258 -0
  83. package/server/utils/revenexxSdk.ts +38 -47
@@ -1,6 +1,12 @@
1
1
  <script setup lang="ts">
2
2
  import { mainNavigation as defaultMainNav, mainNavigationSecondary as defaultSecondaryNav } from "../../../config/navigation";
3
3
 
4
+ /**
5
+ * Grace period before the catalog panel closes, so a pointer crossing the gap
6
+ * between the nav bar and the panel does not dismiss it.
7
+ */
8
+ const PANEL_CLOSE_DELAY_MS = 180;
9
+
4
10
  // Navigation source, in priority order:
5
11
  // 1. per-request useState — a theme that publishes LIVE menus (e.g. the Blokkli
6
12
  // theme reading the pages app; request-scoped, so multi-tenant safe)
@@ -13,10 +19,48 @@ const liveSecondary = useState<typeof defaultSecondaryNav | null>("cover:nav:mai
13
19
  const mainNavigation = computed(() => liveMain.value ?? (appConfig.mainNavigation as typeof defaultMainNav | undefined) ?? defaultMainNav);
14
20
  const mainNavigationSecondary = computed(() => liveSecondary.value ?? (appConfig.mainNavigationSecondary as typeof defaultSecondaryNav | undefined) ?? defaultSecondaryNav);
15
21
 
22
+ const { icon } = useIcons();
16
23
  const { t } = useI18n();
17
24
  const localePath = useLocalePath();
18
25
  const route = useRoute();
19
26
 
27
+ const isPanelOpen = ref(false);
28
+ let closeTimer: ReturnType<typeof setTimeout> | null = null;
29
+
30
+ function clearCloseTimer(): void {
31
+ if (closeTimer) {
32
+ clearTimeout(closeTimer);
33
+ closeTimer = null;
34
+ }
35
+ }
36
+
37
+ function openPanel(): void {
38
+ clearCloseTimer();
39
+ isPanelOpen.value = true;
40
+ }
41
+
42
+ function closePanel(delay: number = PANEL_CLOSE_DELAY_MS): void {
43
+ clearCloseTimer();
44
+ closeTimer = setTimeout(() => {
45
+ isPanelOpen.value = false;
46
+ closeTimer = null;
47
+ }, delay);
48
+ }
49
+
50
+ // A panel left open across a route change would hover over the page the visitor
51
+ // just asked for.
52
+ watch(() => route.fullPath, () => {
53
+ isPanelOpen.value = false;
54
+ });
55
+
56
+ onUnmounted(clearCloseTimer);
57
+
58
+ /**
59
+ * A catalog-panel item owns the whole category tree, so its trigger stays marked
60
+ * while the visitor is anywhere under /category — and while the panel is open.
61
+ */
62
+ const isCategoryRoute = computed(() => route.path.includes("/category/"));
63
+
20
64
  function isActive(to: string): boolean {
21
65
  const localized = localePath(to);
22
66
  if (to === "/") {
@@ -29,7 +73,8 @@ function isActive(to: string): boolean {
29
73
  <template>
30
74
  <nav
31
75
  :aria-label="t('nav.mainNavigation')"
32
- class="hidden md:block bg-inverted text-inverted"
76
+ class="hidden md:block bg-inverted text-inverted relative"
77
+ @pointerleave="closePanel()"
33
78
  >
34
79
  <div
35
80
  class="px-4 sm:px-6 lg:px-8 max-w-(--ui-container) mx-auto w-full
@@ -37,13 +82,39 @@ function isActive(to: string): boolean {
37
82
  >
38
83
  <ul
39
84
  role="list"
40
- class="flex-1 flex items-center gap-6 lg:gap-8 overflow-x-auto"
85
+ class="flex-1 flex items-center gap-6 lg:gap-8"
41
86
  >
87
+ <!--
88
+ A panel item's trigger is a button, not a link: its job is the
89
+ panel, and the panel carries its own route out to the full
90
+ assortment. Every other item stays the plain link it was.
91
+ -->
42
92
  <li
43
93
  v-for="item in mainNavigation"
44
94
  :key="item.to"
95
+ @pointerenter="item.panel === 'categories' ? openPanel() : undefined"
45
96
  >
97
+ <button
98
+ v-if="item.panel === 'categories'"
99
+ type="button"
100
+ class="inline-flex items-center gap-1.5 py-0.5 whitespace-nowrap
101
+ underline-offset-4 decoration-2 hover:underline cursor-pointer"
102
+ :class="{ 'underline': isCategoryRoute || isPanelOpen }"
103
+ :aria-expanded="isPanelOpen"
104
+ aria-haspopup="true"
105
+ @click="isPanelOpen ? closePanel(0) : openPanel()"
106
+ @keydown.escape="closePanel(0)"
107
+ >
108
+ {{ t(item.labelKey) }}
109
+ <UIcon
110
+ :name="icon('chevron-down')"
111
+ class="size-4 transition-transform"
112
+ :class="{ 'rotate-180': isPanelOpen }"
113
+ />
114
+ </button>
115
+
46
116
  <NuxtLink
117
+ v-else
47
118
  :to="localePath(item.to)"
48
119
  class="inline-block py-0.5 whitespace-nowrap underline-offset-4 decoration-2 hover:underline"
49
120
  :class="{ 'underline': isActive(item.to) }"
@@ -69,5 +140,21 @@ function isActive(to: string): boolean {
69
140
  </li>
70
141
  </ul>
71
142
  </div>
143
+
144
+ <Transition
145
+ enter-active-class="transition duration-100 ease-out"
146
+ enter-from-class="opacity-0 -translate-y-1"
147
+ leave-active-class="transition duration-75 ease-in"
148
+ leave-to-class="opacity-0"
149
+ >
150
+ <div
151
+ v-if="isPanelOpen"
152
+ class="absolute inset-x-0 top-full z-50 bg-default text-default
153
+ border-t border-(--ui-border) shadow-xl"
154
+ @pointerenter="openPanel"
155
+ >
156
+ <LayoutHeaderCategoryPanel />
157
+ </div>
158
+ </Transition>
72
159
  </nav>
73
160
  </template>
@@ -6,9 +6,16 @@ import type { ProductListing } from "../../composables/useProductListing";
6
6
  * (grid or list per useViewMode) and pagination. Falls back to the #empty slot
7
7
  * (default: a no-results empty state) when the listing returns no products.
8
8
  */
9
- const props = defineProps<{
9
+ const props = withDefaults(defineProps<{
10
10
  listing: ProductListing;
11
- }>();
11
+ /** Cart icon on the grid card's order button. */
12
+ showOrderIcon?: boolean;
13
+ /** Look of the grid card's order button when the product can't be bought. */
14
+ disabledOrderStyle?: "default" | "muted";
15
+ }>(), {
16
+ showOrderIcon: true,
17
+ disabledOrderStyle: "default",
18
+ });
12
19
 
13
20
  const { t } = useI18n();
14
21
  const { viewMode } = useViewMode();
@@ -22,6 +29,12 @@ const gridClasses = computed(() => viewMode.value === "grid"
22
29
  const listView = resolveComponent("CategoryViewListView");
23
30
  const gridView = resolveComponent("CategoryViewGridView");
24
31
  const productComponent = computed(() => viewMode.value === "list" ? listView : gridView);
32
+
33
+ // Only the grid card declares the order-button options; on the list card they
34
+ // would fall through onto its root element as stray DOM attributes.
35
+ const cardProps = computed(() => viewMode.value === "list"
36
+ ? {}
37
+ : { showOrderIcon: props.showOrderIcon, disabledOrderStyle: props.disabledOrderStyle });
25
38
  </script>
26
39
 
27
40
  <template>
@@ -58,6 +71,7 @@ const productComponent = computed(() => viewMode.value === "list" ? listView : g
58
71
  v-for="product in listing.products.value"
59
72
  :key="product.id"
60
73
  :product="product"
74
+ v-bind="cardProps"
61
75
  />
62
76
  </div>
63
77
 
@@ -0,0 +1,124 @@
1
+ <script setup lang="ts">
2
+ import type { SubcategoryTile } from "../../interfaces/category";
3
+
4
+ /**
5
+ * The subcategory drill-down on a category page: one card per child category,
6
+ * linking into it. The counterpart of the filter rail's `subcategory` facet —
7
+ * same axis, but as the page's primary navigation rather than a filter.
8
+ *
9
+ * Layout is ported from the eltric reference: a horizontal card with the media
10
+ * in a fixed square on the LEFT and the label above its product count on the
11
+ * right. `object-contain` on a tinted square rather than a cropping cover fill,
12
+ * because these are product photos on transparent backgrounds.
13
+ *
14
+ * `media` picks what fills that square:
15
+ * - `image` — a preview photo from one of the subcategory's products (the BFF
16
+ * picks it; see useSubcategoryTiles).
17
+ * - `icon` — the subcategory's icon token.
18
+ *
19
+ * A tile with no image falls back to the icon in the same square, so a mixed
20
+ * grid keeps one alignment. That is also what an empty subcategory or an
21
+ * unreachable product index produces.
22
+ *
23
+ * Purely presentational: the caller owns the fetch and the decision to render.
24
+ */
25
+ const props = withDefaults(defineProps<{
26
+ tiles: SubcategoryTile[];
27
+ /** Parent slug — the first segment of every card's link. */
28
+ categorySlug: string;
29
+ /** Column count from the `xl` breakpoint up; narrower steps are fixed. */
30
+ perRow?: string;
31
+ media?: "icon" | "image";
32
+ showProductCount?: boolean;
33
+ /** Optional heading above the grid. */
34
+ heading?: string;
35
+ }>(), {
36
+ perRow: "6",
37
+ media: "image",
38
+ showProductCount: true,
39
+ heading: "",
40
+ });
41
+
42
+ const { t } = useI18n();
43
+ const { icon } = useIcons();
44
+ const localePath = useLocalePath();
45
+ const { getImage } = useProductImage();
46
+
47
+ // Static map so Tailwind's JIT emits every utility — deliberately a local
48
+ // literal rather than a shared export: coupling this to the category grid's
49
+ // own map would freeze both layouts together, and they step differently.
50
+ const PER_ROW_CLASS: Record<string, string> = {
51
+ 4: "xl:grid-cols-4",
52
+ 5: "xl:grid-cols-5",
53
+ 6: "xl:grid-cols-6",
54
+ 7: "xl:grid-cols-7",
55
+ 8: "xl:grid-cols-8",
56
+ };
57
+
58
+ const perRowClass = computed(() => PER_ROW_CLASS[props.perRow] ?? PER_ROW_CLASS[6]);
59
+ const isImageMedia = computed(() => props.media === "image");
60
+ </script>
61
+
62
+ <template>
63
+ <nav
64
+ :aria-label="t('search.filters.facets.subcategory')"
65
+ class="py-4"
66
+ >
67
+ <h2
68
+ v-if="props.heading"
69
+ class="mb-4 text-lg font-semibold text-highlighted"
70
+ >
71
+ {{ props.heading }}
72
+ </h2>
73
+
74
+ <ul
75
+ role="list"
76
+ :class="['grid grid-cols-2 gap-3 sm:grid-cols-3 lg:grid-cols-4', perRowClass]"
77
+ >
78
+ <!-- Keyed on the index too: categories.json ships a category whose
79
+ subcategory slugs repeat, and a bare slug would collide. -->
80
+ <li
81
+ v-for="(tile, index) in props.tiles"
82
+ :key="`${index}-${tile.slug}`"
83
+ >
84
+ <NuxtLink
85
+ :to="localePath(`/category/${props.categorySlug}/${tile.slug}`)"
86
+ tabindex="0"
87
+ class="group flex h-full items-center gap-3 rounded-lg p-2 ring-1 ring-(--ui-border)
88
+ transition-colors hover:ring-(--ui-primary)
89
+ focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-(--ui-primary)"
90
+ >
91
+ <span
92
+ class="flex size-12 shrink-0 items-center justify-center overflow-hidden
93
+ rounded bg-elevated/40"
94
+ >
95
+ <img
96
+ v-if="isImageMedia && tile.image"
97
+ :src="getImage(tile.image)"
98
+ :alt="tile.label"
99
+ loading="lazy"
100
+ class="max-h-full max-w-full object-contain"
101
+ >
102
+ <UIcon
103
+ v-else
104
+ :name="icon(tile.icon)"
105
+ class="size-6 text-(--ui-primary)"
106
+ />
107
+ </span>
108
+
109
+ <span class="min-w-0 flex-1">
110
+ <span class="line-clamp-2 text-sm text-highlighted group-hover:text-(--ui-primary)">
111
+ {{ tile.label }}
112
+ </span>
113
+ <span
114
+ v-if="props.showProductCount"
115
+ class="text-sm text-muted tabular-nums"
116
+ >
117
+ {{ t('search.category.productCount', tile.productCount, { count: tile.productCount }) }}
118
+ </span>
119
+ </span>
120
+ </NuxtLink>
121
+ </li>
122
+ </ul>
123
+ </nav>
124
+ </template>
@@ -0,0 +1,144 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Compact product card for the `product_grid` block — a self-contained bordered
4
+ * tile, deliberately NOT a UCard: UCard's outline variant puts `divide-y` on its
5
+ * root, which draws a line under the image and above the buttons.
6
+ *
7
+ * One button, not two: it is "order" while the product is orderable and falls
8
+ * back to "info" (linking to the detail page) when there is no price or no
9
+ * stock. `CategoryViewGridView` keeps the two-button layout for the category and
10
+ * search pages.
11
+ *
12
+ * The price is rendered here rather than through `CategoryInfoCategoryPrice`,
13
+ * whose typography is shared with the category page and the list view. Only the
14
+ * presentation is local — the tier/tax maths comes from `useProducts`.
15
+ */
16
+ import { getDisplayUnitPrice, getPriceTiers, getPriceWithOptionalTax } from "../../../composables/useProducts";
17
+ import type { ProductList } from "../../../interfaces/product-list";
18
+
19
+ const props = withDefaults(defineProps<{
20
+ product: ProductList;
21
+ /**
22
+ * `order` still falls back to the info link when the product has no price or
23
+ * no stock; `info` always links to the detail page.
24
+ */
25
+ action?: "order" | "info";
26
+ }>(), {
27
+ action: "order",
28
+ });
29
+
30
+ const { t } = useI18n();
31
+ const { icon } = useIcons();
32
+ const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
33
+ const currency = useDisplayCurrency();
34
+
35
+ const { url } = useProductCard(() => props.product);
36
+ const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.product);
37
+
38
+ const canOrder = computed(() =>
39
+ props.action === "order" && !isOutOfStock.value && hasPrice.value,
40
+ );
41
+
42
+ // Price is the Offer domain — resolved separately, hydrates after first paint.
43
+ const { offer, pending } = useOffers().useOffer(() => props.product.id);
44
+ const offerPrices = computed(() => offer.value?.prices ?? []);
45
+ const hasTieredPricing = computed(() => getPriceTiers(offerPrices.value).length > 1);
46
+
47
+ const displayPrice = computed<number | null>(() => {
48
+ const basePrice = getDisplayUnitPrice(offerPrices.value);
49
+ if (basePrice === null) {
50
+ return null;
51
+ }
52
+ return getPriceWithOptionalTax(basePrice, props.product.tax.rate, taxIncludedPrices);
53
+ });
54
+
55
+ function formatPrice(price: number): string {
56
+ return price.toLocaleString(locale, { style: "currency", currency: currency.value });
57
+ }
58
+ </script>
59
+
60
+ <template>
61
+ <div class="group flex h-full flex-col rounded-lg border border-(--ui-border) p-3 transition-colors hover:border-primary/60">
62
+ <NuxtLink
63
+ :to="url"
64
+ tabindex="-1"
65
+ aria-hidden="true"
66
+ class="block"
67
+ >
68
+ <!-- The image is sized by `inset-0`, not `max-h-full`: a percentage
69
+ max-height does not resolve for a flex item whose containing block gets
70
+ its height from `aspect-ratio`, so portrait images kept their intrinsic
71
+ height and were clipped. `object-contain` then letterboxes inside the
72
+ box, so the whole picture shows at any aspect ratio. -->
73
+ <div class="relative aspect-square flex items-center justify-center overflow-hidden rounded bg-elevated/40">
74
+ <ProductMediaImage
75
+ :src="props.product.image"
76
+ :alt="props.product.name"
77
+ image-class="absolute inset-0 size-full object-contain"
78
+ icon-class="size-8 text-muted"
79
+ />
80
+ </div>
81
+ </NuxtLink>
82
+
83
+ <NuxtLink
84
+ :to="url"
85
+ class="mt-2 block text-sm leading-snug line-clamp-2 text-highlighted group-hover:text-primary"
86
+ >
87
+ {{ props.product.name }}
88
+ </NuxtLink>
89
+
90
+ <p class="mt-1 text-xs tabular-nums text-muted">
91
+ {{ props.product.sku }}
92
+ </p>
93
+
94
+ <!-- mt-auto pins the facts and the button to the bottom, so cards of
95
+ differing title length still line up across a row. -->
96
+ <div class="mt-auto pt-2 space-y-1">
97
+ <CategoryInfoCategoryStock :product="props.product" />
98
+
99
+ <div>
100
+ <USkeleton
101
+ v-if="pending"
102
+ class="h-6 w-24"
103
+ />
104
+ <div
105
+ v-else-if="displayPrice === null"
106
+ class="text-sm font-medium text-muted"
107
+ >
108
+ {{ t('product.price.onRequest') }}
109
+ </div>
110
+ <template v-else>
111
+ <div class="flex flex-wrap items-baseline gap-x-1.5">
112
+ <span
113
+ v-if="hasTieredPricing"
114
+ class="text-sm text-muted"
115
+ >{{ t('product.price.from') }}</span>
116
+ <span class="font-semibold text-highlighted">{{ formatPrice(displayPrice) }}</span>
117
+ <span class="text-muted">
118
+ {{ taxIncludedPrices ? t('product.price.inclTax') : t('product.price.exclTax') }}
119
+ </span>
120
+ </div>
121
+ <p
122
+ v-if="hasTieredPricing"
123
+ class="text-sm text-primary"
124
+ >
125
+ {{ t('product.price.volume') }}
126
+ </p>
127
+ </template>
128
+ </div>
129
+ </div>
130
+
131
+ <UButton
132
+ :label="canOrder ? t('product.actions.order') : t('product.actions.info')"
133
+ :color="canOrder ? 'primary' : 'neutral'"
134
+ :variant="canOrder ? 'solid' : 'soft'"
135
+ :icon="canOrder ? icon('cart') : undefined"
136
+ :to="canOrder ? undefined : url"
137
+ :aria-label="canOrder ? `${t('product.actions.addToCart')}: ${props.product.name}` : props.product.name"
138
+ size="sm"
139
+ block
140
+ class="mt-2 justify-center cursor-pointer"
141
+ @click="canOrder ? addToCart() : undefined"
142
+ />
143
+ </div>
144
+ </template>
@@ -0,0 +1,96 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The related-article grids of the product detail page: one section per
4
+ * relation type the product has — "Zubehör", "Pflichtzubehör", "Ersatzteile" —
5
+ * each a grid of tiles carrying an image, the article name and its number.
6
+ *
7
+ * Props-only like its neighbours; the host fetches via
8
+ * `useProductAssociations` and supplies `linkFor`. Deliberately no price on a
9
+ * tile: these are a way into the catalogue, not a second buy box, so the
10
+ * section costs no offer request.
11
+ *
12
+ * The tiles run no per-item composable, so they stay an inline `v-for` rather
13
+ * than a component of their own (unlike a variants row, which needs one
14
+ * `useOffer` instance apiece).
15
+ *
16
+ * The tile image box is `relative` with an absolutely positioned image rather
17
+ * than a percentage max-height: that does not resolve for a flex item whose
18
+ * containing block takes its height from `aspect-ratio` (same fix, and the same
19
+ * reason, as ProductCardCompact).
20
+ */
21
+ import type {
22
+ ProductAssociationGroup,
23
+ ProductAssociationItem,
24
+ } from "../../../interfaces/product-associations";
25
+
26
+ defineProps<{
27
+ groups: readonly ProductAssociationGroup[];
28
+ /** Localised route to a related article's own detail page. */
29
+ linkFor: (item: ProductAssociationItem) => string;
30
+ }>();
31
+
32
+ const { t } = useI18n();
33
+ </script>
34
+
35
+ <template>
36
+ <template v-if="groups.length">
37
+ <section
38
+ v-for="group in groups"
39
+ :key="group.code"
40
+ class="mt-14 pt-10 border-t border-(--ui-border)"
41
+ >
42
+ <h2 class="text-lg font-semibold tracking-tight text-highlighted">
43
+ {{ group.label }}
44
+ <span
45
+ v-if="group.isMandatory"
46
+ class="ml-2 align-middle text-xs font-normal text-muted"
47
+ >
48
+ {{ t('product.associations.mandatoryNote') }}
49
+ </span>
50
+ </h2>
51
+
52
+ <ul class="mt-4 grid gap-4 grid-cols-2 sm:grid-cols-3 lg:grid-cols-4 xl:grid-cols-6">
53
+ <li
54
+ v-for="item in group.items"
55
+ :key="item.id"
56
+ >
57
+ <NuxtLink
58
+ :to="linkFor(item)"
59
+ class="group block rounded-lg border border-(--ui-border) p-3 h-full
60
+ hover:border-primary/60 transition-colors"
61
+ >
62
+ <div
63
+ class="relative aspect-square flex items-center justify-center
64
+ overflow-hidden rounded bg-elevated/40"
65
+ >
66
+ <ProductMediaImage
67
+ :src="item.image"
68
+ :alt="item.name"
69
+ image-class="absolute inset-0 size-full object-contain"
70
+ />
71
+ </div>
72
+ <p
73
+ class="mt-2 text-sm leading-snug line-clamp-3 text-highlighted
74
+ group-hover:text-primary"
75
+ >
76
+ {{ item.name }}
77
+ </p>
78
+ <p class="mt-1 text-xs tabular-nums text-muted">
79
+ {{ item.sku }}
80
+ </p>
81
+ </NuxtLink>
82
+ </li>
83
+ </ul>
84
+ </section>
85
+ </template>
86
+
87
+ <!--
88
+ A product that relates to nothing renders nothing here. The slot lets a
89
+ host (the blokkli block) put a selectable stand-in in its place on the
90
+ editor canvas, where a zero-height block is unreachable.
91
+ -->
92
+ <slot
93
+ v-else
94
+ name="empty"
95
+ />
96
+ </template>
@@ -1,17 +1,50 @@
1
1
  <script setup lang="ts">
2
2
  /**
3
- * Product identity block: manufacturer, name and a copy-to-clipboard SKU.
3
+ * Product identity block: manufacturer, name, the manufacturer logo where the
4
+ * catalogue has one, and a copy-to-clipboard SKU.
4
5
  */
5
6
  const props = defineProps<{
6
7
  manufacturer: string;
7
8
  name: string;
8
9
  sku: string;
10
+ /**
11
+ * Manufacturer logo src, or null/undefined for none. Whether a logo MAY be
12
+ * shown is the caller's decision (the blokkli block exposes it as an
13
+ * editor option) — this component only renders what it is handed.
14
+ */
15
+ logo?: string | null;
9
16
  }>();
10
17
 
11
18
  const { icon } = useIcons();
12
19
  const { t } = useI18n();
13
20
  const toast = useToast();
14
21
 
22
+ const root = ref<HTMLElement | null>(null);
23
+ // A logo URL that 404s (a stale CDN key after a PIM re-import) must leave the
24
+ // heading alone, not a broken-image glyph next to it. The manufacturer name is
25
+ // already on the line above, so there is nothing to fall back TO.
26
+ const logoFailed = ref(false);
27
+
28
+ const showLogo = computed<boolean>(() => Boolean(props.logo) && !logoFailed.value);
29
+
30
+ /**
31
+ * `@error` alone cannot promise that. An SSR-rendered <img> starts loading while
32
+ * the HTML is still parsing and can fail BEFORE Vue hydrates; the listener
33
+ * attached at hydration never sees an event that already fired. Sweep once on
34
+ * mount for an image that is already finished and has no intrinsic width —
35
+ * anything still in flight is `@error`'s job. `currentSrc` guards against a
36
+ * false positive: the browser only sets it once it has actually selected a
37
+ * source, so an image that was never fetched (a hidden one below `sm`, or any
38
+ * non-loading environment such as the jsdom test env) is skipped rather than
39
+ * declared broken.
40
+ */
41
+ onMounted(() => {
42
+ const image = root.value?.querySelector<HTMLImageElement>("img[data-manufacturer-logo]");
43
+ if (image?.complete && image.naturalWidth === 0 && image.currentSrc) {
44
+ logoFailed.value = true;
45
+ }
46
+ });
47
+
15
48
  async function copySku(): Promise<void> {
16
49
  await navigator.clipboard.writeText(props.sku);
17
50
  toast.add({ title: t("product.detail.skuCopied"), duration: 1200, icon: icon("copy-check") });
@@ -19,13 +52,25 @@ async function copySku(): Promise<void> {
19
52
  </script>
20
53
 
21
54
  <template>
22
- <div>
55
+ <div ref="root">
23
56
  <p class="text-xs font-semibold uppercase tracking-wide text-muted">
24
57
  {{ manufacturer }}
25
58
  </p>
26
- <h1 class="mt-1 text-3xl font-semibold tracking-tight text-highlighted">
27
- {{ name }}
28
- </h1>
59
+ <div class="mt-1 flex items-start justify-between gap-6">
60
+ <h1 class="text-3xl font-semibold tracking-tight text-highlighted">
61
+ {{ name }}
62
+ </h1>
63
+ <!-- Desktop only: on a phone the product name needs the full width. -->
64
+ <img
65
+ v-if="showLogo"
66
+ :src="logo ?? undefined"
67
+ :alt="manufacturer"
68
+ data-manufacturer-logo
69
+ loading="lazy"
70
+ class="hidden sm:block h-14 w-auto max-w-36 object-contain shrink-0"
71
+ @error="logoFailed = true"
72
+ >
73
+ </div>
29
74
  <button
30
75
  type="button"
31
76
  tabindex="0"