@shopbite-de/storefront 1.24.0 → 1.26.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.
Files changed (96) hide show
  1. package/.env.example +3 -0
  2. package/CLAUDE.md +10 -3
  3. package/README.md +0 -1
  4. package/app/app.config.ts +3 -2
  5. package/app/app.vue +4 -1
  6. package/app/assets/css/main.css +16 -0
  7. package/app/components/AddToWishlist.vue +13 -6
  8. package/app/components/Cart/Bar.vue +102 -0
  9. package/app/components/Cart/QuickView.vue +4 -0
  10. package/app/components/Cart/Upsell.vue +106 -0
  11. package/app/components/Category/Listing.vue +11 -3
  12. package/app/components/Checkout/DeliveryTimeSelect.vue +28 -2
  13. package/app/components/Checkout/Summary.vue +25 -3
  14. package/app/components/DemoBanner.vue +13 -0
  15. package/app/components/Feature/Card.vue +121 -0
  16. package/app/components/Features.vue +14 -9
  17. package/app/components/Footer/Contact.vue +5 -1
  18. package/app/components/Header/Right.vue +44 -15
  19. package/app/components/Hero.vue +126 -36
  20. package/app/components/Product/Card.vue +102 -50
  21. package/app/components/Product/CardCompact.vue +72 -0
  22. package/app/components/Product/CardDietBadges.vue +38 -31
  23. package/app/components/Product/CardIngredients.vue +35 -0
  24. package/app/components/Product/CardSkeleton.vue +10 -18
  25. package/app/components/Product/Category.vue +9 -2
  26. package/app/components/Product/Configurator.vue +11 -7
  27. package/app/components/Product/CrossSelling.vue +45 -34
  28. package/app/components/Product/DeselectIngredient.vue +37 -31
  29. package/app/components/Product/Detail.vue +73 -13
  30. package/app/components/Product/QuickView.vue +77 -0
  31. package/app/components/Topseller.vue +44 -34
  32. package/app/composables/useAddToCart.ts +3 -30
  33. package/app/composables/useBusinessHours.ts +10 -3
  34. package/app/composables/useCartQuickView.ts +19 -0
  35. package/app/composables/useCartUpsell.ts +100 -0
  36. package/app/composables/useCategorySeo.ts +5 -4
  37. package/app/composables/useHolidays.ts +7 -3
  38. package/app/composables/useOpeningHoursData.ts +53 -0
  39. package/app/composables/useProductCartQuantity.ts +15 -0
  40. package/app/composables/useProductCrossSelling.ts +1 -0
  41. package/app/composables/useProductDetail.ts +15 -1
  42. package/app/composables/useProductEvents.ts +30 -0
  43. package/app/composables/useProductQuickView.ts +65 -0
  44. package/app/composables/useTopSellers.ts +22 -0
  45. package/app/composables/useTrackEvent.ts +7 -0
  46. package/app/pages/bestellung/bestaetigen.vue +0 -3
  47. package/app/pages/bestellung/warenkorb.vue +0 -3
  48. package/app/pages/bestellung/zahlung-versand.vue +0 -3
  49. package/app/pages/bestellung.vue +22 -14
  50. package/app/pages/index.vue +3 -1
  51. package/app/pages/suche.vue +18 -5
  52. package/app/types/Association.d.ts +1 -0
  53. package/app/utils/openingHours.ts +31 -8
  54. package/app/utils/product.ts +31 -0
  55. package/app/utils/retry.ts +17 -0
  56. package/content/index.yml +16 -11
  57. package/content.config.ts +13 -0
  58. package/docs/notes/2026-09-12-issue-319-stylesheet-cost.md +154 -0
  59. package/docs/notes/2026-09-12-issue-325-product-card.md +100 -0
  60. package/docs/notes/2026-09-12-issue-327-home-hero.md +64 -0
  61. package/docs/notes/2026-09-13-demo-banner.md +32 -0
  62. package/docs/notes/2026-09-13-issue-332-home-info-cards.md +46 -0
  63. package/docs/notes/2026-09-13-quick-view-flicker.md +65 -0
  64. package/docs/notes/2026-09-14-cart-upsell.md +105 -0
  65. package/docs/notes/2026-09-14-demo-noindex.md +57 -0
  66. package/docs/notes/2026-09-16-issue-339-checkout-hydration.md +49 -0
  67. package/docs/notes/2026-09-16-issue-349-order-button-loading.md +39 -0
  68. package/docs/notes/2026-09-16-issue-350-remove-pinia.md +41 -0
  69. package/docs/notes/2026-09-16-issue-355-opening-hours-error.md +57 -0
  70. package/nuxt.config.ts +25 -2
  71. package/package.json +2 -3
  72. package/scripts/perf/first-render.mjs +30 -0
  73. package/scripts/perf/h2-proxy.cjs +49 -0
  74. package/scripts/perf/lighthouse.sh +22 -0
  75. package/scripts/perf/quick-view-layout.mjs +126 -0
  76. package/server/api/listing/[categoryId].get.ts +2 -0
  77. package/server/api/search.get.ts +2 -0
  78. package/test/e2e/simple-checkout-as-recurring-customer.test.ts +13 -17
  79. package/test/nuxt/CartBar.test.ts +110 -0
  80. package/test/nuxt/CartUpsell.test.ts +125 -0
  81. package/test/nuxt/CheckoutSummary.test.ts +127 -0
  82. package/test/nuxt/DemoBanner.test.ts +12 -0
  83. package/test/nuxt/useAddToCart.test.ts +6 -19
  84. package/test/nuxt/useCartUpsell.test.ts +126 -0
  85. package/test/nuxt/useOpeningHoursData.test.ts +120 -0
  86. package/test/nuxt/useTrackEvent.test.ts +15 -0
  87. package/test/unit/openingHours.spec.ts +32 -1
  88. package/test/unit/product.spec.ts +72 -0
  89. package/test/unit/retry.spec.ts +58 -0
  90. package/test/unit/useCategorySeo.spec.ts +2 -1
  91. package/test/visual/playwright.config.ts +33 -0
  92. package/test/visual/visual.spec.ts +87 -0
  93. package/app/components/Product/CardDescription.vue +0 -27
  94. package/app/components/Product/CardFooter.vue +0 -61
  95. package/app/composables/useCheckoutStore.ts +0 -1
  96. package/app/stores/checkout.ts +0 -22
