@shopbite-de/storefront 2.1.0 → 2.1.1

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/CLAUDE.md CHANGED
@@ -134,8 +134,8 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
134
134
  - Components style only with the `--sb-*` colour tokens and `--font-sb-display`/`--font-sb-body` (the `--font` prefix makes @nuxt/fonts resolve the family and add metric fallbacks) through the `sb-*` utilities (`bg-sb-surface`, `text-sb-ink-muted`, `font-display`, `rounded-sb-control`). No colour mode switch: the preset fixes light or dark.
135
135
  - Base components live in `app/components/Sb/` (`SbButton`, `SbIconButton`, `SbSegmentedControl`, `SbSheet`, `SbChoiceGroup`, `SbCheckbox`, `SbField` + `SbInput`, `SbSelect` (native), `SbStepper`, `SbChip`, `SbStatusPill`, `SbStars`, `SbConfirmDialog`, `SbIcon` with inline stroke icons). Behaviour and accessibility come from Reka UI (radio groups, checkbox, dialog and alert dialog with focus trap). Every control is at least 44 px and has a visible focus ring; icon-only buttons need a `label`; toggles use `aria-pressed` with a stable name. Hide a base component responsively with a wrapper (`<span class="hidden sm:block">`): its own `inline-flex` wins over a `hidden` passed as class. Elements focused only by script (`tabindex="-1"`) get no focus ring. Entry animations go behind `motion-safe:` (a `motion-reduce:animate-none` loses against `data-[state=open]:animate-…`).
