@revenexx/cover 0.2.26 → 0.2.28

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 +759 -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,158 @@
1
+ <script setup lang="ts">
2
+ /**
3
+ * Full-bleed banner slider: stacked slides that crossfade on a timer, with dot
4
+ * indicators and side arrows. Presentation only — it never resolves image URLs
5
+ * itself, so the layer stays free of an `@nuxt/image` dependency (consumers
6
+ * that have it fill the `image` slot with `<NuxtImg>`).
7
+ */
8
+ import type { ImageSlide } from "../../../interfaces/image-slider";
9
+
10
+ const props = withDefaults(defineProps<{
11
+ slides: ImageSlide[];
12
+ autoplay?: boolean;
13
+ intervalMs?: number;
14
+ /** Accessible name of the slider region; defaults to the generic label. */
15
+ ariaLabel?: string;
16
+ }>(), {
17
+ autoplay: true,
18
+ intervalMs: 7000,
19
+ ariaLabel: undefined,
20
+ });
21
+
22
+ const { t } = useI18n();
23
+ const { icon } = useIcons();
24
+
25
+ // A NuxtLink with an empty `to` renders a dead anchor, so link-less slides fall
26
+ // back to a plain element. NuxtLink itself handles external URLs.
27
+ const nuxtLink = resolveComponent("NuxtLink");
28
+
29
+ const current = ref(0);
30
+
31
+ // Below two slides there is nothing to navigate: the controls would only add
32
+ // dead hit targets over the banner.
33
+ const hasControls = computed(() => props.slides.length > 1);
34
+
35
+ const regionLabel = computed(() => props.ariaLabel || t("slider.region"));
36
+
37
+ function go(index: number): void {
38
+ const total = props.slides.length;
39
+ if (total > 0) {
40
+ current.value = ((index % total) + total) % total;
41
+ }
42
+ }
43
+
44
+ // Slides are added, removed and reordered live in the page editor; a stale
45
+ // index would leave every slide faded out.
46
+ watch(() => props.slides.length, (total) => {
47
+ if (current.value >= total) {
48
+ current.value = 0;
49
+ }
50
+ });
51
+
52
+ let timer: ReturnType<typeof setInterval> | null = null;
53
+ // Read on mount, not in setup: `matchMedia` does not exist during SSR.
54
+ const reducedMotion = ref(false);
55
+
56
+ function stop(): void {
57
+ if (timer !== null) {
58
+ clearInterval(timer);
59
+ timer = null;
60
+ }
61
+ }
62
+
63
+ // Always clears first, so the rapid pointerleave/pointerenter pairs a mouse
64
+ // produces across the arrows can't stack up intervals.
65
+ function start(): void {
66
+ stop();
67
+ if (props.autoplay && !reducedMotion.value && props.slides.length > 1) {
68
+ timer = setInterval(() => go(current.value + 1), props.intervalMs);
69
+ }
70
+ }
71
+
72
+ onMounted(() => {
73
+ reducedMotion.value = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
74
+ start();
75
+ });
76
+
77
+ onBeforeUnmount(stop);
78
+ </script>
79
+
80
+ <template>
81
+ <!-- No placeholder background behind the slides: at a fractional layout
82
+ height (w-screen ÷ the aspect ratio rarely lands on a whole pixel) the
83
+ browser's rounding exposes a hairline of it under the cover image, which
84
+ reads as a dark border. eltric paints one; we deliberately don't. -->
85
+ <section
86
+ class="relative"
87
+ :aria-label="regionLabel"
88
+ @pointerenter="stop"
89
+ @pointerleave="start"
90
+ @focusin="stop"
91
+ @focusout="start"
92
+ >
93
+ <div class="relative aspect-[3/1] sm:aspect-[3.2/1] overflow-hidden">
94
+ <component
95
+ :is="slide.link ? nuxtLink : 'div'"
96
+ v-for="(slide, index) in props.slides"
97
+ :key="slide.key"
98
+ :to="slide.link || undefined"
99
+ class="absolute inset-0 transition-opacity duration-700"
100
+ :class="index === current ? 'opacity-100' : 'opacity-0 pointer-events-none'"
101
+ :aria-hidden="index !== current"
102
+ :tabindex="slide.link ? (index === current ? 0 : -1) : undefined"
103
+ :aria-label="slide.link ? [slide.title, slide.cta].filter(Boolean).join(' — ') || slide.alt : undefined"
104
+ >
105
+ <slot
106
+ name="image"
107
+ :slide="slide"
108
+ :index="index"
109
+ :is-active="index === current"
110
+ img-class="absolute inset-0 size-full object-cover"
111
+ :loading="index === 0 ? 'eager' : 'lazy'"
112
+ :fetchpriority="index === 0 ? 'high' : 'low'"
113
+ >
114
+ <img
115
+ :src="slide.src"
116
+ :alt="slide.alt"
117
+ class="absolute inset-0 size-full object-cover"
118
+ :loading="index === 0 ? 'eager' : 'lazy'"
119
+ :fetchpriority="index === 0 ? 'high' : 'low'"
120
+ >
121
+ </slot>
122
+ </component>
123
+ </div>
124
+
125
+ <div
126
+ v-if="hasControls"
127
+ class="absolute bottom-3 sm:bottom-5 inset-x-0 flex items-center justify-center gap-2"
128
+ >
129
+ <button
130
+ v-for="(slide, index) in props.slides"
131
+ :key="`dot-${slide.key}`"
132
+ type="button"
133
+ class="h-2 rounded-full transition-all cursor-pointer"
134
+ :class="index === current ? 'w-8 bg-white' : 'w-2 bg-white/50 hover:bg-white/80'"
135
+ :aria-label="t('slider.slide', { index: index + 1 })"
136
+ :aria-current="index === current"
137
+ @click="go(index)"
138
+ />
139
+ </div>
140
+
141
+ <template v-if="hasControls">
142
+ <button
143
+ v-for="step in [-1, 1]"
144
+ :key="step"
145
+ type="button"
146
+ class="hidden sm:flex absolute top-1/2 -translate-y-1/2 size-10 items-center justify-center rounded-full bg-black/30 text-white hover:bg-black/50 transition-colors cursor-pointer"
147
+ :class="step === -1 ? 'left-3' : 'right-3'"
148
+ :aria-label="step === -1 ? t('slider.previous') : t('slider.next')"
149
+ @click="go(current + step)"
150
+ >
151
+ <UIcon
152
+ :name="icon(step === -1 ? 'chevron-left' : 'chevron-right')"
153
+ class="size-5"
154
+ />
155
+ </button>
156
+ </template>
157
+ </section>
158
+ </template>
@@ -0,0 +1,22 @@
1
+ /** Per-request state a layer above may publish the active tenant's logo into. */
2
+ export const BRANDING_LOGO_STATE_KEY = "cover:branding:logo";
3
+
4
+ /**
5
+ * The storefront logo LayoutAppLogo renders: whatever a layer above published
6
+ * for this request, else the app's own `app.config.logo`.
7
+ *
8
+ * The indirection exists because `app.config` is a build-time singleton while a
9
+ * tenant is a per-request cookie — the same reason the nav menus travel through
10
+ * `cover:nav:*` state rather than app.config. This layer knows nothing about
11
+ * tenants; it only agrees on the state key. The cover theme fills it from
12
+ * `/api/blokkli/branding` (app/plugins/branding.ts), and an app that ships no
13
+ * such plugin keeps its static logo with nothing to configure.
14
+ */
15
+ export function useBranding() {
16
+ const { logo } = useAppConfig();
17
+ const tenantLogo = useState<string | null>(BRANDING_LOGO_STATE_KEY, () => null);
18
+
19
+ return {
20
+ logo: computed<string>(() => tenantLogo.value ?? logo),
21
+ };
22
+ }
@@ -0,0 +1,42 @@
1
+ import { brandsApi } from "../api/brands";
2
+ import type { ShopBrand } from "../interfaces/brand";
3
+
4
+ export interface BrandsOptions {
5
+ /** Unique fetch key per surface — two grids on one page must not share a payload. */
6
+ readonly key: string;
7
+ /** How many brands to ask for, ranked by article count descending. */
8
+ readonly limit: MaybeRefOrGetter<number>;
9
+ }
10
+
11
+ /**
12
+ * The catalogue's manufacturers, ranked by article count.
13
+ *
14
+ * The URL is a getter and the fetch key NAMES THE LIMIT, so changing how many
15
+ * brands a grid asks for refetches instead of serving the previous answer —
16
+ * same shape as useSubcategoryTiles. Nuxt does not watch the request URL: its
17
+ * default watch is `[...watchSources, _fetchOptions]`, and an explicit key also
18
+ * drops the URL out of the generated key, so with a constant key nothing
19
+ * observes `limit` and the grid keeps its first response forever. Keying per
20
+ * limit also survives a block re-mount in the blokkli editor, which a constant
21
+ * key would answer from the payload cache.
22
+ *
23
+ * `immediate` is deliberately left unset: `immediate: false` is what registers
24
+ * Nuxt's onServerPrefetch, and turning it off would server-render the grid empty
25
+ * and race the in-flight fetch into payload.data (see useProductListing). Its
26
+ * default `true` is also what lets a key change re-execute at all.
27
+ */
28
+ export const useBrands = (options: BrandsOptions) => {
29
+ const { locale } = useI18n();
30
+ const limit = computed(() => toValue(options.limit));
31
+
32
+ const { data: brands, status, error } = useFetch<ShopBrand[]>(
33
+ () => brandsApi.list(limit.value),
34
+ {
35
+ key: computed(() => `brands:${options.key}:${limit.value}`),
36
+ headers: computed(() => ({ "x-locale": locale.value })),
37
+ default: () => [] as ShopBrand[],
38
+ },
39
+ );
40
+
41
+ return { brands, status, error };
42
+ };
@@ -2,6 +2,55 @@ import type { NavigationMenuItem } from "@nuxt/ui";
2
2
 
