@shopbite-de/storefront 2.0.0 → 2.0.2
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/.github/workflows/ci.yaml +33 -0
- package/.gitignore +5 -0
- package/CLAUDE.md +5 -1
- package/app/assets/css/main.css +3 -0
- package/app/components/Home/Categories.vue +35 -4
- package/app/components/Home/Hero.vue +6 -3
- package/app/composables/useThemePreset.ts +16 -7
- package/app/pages/index.vue +2 -1
- package/content.config.ts +5 -0
- package/modules/theme.ts +8 -0
- package/nuxt.config.ts +3 -1
- package/package.json +1 -1
- package/test/layer/nuxt.config.ts +8 -0
|
@@ -124,6 +124,39 @@ jobs:
|
|
|
124
124
|
- name: Unit tests
|
|
125
125
|
run: pnpm test:unit
|
|
126
126
|
|
|
127
|
+
layer-build:
|
|
128
|
+
name: Build as a layer
|
|
129
|
+
needs: [setup]
|
|
130
|
+
timeout-minutes: 10
|
|
131
|
+
runs-on: ubuntu-latest
|
|
132
|
+
steps:
|
|
133
|
+
- uses: actions/checkout@v7
|
|
134
|
+
|
|
135
|
+
- uses: pnpm/action-setup@v6
|
|
136
|
+
with:
|
|
137
|
+
version: 12.9.1
|
|
138
|
+
|
|
139
|
+
- uses: actions/setup-node@v7
|
|
140
|
+
with:
|
|
141
|
+
node-version: '24'
|
|
142
|
+
|
|
143
|
+
- name: Restore workspace from cache
|
|
144
|
+
uses: actions/cache/restore@v6
|
|
145
|
+
with:
|
|
146
|
+
path: |
|
|
147
|
+
~/.local/share/pnpm/store
|
|
148
|
+
node_modules
|
|
149
|
+
.nuxt
|
|
150
|
+
.output
|
|
151
|
+
key: workspace-${{ runner.os }}-${{ github.sha }}
|
|
152
|
+
|
|
153
|
+
# test/layer extends the storefront like a shop does; imports that only
|
|
154
|
+
# resolve inside the storefront itself break here (2.0.1)
|
|
155
|
+
- name: Build test/layer
|
|
156
|
+
env:
|
|
157
|
+
NODE_OPTIONS: "--max_old_space_size=4096"
|
|
158
|
+
run: pnpm nuxt build test/layer
|
|
159
|
+
|
|
127
160
|
a11y:
|
|
128
161
|
name: Accessibility (${{ matrix.preset }})
|
|
129
162
|
# no test customer needed: the repository secrets (Store API key) suffice
|
package/.gitignore
CHANGED
package/CLAUDE.md
CHANGED
|
@@ -137,7 +137,7 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
|
|
|
137
137
|
- 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.
|
|
138
138
|
- Cart and checkout (#443): `MenuOrderMode` (`useOrderMode`) 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`.
|
|
139
139
|
- 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 (`AddToWishlist`), content pages and `error.vue` (with its own `Header`/`Footer`, because the error page replaces `app.vue`) use the same pieces.
|
|
140
|
-
- 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 poster sits in a `<picture>` with a `min-width: 640px` source, so phones load a 1 px GIF), `HomeFacts` (`features`), `HomeCategories` (word list, `useHomeMenuCategories`), `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.
|
|
140
|
+
- 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.
|
|
141
141
|
- Header and footer (#455): `Header.vue` (logo, main nav, status pill, phone, account, wishlist, cart button opening the cart `SbSheet`, menu `SbSheet` on phones), `Footer.vue` (address, hours, footer navigation columns). `app.vue` has the skip link to `main#inhalt`.
|
|
142
142
|
- Every colour pair a component renders must be in `CONTRAST_PAIRS`; `test/unit/themePresets.spec.ts` fails if a preset misses WCAG AA. Accent red is for headlines only, never on controls (reads as negative).
|
|
143
143
|
|
|
@@ -153,6 +153,10 @@ Pages without content throw `createNotFoundError()` (`app/utils/notFound.ts`): f
|
|
|
153
153
|
- `server/plugins/ai-crawlers.ts` adds two named robots.txt groups via the `robots:config` hook (#403): AI search/assistant bots and AI training bots (lists with sources in `server/utils/aiCrawlers.ts`), toggled by `runtimeConfig.aiCrawlers.search`/`.training`. A crawler matching a named group ignores `*`, so allowed groups repeat the `robots.disallow` paths.
|
|
154
154
|
- Shop contact data (NAP) lives in `runtimeConfig.public.site` (`address.*`, `telephone`, `googleBusinessProfileUrl`; `alternateNames` lists other names the shop is listed under, for the Restaurant schema `alternateName` and `/llms.txt`) and is rendered by `components/Footer/Contact.vue`. `useBusinessHours`/`useHolidays` use `immediate: false` (app.vue loads them on mount); a component that needs them in the SSR HTML calls `onServerPrefetch(() => refresh())`. In the browser both requests are retried twice (`withRetries`); `useOpeningHoursData` gives components the combined loading/failed state and `retry()`, and reports a failure only after mounting (a failed server prefetch would otherwise break hydration, #355). Anything that depends on the current time (open/closed status, "today") is computed after mounting: `useStoreStatus` starts its clock in `onMounted`, because the home page prefetches the hours on the server and the server's clock and time zone differ from the visitor's (hydration mismatch, #365).
|
|
155
155
|
|
|
156
|
+
### Layer imports
|
|
157
|
+
|
|
158
|
+
Shops extend the storefront as a Nuxt layer, so paths must resolve from the storefront itself: `~`, `@` and `#shared` point to the shop's folders there. App code imports nothing from `shared/` (only types; a relative import breaks the Nitro server bundle), so `modules/theme.ts` passes what the app needs through runtime config (`shopBite.themePresets`). Files in `nuxt.config.ts` use `fileURLToPath(new URL("./…", import.meta.url))` (`css`, local modules). `main.css` lists `@source "../.."`, because Tailwind's automatic detection only scans the shop. `test/layer/` is a minimal shop (`extends: ["../.."]`) that the CI job `layer-build` builds (`pnpm nuxt build test/layer`); 2.0.0 broke every shop because only the storefront itself was built.
|
|
159
|
+
|
|
156
160
|
### Testing setup
|
|
157
161
|
|
|
158
162
|
Two Vitest projects in `vitest.config.ts`:
|
package/app/assets/css/main.css
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
@import "tailwindcss";
|
|
2
2
|
|
|
3
3
|
@source "../../../content/**/*";
|
|
4
|
+
/* the storefront's own components: Tailwind's automatic detection only
|
|
5
|
+
scans the shop that extends this layer (2.0.1) */
|
|
6
|
+
@source "../..";
|
|
4
7
|
|
|
5
8
|
@theme {
|
|
6
9
|
/* This is important because apple devices will zoom in when the font size is below 16px */
|
|
@@ -5,7 +5,9 @@ import type { Schemas } from "#shopware";
|
|
|
5
5
|
* Menu sections of the presets on the home page (#444): a word list in the
|
|
6
6
|
* display font on the darker band, no dish counts. On desktop one photo
|
|
7
7
|
* follows the hovered or focused section (category media from Shopware);
|
|
8
|
-
* phones get the words stacked and no photo.
|
|
8
|
+
* phones get the words stacked and no photo. Wide category banners (as in
|
|
9
|
+
* La Fattoria) do not fit the 4:5 column: then the photo spans the width
|
|
10
|
+
* below the words in the banner's own aspect ratio.
|
|
9
11
|
*/
|
|
10
12
|
withDefaults(
|
|
11
13
|
defineProps<{
|
|
@@ -27,6 +29,31 @@ const active = computed<Schemas["Category"] | undefined>(
|
|
|
27
29
|
sections.value.find((category) => category.media?.url),
|
|
28
30
|
);
|
|
29
31
|
|
|
32
|
+
function aspect(media: Schemas["Media"] | null | undefined) {
|
|
33
|
+
const size =
|
|
34
|
+
mediaSize(media) ??
|
|
35
|
+
[...(media?.thumbnails ?? [])].sort(
|
|
36
|
+
(a, b) => (b.width ?? 0) - (a.width ?? 0),
|
|
37
|
+
)[0];
|
|
38
|
+
return size?.width && size?.height ? size.width / size.height : null;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// decided once by the first photo, so hovering does not change the layout
|
|
42
|
+
const bannerAspect = computed(() => {
|
|
43
|
+
const ratio = aspect(
|
|
44
|
+
sections.value.find((category) => category.media?.url)?.media,
|
|
45
|
+
);
|
|
46
|
+
return ratio && ratio > 1.2 ? ratio : null;
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
// the browser picks the thumbnail by width, so a crop has to ask for the
|
|
50
|
+
// width the photo needs to fill the box in height
|
|
51
|
+
const sizes = computed(() => {
|
|
52
|
+
if (bannerAspect.value) return "min(76rem, calc(100vw - 4rem))";
|
|
53
|
+
const ratio = aspect(active.value?.media) ?? 0.8;
|
|
54
|
+
return `${Math.round(500 * Math.max(ratio, 0.8))}px`;
|
|
55
|
+
});
|
|
56
|
+
|
|
30
57
|
function name(category: Schemas["Category"]) {
|
|
31
58
|
return category.translated?.name ?? category.name;
|
|
32
59
|
}
|
|
@@ -42,7 +69,7 @@ function name(category: Schemas["Category"]) {
|
|
|
42
69
|
<div
|
|
43
70
|
:class="[
|
|
44
71
|
'mx-auto grid w-full max-w-(--sb-container) items-center gap-10 px-4 py-14 sm:px-6 lg:px-8 sm:py-24 lg:gap-[72px]',
|
|
45
|
-
active?.media?.url
|
|
72
|
+
active?.media?.url && !bannerAspect
|
|
46
73
|
? 'lg:grid-cols-[minmax(0,1.35fr)_minmax(0,0.65fr)]'
|
|
47
74
|
: '',
|
|
48
75
|
]"
|
|
@@ -101,11 +128,15 @@ function name(category: Schemas["Category"]) {
|
|
|
101
128
|
<img
|
|
102
129
|
:src="active.media.url"
|
|
103
130
|
:srcset="mediaSrcSet(active.media)"
|
|
104
|
-
sizes="
|
|
131
|
+
:sizes="sizes"
|
|
105
132
|
alt=""
|
|
106
133
|
loading="lazy"
|
|
107
134
|
decoding="async"
|
|
108
|
-
class="
|
|
135
|
+
:class="[
|
|
136
|
+
'w-full rounded-[20px] object-cover',
|
|
137
|
+
bannerAspect ? '' : 'aspect-[4/5]',
|
|
138
|
+
]"
|
|
139
|
+
:style="bannerAspect ? { aspectRatio: bannerAspect } : undefined"
|
|
109
140
|
/>
|
|
110
141
|
<figcaption class="font-body text-sm font-bold text-sb-ink">
|
|
111
142
|
{{ name(active) }}
|
|
@@ -17,7 +17,9 @@ const props = defineProps<{
|
|
|
17
17
|
title: string;
|
|
18
18
|
description?: string;
|
|
19
19
|
headline?: string;
|
|
20
|
-
|
|
20
|
+
image?: string;
|
|
21
|
+
// CSS object-position of the 4:5 crop, e.g. "50% 30%"
|
|
22
|
+
imagePosition?: string;
|
|
21
23
|
links?: HeroLink[];
|
|
22
24
|
usps?: HeroUsp[];
|
|
23
25
|
}>();
|
|
@@ -138,9 +140,9 @@ const BLANK =
|
|
|
138
140
|
</p>
|
|
139
141
|
</div>
|
|
140
142
|
|
|
141
|
-
<div v-if="
|
|
143
|
+
<div v-if="image" class="relative hidden sm:block">
|
|
142
144
|
<picture>
|
|
143
|
-
<source media="(min-width: 640px)" :srcset="
|
|
145
|
+
<source media="(min-width: 640px)" :srcset="image" />
|
|
144
146
|
<img
|
|
145
147
|
:src="BLANK"
|
|
146
148
|
alt=""
|
|
@@ -148,6 +150,7 @@ const BLANK =
|
|
|
148
150
|
height="1100"
|
|
149
151
|
fetchpriority="high"
|
|
150
152
|
class="block aspect-[4/5] w-full rounded-[999px_999px_20px_20px] object-cover"
|
|
153
|
+
:style="imagePosition ? { objectPosition: imagePosition } : undefined"
|
|
151
154
|
/>
|
|
152
155
|
</picture>
|
|
153
156
|
<component
|
|
@@ -1,15 +1,24 @@
|
|
|
1
|
-
|
|
1
|
+
type PresetInfo = {
|
|
2
|
+
menuView: "bon" | "bonPhoto" | "listPhoto";
|
|
3
|
+
colorMode: "light" | "dark";
|
|
4
|
+
};
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* The active style preset (#439, #445): `runtimeConfig.public.shopBite
|
|
5
8
|
* .themePreset` (`NUXT_PUBLIC_SHOP_BITE_THEME_PRESET`), by default the
|
|
6
|
-
* `shopBite.preset` of the build
|
|
9
|
+
* `shopBite.preset` of the build, else `trattoria`. modules/theme.ts puts
|
|
10
|
+
* the menu view and colour mode of every preset into the runtime config.
|
|
7
11
|
*/
|
|
8
12
|
export function useThemePreset() {
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
13
|
+
const shopBite = useRuntimeConfig().public.shopBite as
|
|
14
|
+
| { themePreset?: string; themePresets?: Record<string, PresetInfo> }
|
|
15
|
+
| undefined;
|
|
16
|
+
const presets = shopBite?.themePresets ?? {};
|
|
17
|
+
const configured = shopBite?.themePreset ?? "";
|
|
18
|
+
const preset = Object.hasOwn(presets, configured) ? configured : "trattoria";
|
|
19
|
+
const { menuView, colorMode } = presets[preset] ?? {
|
|
20
|
+
menuView: "bon",
|
|
21
|
+
colorMode: "light",
|
|
22
|
+
};
|
|
14
23
|
return { preset, menuView, colorMode };
|
|
15
24
|
}
|
package/app/pages/index.vue
CHANGED
|
@@ -40,7 +40,8 @@ useRestaurantSchema();
|
|
|
40
40
|
:title="page.hero.title || page.title"
|
|
41
41
|
:description="page.description"
|
|
42
42
|
:headline="page.hero.headline"
|
|
43
|
-
:
|
|
43
|
+
:image="page.hero.image || page.hero.poster"
|
|
44
|
+
:image-position="page.hero.imagePosition"
|
|
44
45
|
:links="page.hero.links"
|
|
45
46
|
:usps="page.hero.usps"
|
|
46
47
|
/>
|
package/content.config.ts
CHANGED
|
@@ -68,6 +68,11 @@ export default defineContentConfig({
|
|
|
68
68
|
hero: z.object({
|
|
69
69
|
backgroundVideo: z.string().optional(),
|
|
70
70
|
poster: z.string().optional(),
|
|
71
|
+
// Photo of the hero (#444), portrait 4:5 at about 1200×1500 px;
|
|
72
|
+
// `poster` (a frame of the video) is the fallback. imagePosition
|
|
73
|
+
// is the CSS object-position of the crop, e.g. "50% 30%".
|
|
74
|
+
image: z.string().optional(),
|
|
75
|
+
imagePosition: z.string().optional(),
|
|
71
76
|
headline: z.string().optional(),
|
|
72
77
|
// Hero title; the page title (shop name) is the fallback (#327).
|
|
73
78
|
title: z.string().optional(),
|
package/modules/theme.ts
CHANGED
|
@@ -100,6 +100,14 @@ export default defineNuxtModule<ShopBiteThemeOptions>({
|
|
|
100
100
|
>;
|
|
101
101
|
const shopBite = (publicConfig.shopBite ??= {}) as Record<string, unknown>;
|
|
102
102
|
shopBite.themePreset = name;
|
|
103
|
+
// what the app needs to know about each preset, so app code imports
|
|
104
|
+
// nothing from shared/ (a layer import would resolve in the shop)
|
|
105
|
+
shopBite.themePresets = Object.fromEntries(
|
|
106
|
+
presets.map((preset) => [
|
|
107
|
+
preset.name,
|
|
108
|
+
{ menuView: preset.menuView, colorMode: preset.colorMode },
|
|
109
|
+
]),
|
|
110
|
+
);
|
|
103
111
|
// optional logo URL instead of public/light|dark/Logo.png
|
|
104
112
|
shopBite.logoUrl ??= "";
|
|
105
113
|
|
package/nuxt.config.ts
CHANGED
|
@@ -172,7 +172,9 @@ export default defineNuxtConfig({
|
|
|
172
172
|
preset: "trattoria",
|
|
173
173
|
},
|
|
174
174
|
|
|
175
|
-
|
|
175
|
+
// Absolute: `~` would point to the app/ folder of a shop extending this
|
|
176
|
+
// layer, which may have no main.css (2.0.1).
|
|
177
|
+
css: [fileURLToPath(new URL("./app/assets/css/main.css", import.meta.url))],
|
|
176
178
|
|
|
177
179
|
fonts: {
|
|
178
180
|
defaults: {
|
package/package.json
CHANGED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
// A minimal shop that extends the storefront like the real shops do (La
|
|
2
|
+
// Fattoria, quickstart, lead demos). CI builds it to catch imports that only
|
|
3
|
+
// resolve inside the storefront itself, e.g. the `#shared` alias, which in a
|
|
4
|
+
// layer points to the shop's shared/ folder (2.0.1).
|
|
5
|
+
export default defineNuxtConfig({
|
|
6
|
+
extends: ["../.."],
|
|
7
|
+
shopBite: { preset: "grill" },
|
|
8
|
+
});
|