@@ -4,20 +4,42 @@ export type useTopSellersReturn = {
4
4
  loadTopSellers(): Promise<Schemas["Product"][]>;
5
5
  };
6
6
 
7
+ const TOP_SELLERS_LIMIT = 8;
8
+
7
9
  export function useTopSellers(): useTopSellersReturn {
8
10
  const { apiClient } = useShopwareContext();
9
11
  async function loadTopSellers() {
10
12
  try {
11
13
  const result = await apiClient.invoke("readProduct post /product", {
14
+ // Variants marked as top sellers inherit name, cover and properties.
15
+
16
+ // @ts-expect-error sw-inheritance is missing from the generated header type
17
+ headers: { "sw-inheritance": "true" },
12
18
  body: {
13
19
  filter: [{ type: "equals", field: "markAsTopseller", value: true }],
20
+ limit: TOP_SELLERS_LIMIT,
21
+ // What the compact card and the quick view need (#327).
14
22
  includes: {
15
23
  product: [
24
+ "id",
16
25
  "productNumber",
17
26
  "name",
27
+ "translated",
18
28
  "description",
19
29
  "calculatedPrice",
30
+ "available",
31
+ "cover",
32
+ "sortedProperties",
20
33
  ],
34
+ product_media: ["media"],
35
+ media: ["url", "thumbnails"],
36
+ media_thumbnail: ["width", "url"],
37
+ property_group: ["id", "name", "translated", "options"],
38
+ property_group_option: ["id", "name", "translated"],
39
+ },
40
+ associations: {
41
+ cover: { associations: { media: {} } },
42
+ properties: { associations: { group: {} } },
21
43
  },
22
44
  },
23
45
  });
@@ -58,6 +58,12 @@ export function useTrackEvent() {
58
58
  push(["trackEvent", "Cart", "AddToCart", product.productNumber, quantity]);
59
59
  }
60
60
 
61
+ // A separate action, so the cart suggestions are measurable apart from
62
+ // regular adds (#338).
63
+ function trackUpsellAdd(product: Schemas["Product"], quantity: number) {
64
+ push(["trackEvent", "Cart", "UpsellAdd", product.productNumber, quantity]);
65
+ }
66
+
61
67
  function trackSearch(term: string, productNumbers: string[]) {
62
68
  push(["trackSiteSearch", term, false, productNumbers.length]);
63
69
  }
@@ -68,6 +74,7 @@ export function useTrackEvent() {
68
74
  trackOrder,
69
75
  trackAddToWishlist,
70
76
  trackAddToCart,
77
+ trackUpsellAdd,
71
78
  trackSearch,
72
79
  };
73
80
  }
@@ -5,13 +5,10 @@ useSeoMeta({
5
5
  });
6
6
 
7
7
  const { isLoggedIn, isGuestSession } = useUser();
8
- const { setStep } = useCheckoutStore();
9
8
 
10
9
  if (!isLoggedIn.value && !isGuestSession.value) {
11
10
  await navigateTo("/bestellung/warenkorb");
12
11
  }
13
-
14
- setStep(2);
15
12
  </script>
16
13
 
17
14
  <template>
@@ -6,9 +6,6 @@ useSeoMeta({
6
6
 
7
7
  const { isLoggedIn, isGuestSession } = useUser();
8
8
  const { isEmpty } = useCart();
9
- const { setStep } = useCheckoutStore();
10
-
11
- setStep(0);
12
9
 
13
10
  const isCustomerAvailable = computed<boolean>(() => {
14
11
  return isLoggedIn.value || isGuestSession.value;
@@ -5,13 +5,10 @@ useSeoMeta({
5
5
  });
6
6
 
7
7
  const { isLoggedIn, isGuestSession } = useUser();
8
- const { setStep } = useCheckoutStore();
9
8
 
10
9
  if (!isLoggedIn.value && !isGuestSession.value) {
11
10
  await navigateTo("/bestellung/warenkorb");
12
11
  }
13
-
14
- setStep(1);
15
12
  </script>
16
13
 
17
14
  <template>
@@ -1,15 +1,34 @@
1
1
  <script setup lang="ts">
2
2
  import type { StepperItem } from "@nuxt/ui";
3
3
 
4
- const checkoutStore = useCheckoutStore();
5
- const { step } = storeToRefs(checkoutStore);
6
-
7
4
  const stepRoutes = [
8
5
  "/bestellung/warenkorb",
9
6
  "/bestellung/zahlung-versand",
10
7
  "/bestellung/bestaetigen",
11
8
  ] as const;
12
9
 
10
+ const route = useRoute();
11
+ const isPaymentReturnRoute = computed(() =>
12
+ /^\/bestellung\/[0-9a-f]{32}(\/erfolg|\/fehler)?$/.test(route.path),
13
+ );
14
+
15
+ // The active step follows the route, so the server renders the same step the
16
+ // browser hydrates. Setting it from the child pages ran after the stepper had
17
+ // been rendered on the server (#339).
18
+ const step = computed<number>({
19
+ get: () =>
20
+ Math.max(
21
+ 0,
22
+ stepRoutes.findIndex((path) => path === route.path),
23
+ ),
24
+ set: (index) => {
25
+ const path = stepRoutes[index];
26
+ if (path && path !== route.path) {
27
+ navigateTo(path);
28
+ }
29
+ },
30
+ });
31
+
13
32
  const items = computed(
14
33
  () =>
15
34
  [
@@ -30,17 +49,6 @@ const items = computed(
30
49
  },
31
50
  ] satisfies StepperItem[],
32
51
  );
33
-
34
- const route = useRoute();
35
- const isPaymentReturnRoute = computed(() =>
36
- /^\/bestellung\/[0-9a-f]{32}(\/erfolg|\/fehler)?$/.test(route.path),
37
- );
38
- watch(step, (newStep) => {
39
- if (isPaymentReturnRoute.value) {
40
- return;
41
- }
42
- navigateTo(stepRoutes[newStep]);
43
- });
44
52
  </script>
45
53
 
46
54
  <template>
@@ -39,7 +39,7 @@ useRestaurantSchema();
39
39
  <template>
40
40
  <div v-if="page" class="relative">
41
41
  <Hero
42
- :title="page.title"
42
+ :title="page.hero.title || page.title"
43
43
  :background-video="page.hero.backgroundVideo"
44
44
  :poster="page.hero.poster"
45
45
  :description="page.description"
@@ -48,6 +48,8 @@ useRestaurantSchema();
48
48
  :usps="page.hero.usps"
49
49
  />
50
50
 
51
+ <Topseller />
52
+
51
53
  <USeparator :ui="{ border: 'border-primary/30' }" />
52
54
 
53
55
  <Features
@@ -68,6 +68,12 @@ const { data: fallbackProducts, refresh: refreshFallback } = useLazyAsyncData<
68
68
  { immediate: false },
69
69
  );
70
70
 
71
+ // One quick view for the results and the fallback suggestions (#325).
72
+ const quickView = useProductQuickView(() => [
73
+ ...elements.value,
74
+ ...(fallbackProducts.value ?? []),
75
+ ]);
76
+
71
77
  watch(showFallback, (visible) => {
72
78
  if (visible && !fallbackProducts.value) {
73
79
  refreshFallback();
@@ -92,6 +98,11 @@ function submitSearch() {
92
98
  <UContainer>
93
99
  <UPage>
94
100
  <UPageBody>
101
+ <LazyProductQuickView
102
+ v-if="quickView.mounted.value"
103
+ v-model:open="quickView.open.value"
104
+ :product="quickView.product.value"
105
+ />
95
106
  <div class="flex flex-col gap-4">
96
107
  <div class="flex flex-col sm:flex-row gap-4">
97
108
  <UInput
@@ -135,7 +146,7 @@ function submitSearch() {
135
146
 
136
147
  <div
137
148
  v-if="showSkeleton"
138
- class="flex flex-col gap-4"
149
+ class="grid grid-cols-1 gap-4 xl:grid-cols-2"
139
150
  aria-busy="true"
140
151
  aria-label="Produkte werden geladen"
141
152
  >
@@ -144,7 +155,7 @@ function submitSearch() {
144
155
 
145
156
  <div
146
157
  v-else-if="elements.length > 0"
147
- class="flex flex-col gap-4 transition-opacity duration-200"
158
+ class="grid grid-cols-1 gap-4 transition-opacity duration-200 xl:grid-cols-2"
148
159
  :class="{ 'opacity-40 pointer-events-none': loading }"
149
160
  >
150
161
  <ProductCardWhenVisible
@@ -152,7 +163,8 @@ function submitSearch() {
152
163
  :key="product.id"
153
164
  :product="product"
154
165
  :with-favorite-button="true"
155
- :with-add-to-cart-button="true"
166
+ :selectable="true"
167
+ @select="quickView.show"
156
168
  />
157
169
  </div>
158
170
 
@@ -162,13 +174,14 @@ function submitSearch() {
162
174
  </p>
163
175
  <template v-if="showFallback && fallbackProducts?.length">
164
176
  <p class="text-sm font-medium mt-2">Das könnte dir gefallen:</p>
165
- <div class="flex flex-col gap-4">
177
+ <div class="grid grid-cols-1 gap-4 xl:grid-cols-2">
166
178
  <ProductCardWhenVisible
167
179
  v-for="product in fallbackProducts"
168
180
  :key="product.id"
169
181
  :product="product"
170
182
  :with-favorite-button="true"
171
- :with-add-to-cart-button="true"
183
+ :selectable="true"
184
+ @select="quickView.show"
172
185
  />
173
186
  </div>
174
187
  </template>
@@ -2,6 +2,7 @@ export type AssociationItemProduct = {
2
2
  label: string;
3
3
  value: string;
4
4
  price: string;
5
+ unitPrice?: number;
5
6
  icon?: string;
6
7
  };
7
8
 
@@ -17,6 +17,36 @@ const DAY_LABELS = ["Mo", "Di", "Mi", "Do", "Fr", "Sa", "So"] as const;
17
17
 
18
18
  const formatTime = (time: string) => time.slice(0, 5);
19
19
 
20
+ /** Intervals of one weekday (1 = Monday … 7 = Sunday), e.g. `["11:30–14:30"]`. */
21
+ export function intervalsForDay(
22
+ businessHours: BusinessHourLike[],
23
+ dayOfWeek: number,
24
+ ): string[] {
25
+ return businessHours
26
+ .filter(
27
+ (bh) => bh.dayOfWeek === dayOfWeek && bh.openingTime && bh.closingTime,
28
+ )
29
+ .sort((a, b) => a.openingTime!.localeCompare(b.openingTime!))
30
+ .map(
31
+ (bh) => `${formatTime(bh.openingTime!)}–${formatTime(bh.closingTime!)}`,
32
+ );
33
+ }
34
+
35
+ /**
36
+ * Today's hours as a sentence for the information cards (#332):
37
+ * `Heute 11:30–14:30 und 17:30–23:00`, or `Heute Ruhetag` on a closed day.
38
+ */
39
+ export function formatTodayHours(
40
+ businessHours: BusinessHourLike[],
41
+ date: Date,
42
+ ): string {
43
+ const dayOfWeek = date.getDay() === 0 ? 7 : date.getDay();
44
+ const intervals = intervalsForDay(businessHours, dayOfWeek);
45
+ return intervals.length === 0
46
+ ? "Heute Ruhetag"
47
+ : `Heute ${intervals.join(" und ")}`;
48
+ }
49
+
20
50
  /**
21
51
  * Groups business hours into display rows: consecutive days (Monday to
22
52
  * Sunday) with the same intervals share a row. Returns an empty list if no
@@ -26,14 +56,7 @@ export function groupOpeningHours(
26
56
  businessHours: BusinessHourLike[],
27
57
  ): OpeningHoursRow[] {
28
58
  const intervalsByDay = DAY_LABELS.map((_, index) =>
29
- businessHours
30
- .filter(
31
- (bh) => bh.dayOfWeek === index + 1 && bh.openingTime && bh.closingTime,
32
- )
33
- .sort((a, b) => a.openingTime!.localeCompare(b.openingTime!))
34
- .map(
35
- (bh) => `${formatTime(bh.openingTime!)}–${formatTime(bh.closingTime!)}`,
36
- ),
59
+ intervalsForDay(businessHours, index + 1),
37
60
  );
38
61
 
39
62
  if (intervalsByDay.every((intervals) => intervals.length === 0)) return [];
@@ -0,0 +1,31 @@
1
+ import type { Schemas } from "#shopware";
2
+
3
+ const MAIN_INGREDIENTS_GROUP = "Hauptzutaten";
4
+
5
+ /** `available` is optional in the projection; missing means orderable. */
6
+ export function productIsAvailable(product: Schemas["Product"]): boolean {
7
+ return product.available !== false;
8
+ }
9
+
10
+ /**
11
+ * Whether a cart line item holds the product, as a plain line item or as a
12
+ * container item carrying extras (the product is the first child, #325).
13
+ */
14
+ export function lineItemHoldsProduct(
15
+ item: Schemas["LineItem"],
16
+ productId: string,
17
+ ): boolean {
18
+ return (
19
+ item.referencedId === productId ||
20
+ (item.children ?? []).some((child) => child.referencedId === productId)
21
+ );
22
+ }
23
+
24
+ export function getMainIngredients(
25
+ sortedProperties: Schemas["PropertyGroup"][] | undefined,
26
+ ): Schemas["PropertyGroupOption"][] {
27
+ const group = sortedProperties?.find(
28
+ (propertyGroup) => propertyGroup.translated.name === MAIN_INGREDIENTS_GROUP,
29
+ );
30
+ return group?.options ?? [];
31
+ }
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Runs `request` and, when it throws, runs it again after each of `delays`
3
+ * (milliseconds). The error of the last attempt is thrown.
4
+ */
5
+ export async function withRetries<T>(
6
+ request: () => Promise<T>,
7
+ delays: readonly number[],
8
+ ): Promise<T> {
9
+ for (const delay of delays) {
10
+ try {
11
+ return await request();
12
+ } catch {
13
+ await new Promise((resolve) => setTimeout(resolve, delay));
14
+ }
15
+ }
16
+ return request();
17
+ }
package/content/index.yml CHANGED
@@ -5,6 +5,7 @@ seo:
5
5
  title: ShopBite
6
6
  description: Reduziere Kosten und steigere deinen Umsatz
7
7
  hero:
8
+ title: Frisch gekocht, schnell geliefert.
8
9
  backgroundVideo: https://veliu-minio.cjcbee.easypanel.host/shopbite-demo-shopware/media/f8/66/7e/1789150226/background.mp4?ts=1789150226
9
10
  poster: /hero-poster.webp
10
11
  headline: SHOPBITE
@@ -39,20 +40,24 @@ features:
39
40
  headline: SHOPBITE
40
41
  features:
41
42
  - title: Öffnungszeiten
42
- description: Von 11:30 - 14:30 und 17:30 - 23:00 Uhr. Samstags von 17:30 - 23:30 Uhr. Dienstag ist Ruhetag.
43
+ kind: hours
44
+ description: Samstags 17:30 - 23:30 Uhr, Dienstag ist Ruhetag.
43
45
  icon: i-lucide-clock
44
- ui:
45
- leading: bg-accented/50 p-2 rounded-md border border-muted border-dashed
46
+ link:
47
+ label: Alle Öffnungszeiten
48
+ to: "#oeffnungszeiten"
46
49
  - title: Lieferung
47
- description: Wir liefern nach Obertshausen und Lämmerspiel. Ab 15€ liefern wir frei Haus, darunter berechnen wir lediglich 1€. Die Lieferzeit beträgt bei normaler Auslastung ca. 30 min
50
+ kind: delivery
51
+ description: Wir liefern nach Obertshausen und Lämmerspiel. Ab 15 € frei Haus, darunter 1 € Liefergebühr.
48
52
  icon: i-lucide-truck
49
- ui:
50
- leading: bg-accented/50 p-2 rounded-md border border-muted border-dashed
51
- - title: Reservierungen und Bestellungen
52
- description: Reservierungen nehmen wir ausschließlich telefonisch entgegen. Bestellungen nehmen wir gerne telefonisch oder online entgegen.
53
- icon: i-lucide-pizza
54
- ui:
55
- leading: bg-accented/50 p-2 rounded-md border border-muted border-dashed
53
+ - title: Reservierung
54
+ kind: reservation
55
+ lead: Tisch nur telefonisch
56
+ description: Bestellungen nehmen wir gerne online oder telefonisch entgegen.
57
+ icon: i-lucide-phone
58
+ link:
59
+ label: 06104 77777 anrufen
60
+ to: "tel:+490610477777"
56
61
  marquee:
57
62
  title: Das lieben unsere Kunden
58
63
  description: Kundenbilder
package/content.config.ts CHANGED
@@ -41,6 +41,17 @@ const createBaseSchema = () =>
41
41
  const createFeatureSchema = () =>
42
42
  createBaseSchema().extend({
43
43
  icon: z.string().editor({ input: "icon" }),
44
+ // Information cards on the home page (#332): `kind` fills the lead line
45
+ // with live data (today's hours, delivery time), `lead` is the static
46
+ // alternative, `link` the card's action (a `tel:` target is a button).
47
+ kind: createEnum(["hours", "delivery", "reservation"]).optional(),
48
+ lead: z.string().optional(),
49
+ link: z
50
+ .object({
51
+ label: z.string().nonempty(),
52
+ to: z.string().nonempty(),
53
+ })
54
+ .optional(),
44
55
  ui: z
45
56
  .object({
46
57
  leading: z.string().optional(),
@@ -58,6 +69,8 @@ export default defineContentConfig({
58
69
  backgroundVideo: z.string().optional(),
59
70
  poster: z.string().optional(),
60
71
  headline: z.string().optional(),
72
+ // Hero title; the page title (shop name) is the fallback (#327).
73
+ title: z.string().optional(),
61
74
  links: z.array(createLinkSchema()),
62
75
  usps: z.array(
63
76
  z.object({
@@ -0,0 +1,154 @@
1
+ # Issue #319: Stylesheet cost and Style & Layout time on mobile
2
+
3
+ As of 2026-09-12, branch `fix/319-stylesheet-cost`.
4
+
5
+ ## Measurement setup
6
+
7
+ Production build, La Fattoria Store API, Lighthouse 12.8.2 mobile
8
+ (simulated throttling, 4× CPU) behind the h2/gzip proxy of the #273 and
9
+ #314 notes, two runs per page. In addition, Chrome DevTools Protocol
10
+ traces through Playwright (4× CPU throttling, mobile viewport):
11
+ `Performance.getMetrics`, the `SelectorStats` trace category for selector
12
+ matching cost, and the invalidation-tracking category for the reasons of
13
+ each style recalculation and layout. To isolate causes, copies of the
14
+ server-rendered home page with modified stylesheets were served as static
15
+ files through the same proxy.
16
+
17
+ ## Where the 253 KB come from
18
+
19
+ Tailwind source attribution (compiling `main.css` with the Tailwind node
20
+ API and removing the candidates unique to each `@source`):
21
+
22
+ - Nuxt UI registers the theme files of all 120 components as Tailwind
23
+ sources (`@source "./ui"` in the generated `ui.css`), although the
24
+ storefront renders 49 of them (63 with their dependencies). The colour
25
+ and state variants of the unused ones (Calendar, Table, CommandPalette,
26
+ Editor, Dashboard, Chat, …) were 59 KB, 7 KB gzipped.
27
+ - The Nuxt UI prose theme (`ui/prose`, present because `@nuxt/content` is
28
+ installed) is 41 KB, 4 KB gzipped, and only the legal pages use it.
29
+ - `UButton` alone is 17 KB (7 colours × 4 variants × states), the
30
+ storefront's own classes 16 KB, `UTabs` 10 KB, `UDropdownMenu` 8 KB,
31
+ `UNavigationMenu` 7 KB.
32
+ - Without any utility: 18 KB of theme variables, `@property`
33
+ registrations, preflight, keyframes and 29 `@font-face` blocks.
34
+ - All seven colour aliases (`primary`, `secondary`, `success`, `info`,
35
+ `warning`, `error`, `neutral`) are used by the storefront, so
36
+ `theme.colors` cannot be narrowed without design changes.
37
+
38
+ ## What the Style & Layout time is made of
39
+
40
+ The stylesheet is not the cost. On the home page (300 elements, 4× CPU):
41
+
42
+ - Selector matching for the whole load is 11–14 ms; the most attempted
43
+ selectors are prose rules with `::marker` and `> ul` (1,154 attempts,
44
+ 0 matches), not the `data-*`, `:has()` or `.dark` variants.
45
+ - The first style recalculation is 52 ms with the full stylesheet and
46
+ 36 ms with no stylesheet at all; the first layout is 140–175 ms.
47
+ - Removing the `@property` registrations, pre-resolving `oklch()` /
48
+ `color-mix()`, or dropping `text-wrap: pretty/balance` changes nothing
49
+ measurable.
50
+ - Replacing the font stack with `system-ui` takes the first layout from
51
+ 143 ms to 15 ms.
52
+
53
+ The font stack was
54
+ `"Public Sans", "Public Sans Fallback: BlinkMacSystemFont", "… Segoe UI",
55
+ "… Helvetica Neue", "… Arial", "… Noto Sans", sans-serif`: `@nuxt/fonts`
56
+ (enabled by Nuxt UI) generates a metric-adjusted `local()` face for each
57
+ of its five default fallback families. During the first layout, before the
58
+ web font has arrived, Chrome resolves every family in the stack for every
59
+ text style in use, and each family that is not installed costs a system
60
+ font lookup (fontconfig here, the unique-name lookup on Android). In
61
+ Lighthouse terms, static copies of the home page measured:
62
+
63
+ | Font stack | Style & Layout |
64
+ | --- | --- |
65
+ | Public Sans + 5 fallback families (as shipped) | 743–869 ms |
66
+ | Public Sans + 2 fallback families | 480–514 ms |
67
+ | Public Sans + 1 fallback family | 433–442 ms |
68
+ | Public Sans only | 339–378 ms |
69
+ | `system-ui` (no web font) | 226–264 ms |
70
+
71
+ The metric fallbacks made no difference to CLS in any run (0.058 on the
72
+ home page from the hero row, 0.001 on the category page).
73
+
74
+ The lookups are wall-clock work in the browser process, not renderer CPU:
75
+ the first layout of the live page takes 63 ms at 1× and 75 ms at 4× CPU
76
+ throttling, while the same page without fallback families scales from
77
+ 8.5 ms to 24 ms. Lighthouse multiplies observed durations by the CPU
78
+ multiplier, so every remaining fallback family shows up as roughly 100 ms
79
+ of Style & Layout on this machine (fontconfig, 2,183 installed fonts); on
80
+ a phone the per-family cost is smaller but not zero (Chrome's local font
81
+ lookup is a synchronous call into the browser process).
82
+
83
+ The rest of the time is the first render itself plus hydration: after the
84
+ entry chunk runs, a 285-element recalculation and a full layout
85
+ (28 ms + 24 ms at 4×) follow the DOM patches of hydration.
86
+
87
+ ## Changes
88
+
89
+ 1. `ui.experimental.componentDetection: true` (`nuxt.config.ts`): Nuxt UI
90
+ scans the layers for `<U…>` / `LazyU…` usages and registers only those
91
+ component themes (plus dependencies) as Tailwind sources; the themes of
92
+ the others are emptied. Components rendered dynamically by name would
93
+ need to be listed in the option's array form.
94
+ 2. `fonts.defaults.fallbacks["sans-serif"]` limited to `Roboto` and
95
+ `Helvetica Neue` (Android and iOS system fonts; the storefront is
96
+ phone-first). Windows and Linux desktops fall back to their default
97
+ sans-serif without metric adjustment during the swap.
98
+ 3. `app.config.ts`: `ui.colors.primary` is the alias `brand` instead of the
99
+ hex value, which produced eleven invalid
100
+ `--ui-color-primary-*: var(--color-#ff5b00-*, )` declarations in the
101
+ inlined `nuxt-ui-colors` style and left `primary-*` utilities without a
102
+ value. `--ui-primary` is still set in `main.css` (600 / 400 steps,
103
+ #275). The `gray: "cool"` key was a Nuxt UI v2 leftover.
104
+
105
+ ## Results (Lighthouse mobile, two runs each)
106
+
107
+ | Page | Metric | Baseline | After |
108
+ | --- | --- | --- | --- |
109
+ | `/` | Style & Layout | 763–875 ms | 488–566 ms |
110
+ | `/` | Performance | 74–75 | 75 |
111
+ | `/c/Pizza/` | Style & Layout | 861–912 ms | 546–576 ms |
112
+ | `/c/Pizza/` | Performance | 75–80 | 79–80 |
113
+ | stylesheet | `entry.*.css` | 253 KB / 32.5 KB gzip | 194 KB / 25.5 KB gzip |
114
+
115
+ The 20 KB gzip target of the issue is not reached: the remaining 25 KB
116
+ are the components the storefront does use (`UButton` with all colour
117
+ variants, `UNavigationMenu`, `USelectMenu`, …), the prose theme for the
118
+ content pages (4 KB) and the theme/preflight base (3 KB). Since the
119
+ stylesheet size has no measurable effect on Style & Layout, further
120
+ trimming (a separate prose stylesheet for the content pages, fewer colour
121
+ aliases) is a transfer-size topic, not a main-thread one.
122
+
123
+ ## Tooling
124
+
125
+ `scripts/perf/h2-proxy.cjs` (TLS + HTTP/2 + gzip in front of the Nitro
126
+ server, plus a static `/exp/` directory for page variants),
127
+ `scripts/perf/lighthouse.sh` (mobile run with the main-thread breakdown
128
+ per page) and `scripts/perf/first-render.mjs` (first style recalculation
129
+ and layout via CDP, optional request blocking) are checked in so the
130
+ setup of the #273/#314/#319 notes does not have to be rebuilt.
131
+ `test/visual/` holds the Playwright screenshot suite used for the
132
+ before/after comparison (`pnpm playwright test --config
133
+ test/visual/playwright.config.ts --update-snapshots` on the baseline,
134
+ then without the flag).
135
+
136
+ ## Verification
137
+
138
+ - Playwright screenshots (home, category, product card options, cart
139
+ drawer, checkout, footer; light and dark; 390 px and 1280 px) are
140
+ pixel-identical to the baseline after each step (24 images, `maxDiffPixels: 0`).
141
+ - The inlined colour style now maps `--ui-color-primary-*` to the brand
142
+ scale; no `var(--color-#…)` left.
143
+ - Unit tests, Prettier, ESLint, typecheck and build pass.
144
+
145
+ ## Not done / follow-ups
146
+
147
+ - Prose theme (4 KB gzip) ships on every page; a page-level stylesheet
148
+ for `[...all].vue` would need the generated `#build/ui/prose` directory
149
+ as a Tailwind source, whose location differs between dev and build.
150
+ - `@nuxt/fonts` still emits italic faces (unused by the storefront) and
151
+ the Vietnamese subset (kept on purpose: Vietnamese menus).
152
+ - The hydration recalculation/layout pair after the entry chunk runs is
153
+ the next largest Style & Layout item; it belongs to the hydration
154
+ strategy (#314), not to the stylesheet.