3
3
  import { categoriesApi } from "../api/categories";
4
4
  import type { ProductCategory } from "../config/navigation";
5
+ import type { CategoryPanelGroup } from "../interfaces/category";
6
+
7
+ /** Subcategory links a catalog panel group shows before the "all N groups" link. */
8
+ export const CATEGORY_PANEL_SUBCATEGORY_LIMIT = 5;
9
+
10
+ /** Columns the catalog panel spreads the category groups across. */
11
+ export const CATEGORY_PANEL_COLUMN_COUNT = 4;
12
+
13
+ /**
14
+ * Cap each category's subcategory list for the header's catalog panel, keeping
15
+ * the true subcategory count alongside so the panel can offer "all N groups".
16
+ *
17
+ * Pure, with route resolution injected: the cap decides what the whole catalog
18
+ * looks like in the header, and pinning it in a unit test is only possible
19
+ * without a Nuxt context.
20
+ */
21
+ export function buildCategoryPanelGroups(
22
+ categories: readonly ProductCategory[],
23
+ resolvePath: (path: string) => string,
24
+ limit: number = CATEGORY_PANEL_SUBCATEGORY_LIMIT,
25
+ ): CategoryPanelGroup[] {
26
+ return categories.map((cat): CategoryPanelGroup => ({
27
+ label: cat.label,
28
+ to: resolvePath(`/category/${cat.slug}`),
29
+ links: cat.subcategories.slice(0, limit).map(sub => ({
30
+ label: sub.label,
31
+ to: resolvePath(`/category/${cat.slug}/${sub.slug}`),
32
+ })),
33
+ totalSubcategoryCount: cat.subcategories.length,
34
+ }));
35
+ }
36
+
37
+ /**
38
+ * Spread the groups across the panel's columns, stacking consecutive groups in
39
+ * each one. Slicing by `ceil(total / columnCount)` fills the leading columns
40
+ * first, so a category count that does not divide evenly yields fewer, evenly
41
+ * tall columns rather than one long tail — 5 groups become 2/2/1, not 2/1/1/1.
42
+ */
43
+ export function chunkIntoColumns(
44
+ groups: readonly CategoryPanelGroup[],
45
+ columnCount: number = CATEGORY_PANEL_COLUMN_COUNT,
46
+ ): CategoryPanelGroup[][] {
47
+ const size = Math.ceil(groups.length / columnCount) || 1;
48
+ const columns: CategoryPanelGroup[][] = [];
49
+ for (let i = 0; i < groups.length; i += size) {
50
+ columns.push(groups.slice(i, i + size));
51
+ }
52
+ return columns;
53
+ }
5
54
 
