@shopbite-de/storefront 1.31.3 → 2.0.0
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 +54 -0
- package/CLAUDE.md +23 -8
- package/app/app.vue +10 -6
- package/app/assets/css/main.css +100 -61
- package/app/components/AddToWishlist.vue +15 -25
- package/app/components/Address/Card.vue +6 -11
- package/app/components/Address/Detail.vue +23 -23
- package/app/components/Address/Fields.vue +175 -73
- package/app/components/Address/Form.vue +107 -106
- package/app/components/Cart/Bar.vue +6 -9
- package/app/components/Cart/Item.vue +48 -63
- package/app/components/Cart/QuickView.vue +38 -25
- package/app/components/Cart/Upsell.vue +24 -62
- package/app/components/Category/Breadcrumb.vue +29 -3
- package/app/components/Category/FilterGroup.vue +20 -41
- package/app/components/Category/Listing.vue +100 -130
- package/app/components/Category/SearchInput.vue +22 -19
- package/app/components/Checkout/DeliveryTimeSelect.vue +55 -77
- package/app/components/Checkout/LoginOrRegister.vue +28 -29
- package/app/components/Checkout/PaymentAndDelivery.vue +114 -86
- package/app/components/Checkout/Summary.vue +90 -60
- package/app/components/Checkout/VoucherInput.vue +40 -27
- package/app/components/Contact/Form.vue +164 -192
- package/app/components/DemoBanner.vue +5 -5
- package/app/components/Footer/StoreStatus.vue +2 -2
- package/app/components/Footer.vue +125 -57
- package/app/components/Header.vue +283 -18
- package/app/components/Home/Categories.vue +116 -0
- package/app/components/Home/Facts.vue +71 -0
- package/app/components/Home/Faq.vue +34 -16
- package/app/components/Home/Hero.vue +172 -0
- package/app/components/Home/Highlights.vue +29 -37
- package/app/components/Home/Restaurant.vue +102 -0
- package/app/components/Menu/BonCard.vue +180 -0
- package/app/components/Menu/CartPanel.vue +24 -0
- package/app/components/Menu/CategoryIndex.vue +54 -0
- package/app/components/Menu/OrderMode.vue +20 -0
- package/app/components/Menu/SectionHeader.vue +38 -0
- package/app/components/Navigation/MobileTop.vue +23 -15
- package/app/components/Order/Confirmation.vue +119 -0
- package/app/components/Order/Detail.vue +80 -88
- package/app/components/Product/CardSkeleton.vue +8 -12
- package/app/components/Product/Configurator.vue +8 -16
- package/app/components/Product/CrossSelling.vue +75 -83
- package/app/components/Product/DeselectIngredient.vue +17 -22
- package/app/components/Product/Detail.vue +35 -27
- package/app/components/Product/QuickView.vue +80 -51
- package/app/components/SalesChannelSwitch.vue +14 -28
- package/app/components/Sb/Button.vue +70 -0
- package/app/components/Sb/Checkbox.vue +73 -0
- package/app/components/Sb/Chip.vue +51 -0
- package/app/components/Sb/ChoiceGroup.vue +82 -0
- package/app/components/Sb/ConfirmDialog.vue +60 -0
- package/app/components/Sb/Field.vue +77 -0
- package/app/components/Sb/Icon.vue +66 -0
- package/app/components/Sb/IconButton.vue +55 -0
- package/app/components/Sb/Input.vue +23 -0
- package/app/components/Sb/SegmentedControl.vue +34 -0
- package/app/components/Sb/Select.vue +49 -0
- package/app/components/Sb/Sheet.vue +83 -0
- package/app/components/Sb/Stars.vue +60 -0
- package/app/components/Sb/StatusPill.vue +38 -0
- package/app/components/Sb/Stepper.vue +72 -0
- package/app/components/User/AccountHeader.vue +16 -0
- package/app/components/User/AuthPanel.vue +41 -0
- package/app/components/User/Detail.vue +32 -29
- package/app/components/User/LoginForm.vue +92 -98
- package/app/components/User/RegistrationForm.vue +285 -249
- package/app/components/Wishlist.vue +55 -155
- package/app/composables/useCartMutations.ts +9 -27
- package/app/composables/useCheckoutMethodGuard.ts +2 -24
- package/app/composables/useContactForm.ts +66 -0
- package/app/composables/useHomeMenuCategories.ts +41 -0
- package/app/composables/useNavigation.ts +10 -2
- package/app/composables/useOrderMode.ts +65 -0
- package/app/composables/useRegistrationForm.ts +161 -0
- package/app/composables/useRestaurantSchema.ts +1 -1
- package/app/composables/useShareLink.ts +3 -13
- package/app/composables/useSortingSelection.ts +13 -0
- package/app/composables/useThemePreset.ts +15 -0
- package/app/composables/useVoucherCode.ts +7 -16
- package/app/composables/useWishlistActions.ts +0 -51
- package/app/error.vue +31 -9
- package/app/layouts/account.vue +45 -50
- package/app/layouts/default.vue +2 -3
- package/app/layouts/listing.vue +3 -5
- package/app/pages/[...all].vue +8 -4
- package/app/pages/account/recover/password/index.vue +113 -80
- package/app/pages/anmelden.vue +11 -10
- package/app/pages/bestellung/[id]/erfolg.vue +1 -15
- package/app/pages/bestellung/[id]/fehler.vue +63 -51
- package/app/pages/bestellung/[id]/index.vue +3 -85
- package/app/pages/bestellung/kasse.vue +29 -0
- package/app/pages/bestellung.vue +8 -60
- package/app/pages/index.vue +12 -52
- package/app/pages/kontakt.vue +27 -7
- package/app/pages/konto/adressen.vue +106 -102
- package/app/pages/konto/bestellung/[id].vue +9 -43
- package/app/pages/konto/bestellungen.vue +55 -33
- package/app/pages/konto/index.vue +47 -62
- package/app/pages/konto/profil.vue +162 -100
- package/app/pages/maintenance.vue +8 -6
- package/app/pages/merkliste.vue +7 -8
- package/app/pages/passwort-vergessen.vue +92 -75
- package/app/pages/registrierung/bestaetigen.vue +20 -48
- package/app/pages/registrierung/index.vue +16 -7
- package/app/pages/suche.vue +94 -95
- package/app/plugins/theme-preset.ts +9 -0
- package/app/utils/highlight.ts +25 -0
- package/app/utils/product.ts +9 -0
- package/app/validation/registrationSchema.ts +1 -1
- package/modules/theme.ts +115 -0
- package/nuxt.config.ts +27 -15
- package/package.json +6 -8
- package/playwright.config.ts +11 -0
- package/server/api/listing/[categoryId].get.ts +3 -0
- package/shared/theme/presets.ts +303 -0
- package/test/a11y/presets.test.ts +225 -0
- package/test/nuxt/AccountPagesPreset.test.ts +191 -0
- package/test/nuxt/AuthPagesPreset.test.ts +87 -0
- package/test/nuxt/CartCheckoutPreset.test.ts +154 -0
- package/test/nuxt/CartItem.test.ts +18 -3
- package/test/nuxt/CartUpsell.test.ts +1 -2
- package/test/nuxt/CheckoutFormsPreset.test.ts +120 -0
- package/test/nuxt/CheckoutOnePage.test.ts +115 -0
- package/test/nuxt/CheckoutSummary.test.ts +6 -6
- package/test/nuxt/CheckoutVoucherInput.test.ts +20 -32
- package/test/nuxt/ContactFormPreset.test.ts +115 -0
- package/test/nuxt/FooterStoreStatus.test.ts +2 -2
- package/test/nuxt/HeaderFooterPreset.test.ts +134 -0
- package/test/nuxt/HomeFaq.test.ts +3 -2
- package/test/nuxt/MenuBonCard.test.ts +122 -0
- package/test/nuxt/OrderPagesPreset.test.ts +132 -0
- package/test/nuxt/PaymentAndDelivery.test.ts +0 -4
- package/test/nuxt/ProductCrossSelling.test.ts +2 -1
- package/test/nuxt/ProductDeselectIngredient.test.ts +5 -3
- package/test/nuxt/ProductSheetPreset.test.ts +105 -0
- package/test/nuxt/RegisterConfirmPage.test.ts +0 -8
- package/test/nuxt/RegistrationForm.test.ts +89 -270
- package/test/nuxt/SbBaseComponents.test.ts +170 -0
- package/test/nuxt/SbStars.test.ts +25 -0
- package/test/nuxt/useCartMutations.test.ts +3 -17
- package/test/nuxt/useCartUpsell.test.ts +1 -1
- package/test/nuxt/useCheckoutMethodGuard.test.ts +0 -27
- package/test/nuxt/useShareLink.test.ts +1 -9
- package/test/nuxt/useWishlistActions.test.ts +3 -26
- package/test/unit/highlight.spec.ts +31 -0
- package/test/unit/product.spec.ts +12 -0
- package/test/unit/themePresets.spec.ts +61 -0
- package/app/app.config.ts +0 -19
- package/app/components/AnimatedSection.vue +0 -74
- package/app/components/BottomNavi.vue +0 -70
- package/app/components/Category/Header.vue +0 -48
- package/app/components/Checkout/PaymentMethod.vue +0 -30
- package/app/components/Checkout/ShippingMethod.vue +0 -30
- package/app/components/Cta.vue +0 -30
- package/app/components/Feature/Card.vue +0 -121
- package/app/components/Features.vue +0 -42
- package/app/components/Footer/Contact.vue +0 -82
- package/app/components/Header/Body.vue +0 -82
- package/app/components/Header/Right.vue +0 -187
- package/app/components/Header/Title.vue +0 -10
- package/app/components/Hero.vue +0 -233
- package/app/components/Home/MenuCategories.vue +0 -148
- package/app/components/ImageGallery.vue +0 -63
- package/app/components/Loading.vue +0 -29
- package/app/components/Navigation/DesktopLeft.vue +0 -39
- package/app/components/Product/Card.vue +0 -177
- package/app/components/Product/CardCompact.vue +0 -72
- package/app/components/Product/CardDietBadges.vue +0 -43
- package/app/components/Product/CardIngredients.vue +0 -35
- package/app/components/Product/CardKitchen.vue +0 -34
- package/app/components/Product/SearchBar.vue +0 -95
- package/app/components/PublicAnnouncement.vue +0 -17
- package/app/pages/bestellung/bestaetigen.vue +0 -16
- package/app/pages/bestellung/warenkorb.vue +0 -49
- package/app/pages/bestellung/zahlung-versand.vue +0 -25
- package/test/nuxt/AddressFields.test.ts +0 -222
- package/test/nuxt/AnimatedSection.test.ts +0 -67
- package/test/nuxt/ContactForm.test.ts +0 -207
- package/test/nuxt/FooterContact.test.ts +0 -102
- package/test/nuxt/HeaderRight.test.ts +0 -142
- package/test/nuxt/Hero.test.ts +0 -126
- package/test/nuxt/HomeMenuCategories.test.ts +0 -94
- package/test/nuxt/LoginForm.test.ts +0 -159
|
@@ -0,0 +1,303 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Style presets of the storefront (#439). A preset gives a shop its look:
|
|
3
|
+
* colours, fonts, shape and colour mode. The base components read only the
|
|
4
|
+
* `--sb-*` custom properties, so switching `shopBite.preset` in a shop's
|
|
5
|
+
* nuxt.config changes the whole storefront without code changes.
|
|
6
|
+
*
|
|
7
|
+
* Every colour pair a component puts on top of each other is listed in
|
|
8
|
+
* `CONTRAST_PAIRS` and checked against WCAG 2.2 AA by
|
|
9
|
+
* test/unit/themePresets.spec.ts (#446).
|
|
10
|
+
*/
|
|
11
|
+
|
|
12
|
+
export type ColorToken =
|
|
13
|
+
/** page background */
|
|
14
|
+
| "bg"
|
|
15
|
+
/** cards, inputs, panels on top of bg */
|
|
16
|
+
| "surface"
|
|
17
|
+
/** darker bands and fills (number strips, segmented controls) */
|
|
18
|
+
| "muted"
|
|
19
|
+
/** hairlines and card borders, decorative only */
|
|
20
|
+
| "line"
|
|
21
|
+
/** visible boundary of inputs and outlined controls, 3:1 (WCAG 1.4.11) */
|
|
22
|
+
| "control"
|
|
23
|
+
/** body text and headings */
|
|
24
|
+
| "ink"
|
|
25
|
+
/** secondary text: ingredients, hints, captions */
|
|
26
|
+
| "inkMuted"
|
|
27
|
+
/** primary buttons, selected states */
|
|
28
|
+
| "primary"
|
|
29
|
+
| "primaryHover"
|
|
30
|
+
/** text and icons on primary */
|
|
31
|
+
| "onPrimary"
|
|
32
|
+
/** light fill of secondary buttons (quick add) */
|
|
33
|
+
| "primaryTint"
|
|
34
|
+
/** links and icons in the primary colour on light surfaces */
|
|
35
|
+
| "primaryInk"
|
|
36
|
+
/** headline accents and kickers, never on controls */
|
|
37
|
+
| "accent"
|
|
38
|
+
/** keyboard focus ring */
|
|
39
|
+
| "focus"
|
|
40
|
+
/** error text and borders */
|
|
41
|
+
| "danger"
|
|
42
|
+
/** rating stars, a graphic next to the rating in words (3:1) */
|
|
43
|
+
| "star"
|
|
44
|
+
/** inverted band (restaurant section) */
|
|
45
|
+
| "band"
|
|
46
|
+
| "onBand";
|
|
47
|
+
|
|
48
|
+
export type ThemeColors = Record<ColorToken, string>;
|
|
49
|
+
|
|
50
|
+
export interface ThemePreset {
|
|
51
|
+
name: string;
|
|
52
|
+
colorMode: "light" | "dark";
|
|
53
|
+
colors: ThemeColors;
|
|
54
|
+
fonts: {
|
|
55
|
+
display: { family: string; weights: number[]; fallback: string };
|
|
56
|
+
body: { family: string; weights: number[]; fallback: string };
|
|
57
|
+
};
|
|
58
|
+
radius: {
|
|
59
|
+
/** cards and panels */
|
|
60
|
+
card: string;
|
|
61
|
+
/** buttons and inputs */
|
|
62
|
+
control: string;
|
|
63
|
+
};
|
|
64
|
+
/** how dishes are shown in the menu (#441) */
|
|
65
|
+
menuView: "bon" | "bonPhoto" | "listPhoto";
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export const THEME_PRESETS = {
|
|
69
|
+
trattoria: {
|
|
70
|
+
name: "trattoria",
|
|
71
|
+
colorMode: "light",
|
|
72
|
+
colors: {
|
|
73
|
+
bg: "#F8F3EF",
|
|
74
|
+
surface: "#FDFBF9",
|
|
75
|
+
muted: "#F0E8E2",
|
|
76
|
+
line: "#E8DED7",
|
|
77
|
+
control: "#8F7C6E",
|
|
78
|
+
ink: "#1C1B19",
|
|
79
|
+
inkMuted: "#5E5B55",
|
|
80
|
+
primary: "#3F7D20",
|
|
81
|
+
primaryHover: "#346A1A",
|
|
82
|
+
onPrimary: "#FFFFFF",
|
|
83
|
+
primaryTint: "#DCE8D1",
|
|
84
|
+
primaryInk: "#2F6418",
|
|
85
|
+
accent: "#B03A2E",
|
|
86
|
+
focus: "#2F6418",
|
|
87
|
+
danger: "#B42318",
|
|
88
|
+
star: "#B87A00",
|
|
89
|
+
band: "#1F2A1B",
|
|
90
|
+
onBand: "#FFFFFF",
|
|
91
|
+
},
|
|
92
|
+
fonts: {
|
|
93
|
+
display: { family: "Young Serif", weights: [400], fallback: "serif" },
|
|
94
|
+
body: {
|
|
95
|
+
family: "Figtree",
|
|
96
|
+
weights: [400, 600, 700],
|
|
97
|
+
fallback: "sans-serif",
|
|
98
|
+
},
|
|
99
|
+
},
|
|
100
|
+
radius: { card: "14px", control: "12px" },
|
|
101
|
+
menuView: "bon",
|
|
102
|
+
},
|
|
103
|
+
grill: {
|
|
104
|
+
name: "grill",
|
|
105
|
+
colorMode: "dark",
|
|
106
|
+
colors: {
|
|
107
|
+
bg: "#16120E",
|
|
108
|
+
surface: "#241D17",
|
|
109
|
+
muted: "#2E261F",
|
|
110
|
+
line: "#3A3128",
|
|
111
|
+
control: "#8E8272",
|
|
112
|
+
ink: "#F5EFE6",
|
|
113
|
+
inkMuted: "#B3A996",
|
|
114
|
+
primary: "#F2A93B",
|
|
115
|
+
primaryHover: "#F5B957",
|
|
116
|
+
onPrimary: "#16120E",
|
|
117
|
+
primaryTint: "#3A2E1E",
|
|
118
|
+
primaryInk: "#F2A93B",
|
|
119
|
+
accent: "#F2A93B",
|
|
120
|
+
focus: "#F2A93B",
|
|
121
|
+
danger: "#FF8A7A",
|
|
122
|
+
star: "#F2A93B",
|
|
123
|
+
band: "#0F0C09",
|
|
124
|
+
onBand: "#F5EFE6",
|
|
125
|
+
},
|
|
126
|
+
fonts: {
|
|
127
|
+
display: {
|
|
128
|
+
family: "Bricolage Grotesque",
|
|
129
|
+
weights: [700, 800],
|
|
130
|
+
fallback: "sans-serif",
|
|
131
|
+
},
|
|
132
|
+
body: {
|
|
133
|
+
family: "Bricolage Grotesque",
|
|
134
|
+
weights: [400, 600, 700],
|
|
135
|
+
fallback: "sans-serif",
|
|
136
|
+
},
|
|
137
|
+
},
|
|
138
|
+
radius: { card: "20px", control: "999px" },
|
|
139
|
+
menuView: "bonPhoto",
|
|
140
|
+
},
|
|
141
|
+
asia: {
|
|
142
|
+
name: "asia",
|
|
143
|
+
colorMode: "light",
|
|
144
|
+
colors: {
|
|
145
|
+
bg: "#F3F6F1",
|
|
146
|
+
surface: "#FFFFFF",
|
|
147
|
+
muted: "#E6ECE3",
|
|
148
|
+
line: "#D5DDD3",
|
|
149
|
+
control: "#7C877F",
|
|
150
|
+
ink: "#17201B",
|
|
151
|
+
inkMuted: "#5C665F",
|
|
152
|
+
primary: "#0E6B52",
|
|
153
|
+
primaryHover: "#0B5A45",
|
|
154
|
+
onPrimary: "#FFFFFF",
|
|
155
|
+
primaryTint: "#E3F1EA",
|
|
156
|
+
primaryInk: "#0E6B52",
|
|
157
|
+
accent: "#B8391F",
|
|
158
|
+
focus: "#0E6B52",
|
|
159
|
+
danger: "#B42318",
|
|
160
|
+
star: "#B87A00",
|
|
161
|
+
band: "#17201B",
|
|
162
|
+
onBand: "#FFFFFF",
|
|
163
|
+
},
|
|
164
|
+
fonts: {
|
|
165
|
+
display: { family: "Outfit", weights: [600], fallback: "sans-serif" },
|
|
166
|
+
body: {
|
|
167
|
+
family: "Outfit",
|
|
168
|
+
weights: [400, 500, 600],
|
|
169
|
+
fallback: "sans-serif",
|
|
170
|
+
},
|
|
171
|
+
},
|
|
172
|
+
radius: { card: "24px", control: "999px" },
|
|
173
|
+
menuView: "listPhoto",
|
|
174
|
+
},
|
|
175
|
+
} satisfies Record<string, ThemePreset>;
|
|
176
|
+
|
|
177
|
+
export type ThemePresetName = keyof typeof THEME_PRESETS;
|
|
178
|
+
|
|
179
|
+
export function isThemePresetName(name: unknown): name is ThemePresetName {
|
|
180
|
+
return typeof name === "string" && Object.hasOwn(THEME_PRESETS, name);
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export type ContrastPair = {
|
|
184
|
+
fg: ColorToken;
|
|
185
|
+
bg: ColorToken;
|
|
186
|
+
/** 4.5 for text, 3 for large text, icons and control boundaries */
|
|
187
|
+
min: 4.5 | 3;
|
|
188
|
+
};
|
|
189
|
+
|
|
190
|
+
/** Colour pairs the base components render; every preset must pass all. */
|
|
191
|
+
export const CONTRAST_PAIRS: ContrastPair[] = [
|
|
192
|
+
{ fg: "ink", bg: "bg", min: 4.5 },
|
|
193
|
+
{ fg: "ink", bg: "surface", min: 4.5 },
|
|
194
|
+
{ fg: "ink", bg: "muted", min: 4.5 },
|
|
195
|
+
{ fg: "inkMuted", bg: "bg", min: 4.5 },
|
|
196
|
+
{ fg: "inkMuted", bg: "surface", min: 4.5 },
|
|
197
|
+
{ fg: "inkMuted", bg: "muted", min: 4.5 },
|
|
198
|
+
{ fg: "onPrimary", bg: "primary", min: 4.5 },
|
|
199
|
+
{ fg: "onPrimary", bg: "primaryHover", min: 4.5 },
|
|
200
|
+
{ fg: "primaryInk", bg: "bg", min: 4.5 },
|
|
201
|
+
{ fg: "primaryInk", bg: "surface", min: 4.5 },
|
|
202
|
+
{ fg: "primaryInk", bg: "primaryTint", min: 4.5 },
|
|
203
|
+
{ fg: "accent", bg: "bg", min: 4.5 },
|
|
204
|
+
{ fg: "accent", bg: "muted", min: 4.5 },
|
|
205
|
+
{ fg: "danger", bg: "surface", min: 4.5 },
|
|
206
|
+
{ fg: "onBand", bg: "band", min: 4.5 },
|
|
207
|
+
{ fg: "control", bg: "surface", min: 3 },
|
|
208
|
+
{ fg: "control", bg: "bg", min: 3 },
|
|
209
|
+
{ fg: "focus", bg: "bg", min: 3 },
|
|
210
|
+
{ fg: "focus", bg: "surface", min: 3 },
|
|
211
|
+
{ fg: "star", bg: "surface", min: 3 },
|
|
212
|
+
];
|
|
213
|
+
|
|
214
|
+
function channel(value: number): number {
|
|
215
|
+
const c = value / 255;
|
|
216
|
+
return c <= 0.04045 ? c / 12.92 : ((c + 0.055) / 1.055) ** 2.4;
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
/** Relative luminance of a `#RRGGBB` colour (WCAG 2.2). */
|
|
220
|
+
export function luminance(hex: string): number {
|
|
221
|
+
const match = /^#([0-9a-f]{6})$/i.exec(hex);
|
|
222
|
+
if (!match) throw new Error(`Expected a #RRGGBB colour, got "${hex}"`);
|
|
223
|
+
const n = parseInt(match[1]!, 16);
|
|
224
|
+
return (
|
|
225
|
+
0.2126 * channel((n >> 16) & 255) +
|
|
226
|
+
0.7152 * channel((n >> 8) & 255) +
|
|
227
|
+
0.0722 * channel(n & 255)
|
|
228
|
+
);
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
export function contrastRatio(a: string, b: string): number {
|
|
232
|
+
const [hi, lo] = [luminance(a), luminance(b)].sort((x, y) => y - x);
|
|
233
|
+
return (hi! + 0.05) / (lo! + 0.05);
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
export type ContrastFailure = ContrastPair & { ratio: number };
|
|
237
|
+
|
|
238
|
+
export function contrastFailures(colors: ThemeColors): ContrastFailure[] {
|
|
239
|
+
return CONTRAST_PAIRS.map((pair) => ({
|
|
240
|
+
...pair,
|
|
241
|
+
ratio: contrastRatio(colors[pair.fg], colors[pair.bg]),
|
|
242
|
+
})).filter((result) => result.ratio < result.min);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/** The preset with a shop's colour overrides applied. */
|
|
246
|
+
export function resolvePreset(
|
|
247
|
+
name: ThemePresetName,
|
|
248
|
+
colors: Partial<ThemeColors> = {},
|
|
249
|
+
): ThemePreset {
|
|
250
|
+
const preset: ThemePreset = THEME_PRESETS[name];
|
|
251
|
+
return { ...preset, colors: { ...preset.colors, ...colors } };
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
function kebab(token: string): string {
|
|
255
|
+
return token.replace(/[A-Z]/g, (c) => `-${c.toLowerCase()}`);
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
function fontStack(font: { family: string; fallback: string }): string {
|
|
259
|
+
return `"${font.family}", ${font.fallback}`;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
/**
|
|
263
|
+
* The stylesheet of a preset: the `--sb-*` colour tokens, the fonts as
|
|
264
|
+
* `--font-sb-*` (the `--font` prefix makes @nuxt/fonts resolve the families
|
|
265
|
+
* and add metric fallback faces, which a `--sb-font-*` name would not get),
|
|
266
|
+
* the page ground and the focus ring.
|
|
267
|
+
*/
|
|
268
|
+
export function presetCss(preset: ThemePreset): string {
|
|
269
|
+
const scope = `:root[data-preset="${preset.name}"]`;
|
|
270
|
+
const tokens = Object.entries(preset.colors).map(
|
|
271
|
+
([token, value]) => ` --sb-${kebab(token)}: ${value};`,
|
|
272
|
+
);
|
|
273
|
+
return `${scope} {
|
|
274
|
+
${tokens.join("\n")}
|
|
275
|
+
--font-sb-display: ${fontStack(preset.fonts.display)};
|
|
276
|
+
--font-sb-body: ${fontStack(preset.fonts.body)};
|
|
277
|
+
--sb-radius-card: ${preset.radius.card};
|
|
278
|
+
--sb-radius-control: ${preset.radius.control};
|
|
279
|
+
color-scheme: ${preset.colorMode};
|
|
280
|
+
|
|
281
|
+
--font-sans: var(--font-sb-body);
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
${scope} body {
|
|
285
|
+
background: var(--sb-bg);
|
|
286
|
+
color: var(--sb-ink);
|
|
287
|
+
font-family: var(--font-sb-body);
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
${scope} :where(h1, h2, h3) {
|
|
291
|
+
font-family: var(--font-sb-display);
|
|
292
|
+
/* the display weight of the preset; a heavier utility class would make
|
|
293
|
+
the browser synthesise bold from a single-weight face */
|
|
294
|
+
font-weight: ${Math.max(...preset.fonts.display.weights)};
|
|
295
|
+
font-synthesis: none;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
${scope} :focus-visible:not([tabindex="-1"]) {
|
|
299
|
+
outline: 3px solid var(--sb-focus);
|
|
300
|
+
outline-offset: 2px;
|
|
301
|
+
}
|
|
302
|
+
`;
|
|
303
|
+
}
|
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
import { test, expect, type Page } from "@playwright/test";
|
|
2
|
+
import AxeBuilder from "@axe-core/playwright";
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Accessibility checks of the preset pages (#446): axe (WCAG 2.1 AA) on
|
|
6
|
+
* home, menu, product sheet, cart and checkout. Serious and critical
|
|
7
|
+
* violations fail; the full report is attached to the test. The preset is
|
|
8
|
+
* chosen at build time (NUXT_SHOPBITE_PRESET), CI runs one build per preset.
|
|
9
|
+
* Reads the menu of the configured backend, never registers or orders.
|
|
10
|
+
*/
|
|
11
|
+
const WCAG_TAGS = ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa"];
|
|
12
|
+
|
|
13
|
+
async function expectNoSeriousViolations(page: Page, name: string) {
|
|
14
|
+
const results = await new AxeBuilder({ page }).withTags(WCAG_TAGS).analyze();
|
|
15
|
+
await test.info().attach(`axe-${name}.json`, {
|
|
16
|
+
body: JSON.stringify(results.violations, null, 2),
|
|
17
|
+
contentType: "application/json",
|
|
18
|
+
});
|
|
19
|
+
const serious = results.violations
|
|
20
|
+
.filter((v) => v.impact === "serious" || v.impact === "critical")
|
|
21
|
+
.map((v) => ({
|
|
22
|
+
rule: v.id,
|
|
23
|
+
impact: v.impact,
|
|
24
|
+
help: v.help,
|
|
25
|
+
targets: v.nodes.slice(0, 5).map((node) => node.target.join(" ")),
|
|
26
|
+
}));
|
|
27
|
+
expect(serious, `${name}: serious axe violations`).toEqual([]);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Waits until Nuxt has hydrated, so clicks reach their handlers. */
|
|
31
|
+
async function gotoHydrated(page: Page, url: string) {
|
|
32
|
+
await page.goto(url);
|
|
33
|
+
await page.waitForFunction(
|
|
34
|
+
() =>
|
|
35
|
+
(
|
|
36
|
+
window as unknown as { useNuxtApp?: () => { isHydrating?: boolean } }
|
|
37
|
+
).useNuxtApp?.().isHydrating === false,
|
|
38
|
+
);
|
|
39
|
+
await page.waitForLoadState("networkidle");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
async function menuUrl(page: Page) {
|
|
43
|
+
await gotoHydrated(page, "/");
|
|
44
|
+
const href = await page
|
|
45
|
+
.locator('main a[href*="peisekarte/"]:not([href*="produkt="])')
|
|
46
|
+
.first()
|
|
47
|
+
.getAttribute("href");
|
|
48
|
+
expect(href, "home page links to the menu").toBeTruthy();
|
|
49
|
+
return href!;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
test.beforeEach(async ({ page }) => {
|
|
53
|
+
await page.emulateMedia({ reducedMotion: "reduce" });
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("home page", async ({ page }) => {
|
|
57
|
+
await gotoHydrated(page, "/");
|
|
58
|
+
await expect(page.locator("html")).toHaveAttribute("data-preset", /.+/);
|
|
59
|
+
await expectNoSeriousViolations(page, "home");
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
test("menu page", async ({ page }) => {
|
|
63
|
+
await gotoHydrated(page, await menuUrl(page));
|
|
64
|
+
await expect(page.locator("main h1")).toBeVisible();
|
|
65
|
+
await expectNoSeriousViolations(page, "menu");
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
test("product sheet", async ({ page }) => {
|
|
69
|
+
const menu = await menuUrl(page);
|
|
70
|
+
await gotoHydrated(page, menu);
|
|
71
|
+
const productHref = await page
|
|
72
|
+
.locator('main a[href*="produkt="]')
|
|
73
|
+
.first()
|
|
74
|
+
.getAttribute("href");
|
|
75
|
+
expect(productHref, "menu lists a product").toBeTruthy();
|
|
76
|
+
// open it on the menu page, which lists every dish (the product's own
|
|
77
|
+
// category may be empty on the demo backend)
|
|
78
|
+
const number = new URL(productHref!, "http://shop").searchParams.get(
|
|
79
|
+
"produkt",
|
|
80
|
+
);
|
|
81
|
+
await gotoHydrated(page, `${menu}?produkt=${number}`);
|
|
82
|
+
await expect(page.getByRole("dialog")).toBeVisible();
|
|
83
|
+
await expectNoSeriousViolations(page, "product-sheet");
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
test("cart and checkout", async ({ page }) => {
|
|
87
|
+
await gotoHydrated(page, await menuUrl(page));
|
|
88
|
+
const add = page
|
|
89
|
+
.locator('[data-testid="menu-add"]:not([aria-haspopup])')
|
|
90
|
+
.first();
|
|
91
|
+
// cards hydrate when they come close to the viewport
|
|
92
|
+
await add.scrollIntoViewIfNeeded();
|
|
93
|
+
const cart = page.getByRole("button", { name: /^Warenkorb, / }).first();
|
|
94
|
+
await expect(async () => {
|
|
95
|
+
await add.click();
|
|
96
|
+
await expect(cart).not.toHaveAccessibleName("Warenkorb, 0 Artikel", {
|
|
97
|
+
timeout: 3000,
|
|
98
|
+
});
|
|
99
|
+
}).toPass({ timeout: 20000 });
|
|
100
|
+
|
|
101
|
+
await cart.click();
|
|
102
|
+
await expect(page.getByRole("dialog")).toBeVisible();
|
|
103
|
+
await expectNoSeriousViolations(page, "cart");
|
|
104
|
+
|
|
105
|
+
await gotoHydrated(page, "/bestellung/kasse");
|
|
106
|
+
await expect(page.getByRole("heading", { level: 1 })).toHaveText("Kasse");
|
|
107
|
+
await expect(page.getByText("Ihr Warenkorb ist noch leer.")).toBeHidden();
|
|
108
|
+
await expectNoSeriousViolations(page, "checkout");
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
/** An order as the Store API returns it, so no real order is placed. */
|
|
112
|
+
const ORDER_ID = "0123456789abcdef0123456789abcdef";
|
|
113
|
+
const sampleOrder = {
|
|
114
|
+
id: ORDER_ID,
|
|
115
|
+
orderNumber: "10042",
|
|
116
|
+
createdAt: "2026-10-08T17:30:00.000Z",
|
|
117
|
+
taxStatus: "gross",
|
|
118
|
+
customerComment: "Wunschlieferzeit: 19:15",
|
|
119
|
+
shippingTotal: 1,
|
|
120
|
+
amountTotal: 21.5,
|
|
121
|
+
price: { calculatedTaxes: [{ taxRate: 7, tax: 1.41 }] },
|
|
122
|
+
stateMachineState: { name: "Offen", translated: { name: "Offen" } },
|
|
123
|
+
deliveries: [{ shippingMethod: { name: "Lieferung" } }],
|
|
124
|
+
transactions: [
|
|
125
|
+
{
|
|
126
|
+
paymentMethodId: "cash",
|
|
127
|
+
paymentMethod: { distinguishableName: "Bar" },
|
|
128
|
+
stateMachineState: { name: "Fehlgeschlagen" },
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
lineItems: [
|
|
132
|
+
{
|
|
133
|
+
id: "li-1",
|
|
134
|
+
parentId: null,
|
|
135
|
+
quantity: 2,
|
|
136
|
+
label: "Pizza Margherita",
|
|
137
|
+
totalPrice: 17,
|
|
138
|
+
payload: { productNumber: "LF-4" },
|
|
139
|
+
},
|
|
140
|
+
],
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
async function mockOrder(page: Page) {
|
|
144
|
+
await page.route("**/store-api/order", (route) =>
|
|
145
|
+
route.fulfill({
|
|
146
|
+
json: {
|
|
147
|
+
orders: { elements: [sampleOrder], total: 1 },
|
|
148
|
+
paymentChangeable: {},
|
|
149
|
+
},
|
|
150
|
+
}),
|
|
151
|
+
);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
test("order confirmation", async ({ page }) => {
|
|
155
|
+
await mockOrder(page);
|
|
156
|
+
await gotoHydrated(page, `/bestellung/${ORDER_ID}/erfolg`);
|
|
157
|
+
await expect(page.getByText("Ihre Bestellnummer ist 10042")).toBeVisible();
|
|
158
|
+
await expectNoSeriousViolations(page, "order-confirmation");
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
test("payment failure", async ({ page }) => {
|
|
162
|
+
await mockOrder(page);
|
|
163
|
+
await gotoHydrated(page, `/bestellung/${ORDER_ID}/fehler`);
|
|
164
|
+
await expect(page.getByRole("radiogroup")).toBeVisible();
|
|
165
|
+
await expectNoSeriousViolations(page, "payment-failure");
|
|
166
|
+
});
|
|
167
|
+
|
|
168
|
+
test("login, registration and password pages", async ({ page }) => {
|
|
169
|
+
await gotoHydrated(page, "/anmelden");
|
|
170
|
+
await page.getByRole("button", { name: "Anmelden" }).click();
|
|
171
|
+
await expect(
|
|
172
|
+
page.getByText("Bitte geben Sie eine gültige E-Mail"),
|
|
173
|
+
).toBeVisible();
|
|
174
|
+
await expectNoSeriousViolations(page, "login");
|
|
175
|
+
|
|
176
|
+
await gotoHydrated(page, "/registrierung");
|
|
177
|
+
await expect(page.getByRole("heading", { level: 1 })).toHaveText(
|
|
178
|
+
"Registrieren",
|
|
179
|
+
);
|
|
180
|
+
await expectNoSeriousViolations(page, "registration");
|
|
181
|
+
|
|
182
|
+
await gotoHydrated(page, "/passwort-vergessen");
|
|
183
|
+
await page.getByRole("button", { name: "Link senden" }).click();
|
|
184
|
+
await expect(
|
|
185
|
+
page.getByText("Bitte geben Sie eine gültige E-Mail"),
|
|
186
|
+
).toBeVisible();
|
|
187
|
+
await expectNoSeriousViolations(page, "password-forgotten");
|
|
188
|
+
|
|
189
|
+
await gotoHydrated(page, "/account/recover/password?hash=test");
|
|
190
|
+
await page.getByRole("button", { name: "Passwort speichern" }).click();
|
|
191
|
+
await expect(
|
|
192
|
+
page.getByText("Das Passwort braucht mindestens 8 Zeichen.").first(),
|
|
193
|
+
).toBeVisible();
|
|
194
|
+
await expectNoSeriousViolations(page, "password-reset");
|
|
195
|
+
});
|
|
196
|
+
|
|
197
|
+
test("search, contact, wishlist, content and error pages", async ({ page }) => {
|
|
198
|
+
await gotoHydrated(page, "/suche?q=pizza");
|
|
199
|
+
await expect(page.getByRole("search")).toBeVisible();
|
|
200
|
+
await expectNoSeriousViolations(page, "search");
|
|
201
|
+
|
|
202
|
+
// the contact page exists only with the contact form feature
|
|
203
|
+
const contact = await page.goto("/kontakt");
|
|
204
|
+
if (contact?.ok()) {
|
|
205
|
+
await gotoHydrated(page, "/kontakt");
|
|
206
|
+
await page.getByRole("button", { name: "Nachricht senden" }).click();
|
|
207
|
+
await expect(
|
|
208
|
+
page.getByText("Bitte geben Sie einen Betreff an."),
|
|
209
|
+
).toBeVisible();
|
|
210
|
+
await expectNoSeriousViolations(page, "contact");
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
await gotoHydrated(page, "/merkliste");
|
|
214
|
+
await expectNoSeriousViolations(page, "wishlist");
|
|
215
|
+
|
|
216
|
+
await gotoHydrated(page, "/impressum");
|
|
217
|
+
await expectNoSeriousViolations(page, "content-page");
|
|
218
|
+
|
|
219
|
+
const missing = await page.goto("/diese-seite-gibt-es-nicht");
|
|
220
|
+
expect(missing?.status()).toBe(404);
|
|
221
|
+
await expect(page.getByRole("heading", { level: 1 })).toHaveText(
|
|
222
|
+
"Diese Seite gibt es nicht",
|
|
223
|
+
);
|
|
224
|
+
await expectNoSeriousViolations(page, "not-found");
|
|
225
|
+
});
|