@revenexx/cover 0.2.26 → 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 (79) 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/layout/AppLogo.vue +2 -1
  9. package/app/components/layout/footer/Footer.vue +9 -3
  10. package/app/components/layout/header/CategoryPanel.vue +92 -0
  11. package/app/components/layout/header/MainNav.vue +89 -2
  12. package/app/components/listing/ListingResults.vue +16 -2
  13. package/app/components/listing/ListingSubcategories.vue +124 -0
  14. package/app/components/product/card/Compact.vue +144 -0
  15. package/app/components/product/detail/ProductDetailAssociations.vue +96 -0
  16. package/app/components/product/detail/ProductDetailIdentity.vue +50 -5
  17. package/app/components/product/detail/ProductDetailVariantRow.vue +139 -0
  18. package/app/components/product/detail/ProductDetailVariants.vue +613 -0
  19. package/app/components/product/media/ProductMediaImage.vue +70 -0
  20. package/app/components/ui/forms/SearchInput.vue +14 -2
  21. package/app/components/ui/media/ImageSlider.vue +158 -0
  22. package/app/composables/useBranding.ts +22 -0
  23. package/app/composables/useBrands.ts +42 -0
  24. package/app/composables/useCategories.ts +55 -1
  25. package/app/composables/useProduct.ts +5 -4
  26. package/app/composables/useProductAssociations.ts +35 -0
  27. package/app/composables/useProductImage.ts +35 -2
  28. package/app/composables/useProductVariants.ts +46 -0
  29. package/app/composables/useSearchListing.ts +16 -5
  30. package/app/composables/useSubcategoryTiles.ts +36 -0
  31. package/app/config/navigation.ts +9 -0
  32. package/app/config/palette.ts +1 -0
  33. package/app/config/quickActions.ts +137 -0
  34. package/app/config/themes.ts +1 -0
  35. package/app/interfaces/brand.ts +16 -0
  36. package/app/interfaces/category.ts +45 -0
  37. package/app/interfaces/image-slider.ts +18 -0
  38. package/app/interfaces/product-associations.ts +32 -0
  39. package/app/interfaces/product-detail.ts +6 -0
  40. package/app/interfaces/product-variants.ts +73 -0
  41. package/i18n/locales/de/account.json +17 -0
  42. package/i18n/locales/de/cart.json +5 -1
  43. package/i18n/locales/de/common.json +42 -2
  44. package/i18n/locales/de/editor.json +91 -0
  45. package/i18n/locales/de/product.json +48 -2
  46. package/i18n/locales/de/search.json +4 -2
  47. package/i18n/locales/en/account.json +17 -0
  48. package/i18n/locales/en/cart.json +4 -0
  49. package/i18n/locales/en/common.json +42 -2
  50. package/i18n/locales/en/editor.json +91 -0
  51. package/i18n/locales/en/product.json +47 -1
  52. package/i18n/locales/en/search.json +3 -1
  53. package/nuxt.config.ts +10 -0
  54. package/package.json +3 -1
  55. package/public/img/brands/revenexx.svg +39 -0
  56. package/server/api/brands.get.ts +27 -0
  57. package/server/api/categories/[slug]/subcategories.get.ts +280 -0
  58. package/server/api/product/[id]/associations.get.ts +27 -0
  59. package/server/api/product/[id]/variants.get.ts +27 -0
  60. package/server/api/quick-actions.get.ts +43 -0
  61. package/server/api/typesense/search.post.ts +116 -13
  62. package/server/data/categories.json +5 -0
  63. package/server/data/product-associations.json +44 -0
  64. package/server/data/product-detail.json +346 -0
  65. package/server/data/product-list.json +340 -0
  66. package/server/data/product-variant-models.json +75 -0
  67. package/server/interfaces/brand.ts +17 -0
  68. package/server/interfaces/product.ts +14 -0
  69. package/server/services/ApiBrandService.ts +110 -0
  70. package/server/services/ApiProductService.ts +43 -9
  71. package/server/services/LocalFileProductService.ts +200 -6
  72. package/server/services/MockBrandService.ts +52 -0
  73. package/server/utils/brandService.ts +24 -0
  74. package/server/utils/contentTenant.ts +67 -0
  75. package/server/utils/liveCatalog.ts +744 -46
  76. package/server/utils/productService.ts +6 -1
  77. package/server/utils/productsSchema.ts +5 -2
  78. package/server/utils/revenexxCredentials.ts +258 -0
  79. package/server/utils/revenexxSdk.ts +38 -47