6
55
  export const useCategories = () => {
7
56
  const localePath = useLocalePath();
@@ -25,5 +74,10 @@ export const useCategories = () => {
25
74
  })),
26
75
  );
27
76
 
28
- return { categories, categoryNavItems, status, error };
77
+ /** The same tree as categoryNavItems, capped and column-chunked for the panel. */
78
+ const categoryPanelColumns = computed<CategoryPanelGroup[][]>(() =>
79
+ chunkIntoColumns(buildCategoryPanelGroups(categories.value ?? [], localePath)),
80
+ );
81
+
82
+ return { categories, categoryNavItems, categoryPanelColumns, status, error };
29
83
  };
@@ -1,4 +1,3 @@
1
- import { imagesApi } from "../api/images";
2
1
  import { productApi } from "../api/product";
3
2
  import { getPriceWithOptionalTax } from "../composables/useProducts";
4
3
  import type {
@@ -14,6 +13,10 @@ export const useProductDetail = (id: MaybeRefOrGetter<string>) => {
14
13
  const { public: { locale, taxIncludedPrices } } = useRuntimeConfig();
15
14
  const currency = useDisplayCurrency();
16
15
  const { locale: activeLocale } = useI18n();
16
+ // One rule for every catalogue image, shared with the listing cards: live
17
+ // values (absolute URL or `/cdn/` path) load as-is, demo filenames go through
18
+ // the bundled-asset endpoint.
19
+ const { getDetailImage } = useProductImage();
17
20
 
18
21
  // Kept as one object (rather than destructured straight away) so `ready()`
19
22
  // below can await the AsyncData thenable — destructuring drops it, which is
@@ -111,9 +114,7 @@ export const useProductDetail = (id: MaybeRefOrGetter<string>) => {
111
114
  return displayPrice.toLocaleString(locale, { style: "currency", currency: currency.value });
112
115
  };
113
116
 
114
- const getDetailImageUrl = (filename: string): string => {
115
- return imagesApi.detail(filename);
116
- };
117
+ const getDetailImageUrl = (filename: string): string => getDetailImage(filename);
117
118
 
118
119
  /**
119
120
  * Resolves once the initial detail request has settled — for pages that own
@@ -0,0 +1,35 @@
1
+ import { productApi } from "../api/product";
2
+ import type { ProductAssociationGroup, ProductAssociations } from "../interfaces/product-associations";
3
+
4
+ const EMPTY: ProductAssociations = { groups: [] };
5
+
6
+ /**
7
+ * The articles this product relates to, grouped by relation type — accessories,
8
+ * mandatory accessories, spare parts, whatever the tenant models.
9
+ *
10
+ * Fetched server-side with an explicit key so the tiles are in the SSR payload;
11
+ * without one the client refetches on hydration and the grids blink empty over
12
+ * a correctly server-rendered page.
13
+ *
14
+ * No offer loading here, unlike the variants table: an association tile shows a
15
+ * name and an article number, never a price, so there is nothing to hydrate
16
+ * after first paint.
17
+ */
18
+ export function useProductAssociations(id: MaybeRefOrGetter<string>) {
19
+ const { locale: activeLocale } = useI18n();
20
+
21
+ const { data, status, error, refresh } = useFetch<ProductAssociations>(
22
+ () => productApi.associations(toValue(id)),
23
+ {
24
+ headers: computed(() => ({ "x-locale": activeLocale.value })),
25
+ key: () => `product-associations:${toValue(id)}`,
26
+ default: () => EMPTY,
27
+ // Without this guard an empty id requests `/api/product//associations`.
28
+ immediate: Boolean(toValue(id)),
29
+ },
30
+ );
31
+
32
+ const groups = computed<ProductAssociationGroup[]>(() => [...(data.value?.groups ?? [])]);
33
+
34
+ return { groups, status, error, refresh };
35
+ }
@@ -1,12 +1,45 @@
1
1
  import { imagesApi } from "../api/images";
2
2
 
3
+ /**
4
+ * Resolution of a catalogue image value to a loadable src.
5
+ *
6
+ * Two shapes reach the client. Live catalogue values are already resolvable —
7
+ * an absolute URL from the PIM's media CDN, or a root-relative `/cdn/` path the
8
+ * BFF built from a storage key (see `liveImageSrc` in
9
+ * `server/utils/liveCatalog.ts`). Demo values are bare filenames served from the
10
+ * bundled asset dir by `/api/images/{list,detail}/<filename>`.
11
+ *
12
+ * Anything already resolvable must therefore pass through untouched: wrapped in
13
+ * an endpoint path it becomes `/api/images/detail/https://…`, which the handler
14
+ * rejects (a filename is validated against its own basename) — that is exactly
15
+ * why the product gallery rendered no live images.
16
+ */
17
+ function isResolvable(name: string): boolean {
18
+ return /^https?:\/\//.test(name) || name.startsWith("/");
19
+ }
20
+
3
21
  export function useProductImage() {
22
+ /** Listing/card images (`ProductList.image`). */
4
23
  const getImage = (name: string): string => {
5
- if (name.startsWith("/") || name.startsWith("http")) {
24
+ if (!name) {
25
+ return "";
26
+ }
27
+ if (isResolvable(name)) {
6
28
  return name;
7
29
  }
8
30
  return imagesApi.list(name);
9
31
  };
10
32
 
11
- return { getImage };
33
+ /** Detail gallery images (`ProductDetailImage.url`). */
34
+ const getDetailImage = (name: string): string => {
35
+ if (!name) {
36
+ return "";
37
+ }
38
+ if (isResolvable(name)) {
39
+ return name;
40
+ }
41
+ return imagesApi.detail(name);
42
+ };
43
+
44
+ return { getImage, getDetailImage };
12
45
  }
@@ -0,0 +1,46 @@
1
+ import { productApi } from "../api/product";
2
+ import type { ProductVariant, ProductVariants } from "../interfaces/product-variants";
3
+
4
+ const EMPTY: ProductVariants = { variants: [], axes: [], model: null };
5
+
6
+ /**
7
+ * The sibling articles of a product's model, with the axes that distinguish
8
+ * them.
9
+ *
10
+ * Data only — the table's own state (search, axis filters, availability
11
+ * toggle, sorting) lives in `ProductDetailVariants`, which owns that UI.
12
+ *
13
+ * Fetched server-side with an explicit key so the rows are in the SSR payload;
14
+ * without one the client refetches on hydration and the table blinks empty
15
+ * over a correctly server-rendered page. Prices are NOT part of this: they are
16
+ * the Offer domain, batched into one request after first paint, which is why
17
+ * the price column renders skeletons on the server.
18
+ */
19
+ export function useProductVariants(id: MaybeRefOrGetter<string>) {
20
+ const { locale: activeLocale } = useI18n();
21
+
22
+ const { data, status, error, refresh } = useFetch<ProductVariants>(
23
+ () => productApi.variants(toValue(id)),
24
+ {
25
+ headers: computed(() => ({ "x-locale": activeLocale.value })),
26
+ key: () => `product-variants:${toValue(id)}`,
27
+ default: () => EMPTY,
28
+ // Without this guard an empty id requests `/api/product//variants`.
29
+ immediate: Boolean(toValue(id)),
30
+ },
31
+ );
32
+
33
+ const variants = computed<ProductVariant[]>(() => [...(data.value?.variants ?? [])]);
34
+ const axes = computed(() => [...(data.value?.axes ?? [])]);
35
+ const model = computed(() => data.value?.model ?? null);
36
+
37
+ // Price + availability for every row in ONE request, client-side only.
38
+ const { loadOffers } = useOffers();
39
+ watch(variants, (rows) => {
40
+ if (rows.length > 0) {
41
+ void loadOffers(rows.map(({ id: rowId, sku }) => ({ id: rowId, sku })));
42
+ }
43
+ }, { immediate: true });
44
+
45
+ return { variants, axes, model, status, error, refresh };
46
+ }
@@ -59,17 +59,28 @@ export const useSearchListing = (options: SearchListingOptions) => {
59
59
  facetFields: ["category", "subcategory", "manufacturer", "available"],
60
60
  });
61
61
 
62
- const title = computed(() =>
63
- query.value
62
+ // `?q=*` is the match-all link (Typesense's native catch-all query): the
63
+ // full catalog, presented as such instead of as results for a "*" term.
64
+ const isCatalog = computed(() => query.value.trim() === "*");
65
+
66
+ const title = computed(() => {
67
+ if (isCatalog.value) {
68
+ return t("search.results.catalogTitle");
69
+ }
70
+ return query.value
64
71
  ? t("search.results.title", { query: query.value })
65
- : t("search.results.initialTitle"),
66
- );
72
+ : t("search.results.initialTitle");
73
+ });
67
74
 
68
75
  const breadcrumb = computed(() => {
69
76
  const items: { label: string; to?: string }[] = [
70
77
  { label: t("nav.home"), to: localePath("/") },
71
78
  ];
72
- items.push({ label: query.value || t("search.results.initialTitle") });
79
+ items.push({
80
+ label: isCatalog.value
81
+ ? t("search.results.catalogTitle")
82
+ : query.value || t("search.results.initialTitle"),
83
+ });
73
84
  return items;
74
85
  });
75
86
 
@@ -0,0 +1,36 @@
1
+ import type { MaybeRefOrGetter } from "vue";
2
+
3
+ import { categoriesApi } from "../api/categories";
4
+ import type { SubcategoryTile } from "../interfaces/category";
5
+
6
+ /**
7
+ * One category's subcategories, enriched with product counts and preview images
8
+ * by the BFF (see server/api/categories/[slug]/subcategories.get.ts).
9
+ *
10
+ * Separate from useCategories() on purpose: the navigation tree is fetched on
11
+ * every page and must stay cheap, while these two extra facts cost a product
12
+ * index query and only the category page needs them.
13
+ *
14
+ * The URL is a getter and the fetch key names the slug, so navigating between
15
+ * categories refetches instead of serving the previous category's tiles.
16
+ *
17
+ * Expects a resolved slug. An empty one yields an unmatched route and leaves
18
+ * `tiles` at its empty default until a real slug arrives — the callers all sit
19
+ * inside the category shell, which resolves the slug before rendering them.
20
+ */
21
+ export const useSubcategoryTiles = (categorySlug: MaybeRefOrGetter<string>) => {
22
+ const { locale } = useI18n();
23
+
24
+ const slug = computed(() => toValue(categorySlug));
25
+
26
+ const { data: tiles, status, error } = useFetch<SubcategoryTile[]>(
27
+ () => categoriesApi.subcategories(slug.value),
28
+ {
29
+ key: computed(() => `subcategory-tiles:${slug.value}`),
30
+ headers: computed(() => ({ "x-locale": locale.value })),
31
+ default: () => [] as SubcategoryTile[],
32
+ },
33
+ );
34
+
35
+ return { tiles, status, error };
36
+ };
@@ -58,11 +58,20 @@ export const shopContact = {
58
58
  /* (topbar · header · main nav · account area). Labels are i18n keys. */
59
59
  /* ------------------------------------------------------------------ */
60
60
 
61
+ /**
62
+ * A generated dropdown panel a navigation item can open next to its link.
63
+ * The menu only names the kind — the renderer owns the contents, so a tenant
64
+ * cannot author the catalog by hand and cannot let it drift from the real tree.
65
+ */
66
+ export type MenuPanelKind = "categories";
67
+
61
68
  export interface NavItem {
62
69
  /** i18n key, resolved by the rendering component */
63
70
  labelKey: string;
64
71
  to: string;
65
72
  icon?: string;
73
+ /** Opens a generated dropdown panel next to the link. */
74
+ panel?: MenuPanelKind;
66
75
  }
67
76
 
68
77
  export interface TopbarUsp {
@@ -8,6 +8,7 @@ export const palette: Record<string, Record<number, string>> = {
8
8
  zinc: { 50: "oklch(98.5% 0 0)", 100: "oklch(96.7% 0.001 286.375)", 200: "oklch(92% 0.004 286.32)", 300: "oklch(87.1% 0.006 286.286)", 400: "oklch(70.5% 0.015 286.067)", 500: "oklch(55.2% 0.016 285.938)", 600: "oklch(44.2% 0.017 285.786)", 700: "oklch(37% 0.013 285.805)", 800: "oklch(27.4% 0.006 286.033)", 900: "oklch(21% 0.006 285.885)", 950: "oklch(14.1% 0.005 285.823)" },
9
9
  slate: { 50: "oklch(98.4% 0.003 247.858)", 100: "oklch(96.8% 0.007 247.896)", 200: "oklch(92.9% 0.013 255.508)", 300: "oklch(86.9% 0.022 252.894)", 400: "oklch(70.4% 0.04 256.788)", 500: "oklch(55.4% 0.046 257.417)", 600: "oklch(44.6% 0.043 257.281)", 700: "oklch(37.2% 0.044 257.287)", 800: "oklch(27.9% 0.041 260.031)", 900: "oklch(20.8% 0.042 265.755)", 950: "oklch(12.9% 0.042 264.695)" },
10
10
  stone: { 50: "oklch(98.5% 0.001 106.423)", 100: "oklch(97% 0.001 106.424)", 200: "oklch(92.3% 0.003 48.717)", 300: "oklch(86.9% 0.005 56.366)", 400: "oklch(70.9% 0.01 56.259)", 500: "oklch(55.3% 0.013 58.071)", 600: "oklch(44.4% 0.011 73.639)", 700: "oklch(37.4% 0.01 67.558)", 800: "oklch(26.8% 0.007 34.298)", 900: "oklch(21.6% 0.006 56.043)", 950: "oklch(14.7% 0.004 49.25)" },
11
+ navy: { 50: "#f2f3f6", 100: "#e6e6ed", 200: "#c7c9d7", 300: "#999db5", 400: "#596087", 500: "#000a47", 600: "#00093e", 700: "#000835", 800: "#00062b", 900: "#000420", 950: "#000314" },
11
12
  };
12
13
 
13
14
  export const COLOR_SHADES = [50, 100, 200, 300, 400, 500, 600, 700, 800, 900, 950] as const;