136
136
  - No toasts (removed in #445, other responses to be designed): results and errors show where they happen, e.g. `role="alert"` boxes in forms and the checkout, `role="status"` regions, the voucher error at its field.
137
- - Menu (#441): `Category/Listing.vue` has three columns from `lg` (`MenuCategoryIndex` word list, the list, `MenuCartPanel`), `NavigationMobileTop` below `lg`; `MenuSectionHeader` and `MenuBonCard` (one column, number strip, `photo` for the `bonPhoto` view). The card's button adds a product straight to the cart unless `productNeedsChoice()` (a parent with variants, `childCount` in the listing projection), which opens the quick view; extras stay optional. Cards hydrate on approach (`hydrateWhenVisible`), so a click on a card that has not hydrated yet is lost. Filters live in an `SbSheet`, sorting is an `SbSelect` (`toSortingOptions()`).
138
- - Product sheet (#442): `SbSheet` with a bon header (number strip, name as `DialogTitle`, diet and description as `DialogDescription`); `Configurator` shows variants as `SbChoiceGroup` (required), `DeselectIngredient` as `SbChip` ingredient chips (pressed = included), `CrossSelling` as `SbCheckbox` rows with a search, `Detail` a sticky footer with `SbStepper` and the add button.
137
+ - Menu (#441): `Category/Listing.vue` has three columns from `lg` (`MenuCategoryIndex` word list, the list, `MenuCartPanel`), `NavigationMobileTop` below `lg` (section chips; the open section's sub-categories as a second chip row led by "Alle", the current chip scrolls into view); `MenuSectionHeader` and `MenuBonCard` (one column, number strip, `photo` for the `bonPhoto` view). The card's button adds a product straight to the cart unless `productNeedsChoice()` (a parent with variants, `childCount` in the listing projection), which opens the quick view; extras stay optional. Cards hydrate on approach (`hydrateWhenVisible`), so a click on a card that has not hydrated yet is lost. Filters live in an `SbSheet`, sorting is an `SbSelect` (`toSortingOptions()`).
138
+ - Product sheet (#442): `SbSheet` with a bon header (a custom `#header` gets the full width below a toolbar with the `#actions` and the close button; next to the buttons a long name broke after four letters on a 393 px phone) (number strip, name as `DialogTitle`, diet and description as `DialogDescription`); `Configurator` shows variants as `SbChoiceGroup` (required), `DeselectIngredient` as `SbChip` ingredient chips (pressed = included), `CrossSelling` as `SbCheckbox` rows with a search, `Detail` a sticky footer with `SbStepper` and the add button.
139
139
  - Cart and checkout (#443): `MenuOrderMode` (`useOrderMode`) and the checkout's shipping section list ALL active shipping methods (`useShippingMethodChoice`, `onlyAvailable: false`), because a delivery-area rule on the shipping city never matches before the guest has an address (La Fattoria, fixed in 2.0.3); `useCheckoutMethodGuard` switches only a blocked payment method, a blocked shipping method is reported in the checkout and never switched to pickup. It shows the shipping methods as an `SbSegmentedControl` only when there are two to four. The header cart opens an `SbSheet`; `Cart/Item` uses `SbStepper` (remove at 1). The checkout is one page, `/bestellung/kasse` (the old step routes 301 there, `routeRules`): numbered sections Lieferung oder Abholung (`CheckoutPaymentAndDelivery part="shipping"`), Wann, Ihre Angaben (`CheckoutLoginOrRegister` with Reka tabs, `UserRegistrationForm` (logic in `useRegistrationForm`) / `UserLoginForm`, or `UserDetail`), Bezahlung (`part="payment"`) and the order card in `Checkout/Summary.vue`; the order button says "Zahlungspflichtig bestellen" (§ 312j BGB). Forms validate with Zod on submit and show errors at the fields plus a focused summary in form order; `AddressFields` sets `autocomplete`.
140
140
  - Order and account (#445): `/bestellung/<id>/erfolg` and `/bestellung/<id>` render `OrderConfirmation` (`OrderDetail`: facts incl. the wished time from the `customerComment`, receipt lines, totals; call card), `/bestellung/<id>/fehler` a payment retry. Login, registration, password pages and the registration confirmation render in `UserAuthPanel`; the account pages in `layouts/account.vue` (link navigation with `aria-current`) with `UserAccountHeader`; `AddressForm` (also used when an address is edited in the checkout). Irreversible actions confirm with `SbConfirmDialog` (focus starts on "Abbrechen"). Search, contact (`useContactForm`), wishlist (`useWishlistEntries`, #467), content pages and `error.vue` (with its own `Header`/`Footer`, because the error page replaces `app.vue`) use the same pieces.
141
141
  - Home page (#444): `pages/index.vue` renders `HomeHero` (kicker, `[highlight]{.text-primary}` part in the accent colour via `splitHighlight()`, buttons from `hero.links`, live status, rating card from the Google `usp`; the photo is `hero.image` with the blurred video `hero.poster` as fallback, cropped 4:5 at `hero.imagePosition` (object-position); it sits in a `<picture>` with a `min-width: 640px` source, so phones load a 1 px GIF), `HomeFacts` (`features`), `HomeCategories` (word list, `useHomeMenuCategories`; a wide first category image switches to a full-width photo below the words, and `sizes` asks for the width the crop needs, since thumbnails are picked by width), `HomeHighlights` (top sellers as bon cards), `HomeRestaurant` (`gallery` + opening hours in the SSR HTML) and the two-column `HomeFaq`; `cta` and `mittagstisch` in `content/index.yml` are not shown.
@@ -1,30 +1,119 @@
1
1
  <script setup lang="ts">
2
+ import type { Schemas } from "#shopware";
2
3
  import { useNavigation } from "~/composables/useNavigation";
3
4
 
4
5
  /**
5
- * Menu categories as a horizontally scrolling row on phones and tablets
6
+ * Menu categories as horizontally scrolling rows on phones and tablets
6
7
  * (#445); the desktop menu has the word-list index (MenuCategoryIndex).
8
+ * The first row holds the menu sections. When the open section has
9
+ * sub-categories (La Fattoria: Fleischgerichte → Vom Rind, Hähnchen …),
10
+ * a second row lists them, led by "Alle" for the section itself; deeper
11
+ * levels follow in the same row. The current chip scrolls into view.
7
12
  */
8
- const { menuCardMenu } = useNavigation(true);
13
+ const { menuCardNavigation } = useNavigation(true);
9
14
  const route = useRoute();
10
15
 
16
+ type Chip = { label: string; to: string };
17
+
18
+ const normalize = (path: string) =>
19
+ decodeURI(path).replace(/\/+$/, "").toLowerCase();
20
+
11
21
  const isCurrent = (to?: string) =>
12
- !!to && decodeURI(route.path).toLowerCase() === decodeURI(to).toLowerCase();
22
+ !!to && normalize(route.path) === normalize(to);
23
+
24
+ function toChip(category: Schemas["Category"]): Chip {
25
+ return {
26
+ label: category.translated?.name ?? category.name ?? "",
27
+ to: category.seoUrl ?? "",
28
+ };
29
+ }
30
+
31
+ function descendants(category: Schemas["Category"]): Schemas["Category"][] {
32
+ return (category.children ?? []).flatMap((child) => [
33
+ child,
34
+ ...descendants(child),
35
+ ]);
36
+ }
37
+
38
+ const sections = computed(() => menuCardNavigation.value ?? []);
39
+
40
+ // The section the current page belongs to: itself or one of its children.
41
+ const activeSection = computed(() =>
42
+ sections.value.find(
43
+ (section) =>
44
+ isCurrent(section.seoUrl ?? undefined) ||
45
+ descendants(section).some((child) =>
46
+ isCurrent(child.seoUrl ?? undefined),
47
+ ),
48
+ ),
49
+ );
50
+
51
+ const subChips = computed<Chip[]>(() => {
52
+ const section = activeSection.value;
53
+ if (!section) return [];
54
+ const children = descendants(section).map(toChip);
55
+ if (!children.length) return [];
56
+ return [{ label: "Alle", to: section.seoUrl ?? "" }, ...children];
57
+ });
58
+
59
+ const nav = ref<HTMLElement | null>(null);
60
+
61
+ // Long rows scroll sideways: bring the current chips into view.
62
+ function revealCurrent() {
63
+ nav.value
64
+ ?.querySelectorAll<HTMLElement>('[aria-current="page"], [data-section]')
65
+ .forEach((chip) =>
66
+ chip.scrollIntoView({ block: "nearest", inline: "center" }),
67
+ );
68
+ }
69
+
70
+ onMounted(revealCurrent);
71
+ watch(
72
+ () => route.path,
73
+ () => nextTick(revealCurrent),
74
+ );
75
+
76
+ const chipClass =
77
+ "flex min-h-11 items-center rounded-sb-control px-3.5 font-semibold whitespace-nowrap focus-visible:outline-3 focus-visible:-outline-offset-3 focus-visible:outline-sb-focus";
13
78
  </script>
14
79
 
15
80
  <template>
16
81
  <nav
17
- v-if="menuCardMenu.length"
82
+ v-if="sections.length"
83
+ ref="nav"
18
84
  aria-label="Kategorien der Speisekarte"
19
85
  class="border-b border-sb-line bg-sb-bg/95 font-body backdrop-blur-sm"
20
86
  >
21
87
  <ul class="flex gap-1 overflow-x-auto px-4 py-2 sm:px-6">
22
- <li v-for="item in menuCardMenu" :key="item.to ?? item.label">
88
+ <li v-for="section in sections" :key="section.id">
89
+ <NuxtLink
90
+ :to="section.seoUrl ?? ''"
91
+ :aria-current="isCurrent(section.seoUrl ?? '') ? 'page' : undefined"
92
+ :data-section="section === activeSection ? '' : undefined"
93
+ :class="[
94
+ chipClass,
95
+ section === activeSection
96
+ ? 'bg-sb-ink text-sb-bg'
97
+ : 'text-sb-ink hover:bg-sb-muted',
98
+ ]"
99
+ >{{ toChip(section).label }}</NuxtLink
100
+ >
101
+ </li>
102
+ </ul>
103
+ <ul
104
+ v-if="subChips.length"
105
+ :aria-label="`Unterkategorien von ${toChip(activeSection!).label}`"
106
+ class="flex gap-1 overflow-x-auto border-t border-sb-line px-4 py-2 text-[15px] sm:px-6"
107
+ >
108
+ <li v-for="chip in subChips" :key="chip.to">
23
109
  <NuxtLink
24
- :to="item.to"
25
- :aria-current="isCurrent(item.to) ? 'page' : undefined"
26
- class="flex min-h-11 items-center rounded-sb-control px-3.5 font-semibold whitespace-nowrap text-sb-ink hover:bg-sb-muted focus-visible:outline-3 focus-visible:-outline-offset-3 focus-visible:outline-sb-focus aria-[current=page]:bg-sb-ink aria-[current=page]:text-sb-bg"
27
- >{{ item.label }}</NuxtLink
110
+ :to="chip.to"
111
+ :aria-current="isCurrent(chip.to) ? 'page' : undefined"
112
+ :class="[
113
+ chipClass,
114
+ 'border border-sb-line text-sb-ink hover:bg-sb-muted aria-[current=page]:border-sb-ink aria-[current=page]:bg-sb-muted',
115
+ ]"
116
+ >{{ chip.label }}</NuxtLink
28
117
  >
29
118
  </li>
30
119
  </ul>
@@ -39,25 +39,43 @@ const open = defineModel<boolean>("open", { default: false });
39
39
  <div class="flex justify-center pt-2.5 md:hidden" aria-hidden="true">
40
40
  <span class="h-1 w-9 rounded-full bg-sb-line" />
41
41
  </div>
42
- <header class="flex items-start gap-3 px-5 pt-3 pb-2 md:pt-6">
42
+ <!-- A custom header (the product sheet's bon card) gets the full
43
+ width below a toolbar with the actions and the close button:
44
+ next to three 44 px buttons a long dish name broke after four
45
+ letters on a 393 px phone. -->
46
+ <header
47
+ v-if="$slots.header"
48
+ class="flex flex-col gap-2 px-5 pt-2 pb-2 md:pt-4"
49
+ >
50
+ <div class="flex items-center justify-end gap-2">
51
+ <slot name="actions" />
52
+ <DialogClose as-child>
53
+ <SbIconButton label="Schließen">
54
+ <SbIcon name="close" />
55
+ </SbIconButton>
56
+ </DialogClose>
57
+ </div>
58
+ <div class="min-w-0">
59
+ <slot name="header" />
60
+ </div>
61
+ </header>
62
+ <header v-else class="flex items-start gap-3 px-5 pt-3 pb-2 md:pt-6">
43
63
  <div class="min-w-0 flex-1">
44
- <slot name="header">
45
- <DialogTitle
46
- :class="
47
- hideTitle
48
- ? 'sr-only'
49
- : 'font-display text-2xl leading-tight text-sb-ink'
50
- "
51
- >
52
- {{ title }}
53
- </DialogTitle>
54
- <DialogDescription
55
- v-if="description"
56
- class="mt-1 text-sm text-sb-ink-muted"
57
- >
58
- {{ description }}
59
- </DialogDescription>
60
- </slot>
64
+ <DialogTitle
65
+ :class="
66
+ hideTitle
67
+ ? 'sr-only'
68
+ : 'font-display text-2xl leading-tight text-sb-ink'
69
+ "
70
+ >
71
+ {{ title }}
72
+ </DialogTitle>
73
+ <DialogDescription
74
+ v-if="description"
75
+ class="mt-1 text-sm text-sb-ink-muted"
76
+ >
77
+ {{ description }}
78
+ </DialogDescription>
61
79
  </div>
62
80
  <slot name="actions" />
63
81
  <DialogClose as-child>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@shopbite-de/storefront",
3
- "version": "2.1.0",
3
+ "version": "2.1.1",
4
4
  "main": "nuxt.config.ts",
5
5
  "description": "Shopware storefront for food delivery shops",
6
6
  "keywords": [
@@ -0,0 +1,90 @@
1
+ import { describe, it, expect, vi } from "vitest";
2
+ import { mountSuspended } from "@nuxt/test-utils/runtime";
3
+ import type { VueWrapper } from "@vue/test-utils";
4
+ import { ref } from "vue";
5
+ import MobileTop from "~/components/Navigation/MobileTop.vue";
6
+
7
+ // La Fattoria's menu: Fleischgerichte has sub-categories, Pizza has none.
8
+ vi.mock("~/composables/useNavigation", () => ({
9
+ useNavigation: () => ({
10
+ menuCardNavigation: ref([
11
+ { id: "pizza", name: "Pizza", seoUrl: "/speisekarte/pizza/" },
12
+ {
13
+ id: "fleisch",
14
+ name: "Fleischgerichte",
15
+ seoUrl: "/speisekarte/fleischgerichte/",
16
+ children: [
17
+ {
18
+ id: "rind",
19
+ name: "Vom Rind",
20
+ seoUrl: "/speisekarte/fleischgerichte/vom-rind/",
21
+ },
22
+ {
23
+ id: "kalb",
24
+ name: "Vom Kalb",
25
+ seoUrl: "/speisekarte/fleischgerichte/vom-kalb/",
26
+ },
27
+ ],
28
+ },
29
+ ]),
30
+ }),
31
+ }));
32
+
33
+ type Row = {
34
+ label: string | undefined;
35
+ links: { text: string; current: string | undefined }[];
36
+ };
37
+
38
+ function chips(wrapper: VueWrapper): Row[] {
39
+ return wrapper.findAll("ul").map((list) => ({
40
+ label: list.attributes("aria-label"),
41
+ links: list.findAll("a").map((link) => ({
42
+ text: link.text(),
43
+ current: link.attributes("aria-current"),
44
+ })),
45
+ }));
46
+ }
47
+
48
+ describe("NavigationMobileTop", () => {
49
+ it("shows only the sections on a section without sub-categories", async () => {
50
+ const wrapper = await mountSuspended(MobileTop, {
51
+ route: "/speisekarte/pizza/",
52
+ });
53
+
54
+ const rows = chips(wrapper);
55
+ expect(rows).toHaveLength(1);
56
+ expect(rows[0]!.links).toEqual([
57
+ { text: "Pizza", current: "page" },
58
+ { text: "Fleischgerichte", current: undefined },
59
+ ]);
60
+ });
61
+
62
+ it("lists the sub-categories of the open section in a second row", async () => {
63
+ const wrapper = await mountSuspended(MobileTop, {
64
+ route: "/speisekarte/fleischgerichte/",
65
+ });
66
+
67
+ const rows = chips(wrapper);
68
+ expect(rows[1]!.label).toBe("Unterkategorien von Fleischgerichte");
69
+ expect(rows[1]!.links).toEqual([
70
+ { text: "Alle", current: "page" },
71
+ { text: "Vom Rind", current: undefined },
72
+ { text: "Vom Kalb", current: undefined },
73
+ ]);
74
+ });
75
+
76
+ it("keeps the section and its row open on a sub-category", async () => {
77
+ const wrapper = await mountSuspended(MobileTop, {
78
+ route: "/speisekarte/fleischgerichte/vom-kalb/",
79
+ });
80
+
81
+ const rows = chips(wrapper);
82
+ const section = wrapper.find("[data-section]");
83
+ expect(section.text()).toBe("Fleischgerichte");
84
+ expect(section.classes()).toContain("bg-sb-ink");
85
+ expect(rows[1]!.links.find((link) => link.current)).toEqual({
86
+ text: "Vom Kalb",
87
+ current: "page",
88
+ });
89
+ });
90
+ });
@@ -0,0 +1,44 @@
1
+ import { describe, it, expect } from "vitest";
2
+ import { mountSuspended } from "@nuxt/test-utils/runtime";
3
+ import { defineComponent, h } from "vue";
4
+ import { DialogTitle } from "reka-ui";
5
+ import SbSheet from "~/components/Sb/Sheet.vue";
6
+
7
+ // A custom header (product sheet) gets its own row below the actions, so
8
+ // a long dish name is not squeezed next to three 44 px buttons.
9
+ describe("SbSheet header", () => {
10
+ it("puts the actions and close into a toolbar above a custom header", async () => {
11
+ const Host = defineComponent(
12
+ () => () =>
13
+ h(
14
+ SbSheet,
15
+ { open: true, title: "Hähnchenbrustfilet Paniert m. Kroketten" },
16
+ {
17
+ header: () =>
18
+ h(DialogTitle, { "data-test": "title" }, () => "Titel"),
19
+ actions: () => h("button", { "data-test": "save" }, "Merken"),
20
+ default: () => h("p", "Inhalt"),
21
+ },
22
+ ),
23
+ );
24
+ await mountSuspended(Host);
25
+
26
+ const header = document.body.querySelector("header")!;
27
+ const [toolbar, content] = [...header.children];
28
+ expect(toolbar!.querySelector('[data-test="save"]')).not.toBeNull();
29
+ expect(toolbar!.querySelector('[aria-label="Schließen"]')).not.toBeNull();
30
+ expect(content!.querySelector('[data-test="title"]')).not.toBeNull();
31
+ });
32
+
33
+ it("keeps title and close in one row without a custom header", async () => {
34
+ const Host = defineComponent(
35
+ () => () =>
36
+ h(SbSheet, { open: true, title: "Warenkorb" }, () => h("p", "Inhalt")),
37
+ );
38
+ await mountSuspended(Host);
39
+
40
+ const header = [...document.body.querySelectorAll("header")].at(-1)!;
41
+ expect(header.className).toContain("items-start");
42
+ expect(header.textContent).toContain("Warenkorb");
43
+ });
44
+ });