@@ -0,0 +1,5 @@
1
+ export const brandsApi = {
2
+ list: (limit: number) => `/api/brands?limit=${limit}`,
3
+ /** Every brand, names and counts only (`logo: null`) — for pickers. */
4
+ listAll: () => "/api/brands?all=1",
5
+ };
@@ -1,3 +1,4 @@
1
1
  export const categoriesApi = {
2
2
  list: () => "/api/categories",
3
+ subcategories: (slug: string) => `/api/categories/${slug}/subcategories`,
3
4
  };
@@ -1,3 +1,5 @@
1
1
  export const productApi = {
2
2
  detail: (id: string) => `/api/product/${id}`,
3
+ variants: (id: string) => `/api/product/${id}/variants`,
4
+ associations: (id: string) => `/api/product/${id}/associations`,
3
5
  };
package/app/app.config.ts CHANGED
@@ -18,6 +18,7 @@ export default defineAppConfig({
18
18
  authService: "mock",
19
19
  productService: "mock",
20
20
  categoryService: "mock",
21
+ brandService: "mock",
21
22
  marketService: "mock",
22
23
  cartService: "mock",
23
24
  paymentService: "mock",
@@ -27,6 +28,13 @@ export default defineAppConfig({
27
28
  inventoryService: "mock",
28
29
  orderListService: "mock",
29
30
  themeService: "mock",
31
+ // Where a live catalogue keeps a manufacturer's logo. This is a per-tenant
32
+ // PIM attribute on the product document, not a platform contract, so a
33
+ // storefront whose catalogue names it differently overrides the code here.
34
+ // A tenant that has no such attribute renders wordmark tiles instead.
35
+ brands: {
36
+ logoAttribute: "manufacturer_logo",
37
+ },
30
38
  // Search UX defaults the layer's components read — apps may override,
31
39
  // but the layer must ship working values (a missing `search` object
32
40
  // crashed SearchInput with "Cannot read … 'autocompleteMinChars'").
@@ -1,42 +1,98 @@
1
1
  <script setup lang="ts">
2
- import { productsApi } from "../../../api/products";
2
+ import { useDebounceFn } from "@vueuse/core";
3
+
4
+ import { searchApi } from "../../../api/search";
5
+ import type { ListingResponse } from "../../../composables/useProductListing";
3
6
  import { getBaseUnitPrice, getPriceTiers, type Product } from "../../../composables/useProducts";
4
7
 
5
8
  /**
6
9
  * Cart quick entry (spec: Warenkorb-Schnellerfassung): add positions by
7
- * article number with quantity, embedded on the empty cart and available
8
- * as a modal on the filled cart.
10
+ * article number with quantity, embedded on the empty cart, available as a
11
+ * modal on the filled cart and as the `quick_order` content block.
12
+ *
13
+ * Matching runs server-side through the Typesense listing endpoint
14
+ * (`query_by: "name,sku"`), so an article number resolves against the whole
15
+ * catalog. Filtering the `/api/products` list client-side would have capped
16
+ * the lookup at that endpoint's page size — 48 articles in live mode.
9
17
  */
10
18
  const { icon } = useIcons();
11
- const { t } = useI18n();
19
+ const { locale, t } = useI18n();
12
20
  const toast = useToast();
13
21
  const cart = useCartStore();
14
- const { locale } = useI18n();
22
+ // The layer ships a `search` default, but a consumer that overrides
23
+ // app.config without it must not break quick entry — fall back locally.
24
+ const appConfig = useAppConfig();
25
+
26
+ /** Enough lines to disambiguate a name, few enough to stay a dropdown. */
27
+ const MAX_MATCHES = 6;
28
+
29
+ const offers = useOffers();
15
30
 
16
31
  const sku = ref("");
17
32
  const quantity = ref("1");
18
33
  const adding = ref(false);
34
+ const searching = ref(false);
35
+ const rawMatches = ref<Product[]>([]);
19
36
 
20
- const { data: products } = useFetch<Product[]>(productsApi.list(), {
21
- key: "quick-add-products",
22
- headers: computed(() => ({ "x-locale": locale.value })),
23
- server: false,
24
- lazy: true,
25
- default: () => [],
26
- });
37
+ const minChars = computed(() => appConfig.search?.autocompleteMinChars ?? 2);
38
+
39
+ // Offers (price + availability) hydrate only for the few shown matches. By the
40
+ // time a list reaches `rawMatches` its offers are already cached, so this reads
41
+ // them straight out rather than kicking off the load itself.
42
+ const matches = offers.withOffers(() => rawMatches.value);
43
+
44
+ /**
45
+ * A row is orderable only once its offer says so. Price and availability are
46
+ * the Offer domain, so a row whose offer carries no price is "on request" and
47
+ * cannot be added — the row has to say that rather than swallow the click.
48
+ */
49
+ const rows = computed(() => matches.value.map(product => ({
50
+ product,
51
+ hasPrice: getBaseUnitPrice(product.prices) !== null,
52
+ isOutOfStock: product.isOutOfStock ?? false,
53
+ })));
54
+
55
+ const orderableRows = computed(() => rows.value.filter(row => row.hasPrice && !row.isOutOfStock));
27
56
 
28
- const rawMatches = computed(() => {
29
- const q = sku.value.trim().toLowerCase();
30
- if (q.length < 2) {
31
- return [];
57
+ async function fetchMatches(q: string): Promise<void> {
58
+ searching.value = true;
59
+ try {
60
+ const data = await $fetch<ListingResponse | null>(searchApi.search(), {
61
+ method: "POST",
62
+ // The search route filters the index by locale; without this header it
63
+ // would use the browser's Accept-Language instead of the selected one.
64
+ headers: { "x-locale": locale.value },
65
+ body: { q, page: 1, perPage: MAX_MATCHES },
66
+ }).catch(() => null);
67
+ // A response that lost the race against newer typing must not win.
68
+ if (q !== sku.value.trim()) {
69
+ return;
70
+ }
71
+ const products = data?.products ?? [];
72
+ // Fill the offer cache BEFORE the rows appear. `withOffers` would load
73
+ // them in a watcher, leaving every row priceless — and so silently
74
+ // unaddable — for as long as POST /api/offers takes.
75
+ await offers.loadOffers(products);
76
+ if (q !== sku.value.trim()) {
77
+ return;
78
+ }
79
+ rawMatches.value = products;
32
80
  }
33
- return (products.value ?? [])
34
- .filter(p => p.sku.toLowerCase().includes(q) || p.name.toLowerCase().includes(q))
35
- .slice(0, 5);
36
- });
81
+ finally {
82
+ searching.value = false;
83
+ }
84
+ }
37
85
 
38
- // Offers (price + availability) hydrate only for the few shown matches.
39
- const matches = useOffers().withOffers(() => rawMatches.value);
86
+ const debouncedFetch = useDebounceFn(fetchMatches, 250);
87
+
88
+ watch(sku, (val) => {
89
+ const q = val.trim();
90
+ if (q.length < minChars.value) {
91
+ rawMatches.value = [];
92
+ return;
93
+ }
94
+ void debouncedFetch(q);
95
+ });
40
96
 
41
97
  function buildTiers(prices: { [key: string]: number }[]) {
42
98
  return getPriceTiers(prices).map(tier => ({
@@ -48,6 +104,8 @@ function buildTiers(prices: { [key: string]: number }[]) {
48
104
  function addProduct(product: Product): void {
49
105
  const qty = Math.max(1, parseInt(quantity.value, 10) || 1);
50
106
  const price = getBaseUnitPrice(product.prices);
107
+ // Belt and braces: the rows and the submit button already exclude anything
108
+ // without a price, so reaching this is a bug rather than a user action.
51
109
  if (price === null) {
52
110
  return;
53
111
  }
@@ -78,16 +136,20 @@ function addProduct(product: Product): void {
78
136
  icon: icon("success"),
79
137
  duration: 1500,
80
138
  });
139
+ // Clearing the query also empties the match list through the watcher.
81
140
  sku.value = "";
82
141
  quantity.value = "1";
83
142
  adding.value = false;
84
143
  }
85
144
 
86
145
  function onSubmit(): void {
87
- const exact = matches.value.find(p => p.sku.toLowerCase() === sku.value.trim().toLowerCase());
88
- const target = exact ?? matches.value[0];
146
+ const query = sku.value.trim().toLowerCase();
147
+ // An exact article number wins — but only if it can actually be ordered;
148
+ // otherwise fall through to the best row that can.
149
+ const exact = orderableRows.value.find(row => row.product.sku.toLowerCase() === query);
150
+ const target = exact ?? orderableRows.value[0];
89
151
  if (target) {
90
- addProduct(target);
152
+ addProduct(target.product);
91
153
  }
92
154
  }
93
155
  </script>
@@ -118,29 +180,43 @@ function onSubmit(): void {
118
180
  <UButton
119
181
  color="primary"
120
182
  tabindex="0"
121
- :loading="adding"
122
- :disabled="matches.length === 0"
183
+ :loading="adding || searching"
184
+ :disabled="orderableRows.length === 0"
123
185
  :label="t('cart.quickAdd.add')"
124
186
  @click="onSubmit"
125
187
  />
126
188
  </div>
127
189
  <ul
128
- v-if="matches.length"
190
+ v-if="rows.length"
129
191
  class="border border-(--ui-border) rounded-lg divide-y divide-(--ui-border) overflow-hidden"
130
192
  >
131
193
  <li
132
- v-for="product in matches"
133
- :key="product.id"
194
+ v-for="row in rows"
195
+ :key="row.product.id"
134
196
  >
135
197
  <button
136
198
  type="button"
137
199
  tabindex="0"
200
+ :disabled="!row.hasPrice || row.isOutOfStock"
138
201
  class="w-full flex items-center justify-between gap-3 px-3 py-2 text-left
139
- hover:bg-elevated transition-colors cursor-pointer"
140
- @click="addProduct(product)"
202
+ transition-colors enabled:hover:bg-elevated enabled:cursor-pointer
203
+ disabled:cursor-not-allowed disabled:opacity-60"
204
+ @click="addProduct(row.product)"
141
205
  >
142
- <span class="text-sm text-highlighted truncate">{{ product.name }}</span>
143
- <span class="text-xs text-muted shrink-0">{{ product.sku }}</span>
206
+ <span class="text-sm text-highlighted truncate">{{ row.product.name }}</span>
207
+ <span class="text-xs text-muted shrink-0 text-right">
208
+ {{ row.product.sku }}
209
+ <!-- Why the row can't be ordered — without this the click
210
+ would simply do nothing and look broken. -->
211
+ <span
212
+ v-if="row.isOutOfStock"
213
+ class="block"
214
+ >{{ t("product.stock.unavailable") }}</span>
215
+ <span
216
+ v-else-if="!row.hasPrice"
217
+ class="block"
218
+ >{{ t("product.price.onRequest") }}</span>
219
+ </span>
144
220
  </button>
145
221
  </li>
146
222
  </ul>
@@ -1,13 +1,35 @@
1
1
  <script setup lang="ts">
2
2
  import type { ProductList } from "../../../interfaces/product-list";
3
3
 
4
- const props = defineProps<{
4
+ const props = withDefaults(defineProps<{
5
5
  product: ProductList;
6
- }>();
6
+ /** Cart icon on the order button. */
7
+ showOrderIcon?: boolean;
8
+ /** Look of the order button when the product can't be bought. */
9
+ disabledOrderStyle?: "default" | "muted";
10
+ }>(), {
11
+ showOrderIcon: true,
12
+ disabledOrderStyle: "default",
13
+ });
7
14
 
8
15
  const { t } = useI18n();
9
- const { url, getImage } = useProductCard(() => props.product);
16
+ const { icon } = useIcons();
17
+ const { url } = useProductCard(() => props.product);
10
18
  const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.product);
19
+
20
+ const orderDisabled = computed(() => isOutOfStock.value || !hasPrice.value);
21
+
22
+ // Trailing `!` — Tailwind 4's important modifier. Needed because these have to
23
+ // beat UButton's own solid-neutral colours, and `disabled:opacity-100!` cancels
24
+ // its dimming so the muted variant reads as a solid grey button.
25
+ const orderButtonClass = computed(() => {
26
+ if (!orderDisabled.value) {
27
+ return "cursor-pointer";
28
+ }
29
+ return props.disabledOrderStyle === "muted"
30
+ ? "bg-elevated! text-dimmed! hover:bg-elevated! disabled:opacity-100! cursor-not-allowed"
31
+ : "cursor-not-allowed";
32
+ });
11
33
  </script>
12
34
 
13
35
  <template>
@@ -24,11 +46,11 @@ const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.
24
46
  focus-visible:ring-(--ui-primary)"
25
47
  >
26
48
  <div class="h-50 flex items-center justify-center">
27
- <img
28
- :src="getImage(product.image)"
49
+ <ProductMediaImage
50
+ :src="product.image"
29
51
  :alt="product.name"
30
- class="max-h-full max-w-full object-contain"
31
- >
52
+ icon-class="size-10 text-muted"
53
+ />
32
54
  </div>
33
55
  </NuxtLink>
34
56
  </template>
@@ -58,13 +80,12 @@ const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.
58
80
  />
59
81
  <UButton
60
82
  :label="t('product.actions.order')"
83
+ :icon="showOrderIcon ? icon('cart') : undefined"
61
84
  variant="solid"
62
- :color="isOutOfStock || !hasPrice ? 'neutral' : 'primary'"
63
- :disabled="isOutOfStock || !hasPrice"
64
- :class="isOutOfStock || !hasPrice
65
- ? '!bg-gray-200 !text-gray-500 !border-gray-200 hover:!bg-gray-200 cursor-not-allowed'
66
- : ''"
67
- class="flex-1 justify-center cursor-pointer focus-visible:outline-none
85
+ :color="orderDisabled ? 'neutral' : 'primary'"
86
+ :disabled="orderDisabled"
87
+ :class="orderButtonClass"
88
+ class="flex-1 justify-center focus-visible:outline-none
68
89
  focus-visible:ring-2 focus-visible:ring-(--ui-primary)"
69
90
  tabindex="0"
70
91
  @click="addToCart"
@@ -6,7 +6,7 @@ const props = defineProps<{
6
6
  }>();
7
7
 
8
8
  const { t } = useI18n();
9
- const { url, getImage } = useProductCard(() => props.product);
9
+ const { url } = useProductCard(() => props.product);
10
10
  const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.product);
11
11
  </script>
12
12
 
@@ -24,11 +24,11 @@ const { isOutOfStock, hasPrice, addToCart } = useProductCardActions(() => props.
24
24
  focus-visible:ring-(--ui-primary) rounded"
25
25
  >
26
26
  <div class="w-15 h-15 sm:w-15 sm:h-15 flex items-center justify-center">
27
- <img
28
- :src="getImage(product.image)"
27
+ <ProductMediaImage
28
+ :src="product.image"
29
29
  :alt="product.name"
30
- class="max-h-full max-w-full object-contain"
31
- >
30
+ icon-class="size-6 text-muted"
31
+ />
32
32
  </div>
33
33
  </NuxtLink>
34
34
  <div class="flex-1 min-w-0 flex flex-col gap-1">
@@ -1,5 +1,6 @@
1
1
  <script setup lang="ts">
2
- const { appName, localizeAppName, logo } = useAppConfig();
2
+ const { appName, localizeAppName } = useAppConfig();
3
+ const { logo } = useBranding();
3
4
  const { t } = useI18n();
4
5
  const { to: appUrl } = useAppUrl();
5
6
 
@@ -4,6 +4,12 @@ import { footerLinks as defaultFooterLinks, legalLinks as defaultLegalLinks, sho
4
4
  // Consumers replace the footer columns / legal links, in priority order:
5
5
  // per-request live menus (useState, e.g. the Blokkli theme from the pages app)
6
6
  // → app.config override → the layer defaults (demo's full sitemap).
7
+ //
8
+ // Headings and labels are rendered through t(), matching the header
9
+ // (MainNav/TopBar). That is what lets a tenant supply i18n keys and have its
10
+ // footer follow the language switcher; vue-i18n echoes anything that is not a
11
+ // key, so a plain string — the layer's own defaults included — renders as
12
+ // written.
7
13
  const appConfig = useAppConfig();
8
14
  const liveFooterLinks = useState<{ heading: string; links: { label: string; to: string }[] }[] | null>("cover:nav:footerLinks", () => null);
9
15
  const liveLegalLinks = useState<{ label: string; to: string }[] | null>("cover:nav:legalLinks", () => null);
@@ -70,7 +76,7 @@ const year = new Date().getFullYear();
70
76
  class="text-xs font-semibold uppercase tracking-wider
71
77
  text-dimmed dark:text-white/70 mb-4"
72
78
  >
73
- {{ group.heading }}
79
+ {{ t(group.heading) }}
74
80
  </h3>
75
81
  <ul
76
82
  role="list"
@@ -86,7 +92,7 @@ const year = new Date().getFullYear();
86
92
  class="text-sm text-muted dark:text-white/90
87
93
  hover:text-default dark:hover:text-white transition-colors"
88
94
  >
89
- {{ link.label }}
95
+ {{ t(link.label) }}
90
96
  </NuxtLink>
91
97
  </li>
92
98
  </ul>
@@ -123,7 +129,7 @@ const year = new Date().getFullYear();
123
129
  class="text-xs text-dimmed dark:text-white/70
124
130
  hover:text-default dark:hover:text-white transition-colors"
125
131
  >
126
- {{ link.label }}
132
+ {{ t(link.label) }}
127
133
  </NuxtLink>
128
134
  </nav>
129
135
 
@@ -0,0 +1,92 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * The catalog panel behind a main-nav item that carries `panel: "categories"`.
4
+ *
5
+ * The panel body only — MainNav owns the positioned, animated wrapper and the
6
+ * pointer handling, so this stays renderable on its own. The tree comes from
7
+ * useCategories(), which AppBar and MobileMenu already fetch, so this shares
8
+ * their useFetch key rather than issuing a second request.
9
+ */
10
+
11
+ /** Where "browse the whole assortment" goes — the tenant's catalog landing page. */
12
+ const CATALOG_ROUTE = "/search?q=*";
13
+
14
+ const { categories, categoryPanelColumns } = useCategories();
15
+ const { t } = useI18n();
16
+ const localePath = useLocalePath();
17
+ </script>
18
+
19
+ <template>
20
+ <div class="px-4 sm:px-6 lg:px-8 max-w-(--ui-container) mx-auto w-full py-8">
21
+ <p
22
+ v-if="!categories.length"
23
+ class="text-sm text-muted"
24
+ >
25
+ {{ t("nav.catalog.loading") }}
26
+ </p>
27
+
28
+ <div
29
+ v-else
30
+ class="grid grid-cols-2 lg:grid-cols-4 gap-x-8 gap-y-8"
31
+ >
32
+ <div
33
+ v-for="(column, index) in categoryPanelColumns"
34
+ :key="index"
35
+ class="space-y-6"
36
+ >
37
+ <div
38
+ v-for="group in column"
39
+ :key="group.to"
40
+ >
41
+ <NuxtLink
42
+ :to="group.to"
43
+ class="block text-sm font-semibold text-highlighted hover:text-primary leading-snug"
44
+ >
45
+ {{ group.label }}
46
+ </NuxtLink>
47
+
48
+ <ul
49
+ v-if="group.links.length"
50
+ role="list"
51
+ class="mt-2 space-y-1"
52
+ >
53
+ <li
54
+ v-for="link in group.links"
55
+ :key="link.to"
56
+ >
57
+ <NuxtLink
58
+ :to="link.to"
59
+ class="block text-sm text-muted hover:text-primary leading-snug"
60
+ >
61
+ {{ link.label }}
62
+ </NuxtLink>
63
+ </li>
64
+ <li v-if="group.totalSubcategoryCount > group.links.length">
65
+ <NuxtLink
66
+ :to="group.to"
67
+ class="block text-sm text-primary hover:underline"
68
+ >
69
+ {{ t("nav.catalog.showAllGroups", { count: group.totalSubcategoryCount }) }}
70
+ </NuxtLink>
71
+ </li>
72
+ </ul>
73
+ </div>
74
+ </div>
75
+ </div>
76
+
77
+ <div
78
+ v-if="categories.length"
79
+ class="mt-8 pt-6 border-t border-(--ui-border) flex items-center justify-between"
80
+ >
81
+ <NuxtLink
82
+ :to="localePath(CATALOG_ROUTE)"
83
+ class="text-sm font-medium text-primary hover:underline"
84
+ >
85
+ {{ t("nav.catalog.browseAll") }}
86
+ </NuxtLink>
87
+ <span class="text-xs text-muted">
88
+ {{ t("nav.catalog.groupCount", { count: categories.length }) }}
89
+ </span>
90
+ </div>
91
+ </div>
92
+ </template>
@@ -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