@hszrdm/create-commerce 1.1.0 → 1.2.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 (38) hide show
  1. package/package.json +1 -1
  2. package/src/cli.mjs +5 -2
  3. package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +41 -9
  4. package/templates/storefront/src/app/account/page.tsx +12 -1
  5. package/templates/storefront/src/app/account/wishlist/page.tsx +9 -0
  6. package/templates/storefront/src/app/core-ux.css +244 -0
  7. package/templates/storefront/src/app/layout.tsx +31 -12
  8. package/templates/storefront/src/app/newsletter/confirm/page.tsx +19 -0
  9. package/templates/storefront/src/app/newsletter/unsubscribe/page.tsx +19 -0
  10. package/templates/storefront/src/components/accessibility-preferences.tsx +126 -0
  11. package/templates/storefront/src/components/accessible-dialog.tsx +88 -0
  12. package/templates/storefront/src/components/accessible-dropdown.tsx +98 -0
  13. package/templates/storefront/src/components/account-wishlist.tsx +95 -0
  14. package/templates/storefront/src/components/add-to-cart.tsx +110 -15
  15. package/templates/storefront/src/components/back-to-top.tsx +26 -0
  16. package/templates/storefront/src/components/breadcrumbs.tsx +26 -0
  17. package/templates/storefront/src/components/cart-view.tsx +72 -16
  18. package/templates/storefront/src/components/form-ux.tsx +47 -0
  19. package/templates/storefront/src/components/free-shipping-progress.tsx +35 -0
  20. package/templates/storefront/src/components/newsletter-action.tsx +66 -0
  21. package/templates/storefront/src/components/product-gallery.tsx +64 -0
  22. package/templates/storefront/src/components/quantity-stepper.tsx +41 -0
  23. package/templates/storefront/src/components/share-button.tsx +63 -0
  24. package/templates/storefront/src/components/storefront-header.tsx +72 -18
  25. package/templates/storefront/src/components/tier-progress-hint.tsx +32 -0
  26. package/templates/storefront/src/components/toast-provider.tsx +92 -0
  27. package/templates/storefront/src/components/variant-price-display.tsx +31 -0
  28. package/templates/storefront/src/components/wishlist-button.tsx +88 -0
  29. package/templates/storefront/src/lib/core/account.ts +3 -0
  30. package/templates/storefront/src/lib/core/cms-contract.ts +35 -0
  31. package/templates/storefront/src/lib/core/cms.ts +66 -7
  32. package/templates/storefront/src/lib/core/form-ux.ts +57 -0
  33. package/templates/storefront/src/lib/core/newsletter.ts +53 -0
  34. package/templates/storefront/src/lib/core/reviews.ts +40 -0
  35. package/templates/storefront/src/lib/core/share.ts +57 -0
  36. package/templates/storefront/src/lib/core/wishlist.ts +88 -0
  37. package/templates/storefront/src/lib/storefront-routes.ts +3 -0
  38. package/templates/storefront/src/proxy.ts +3 -0
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hszrdm/create-commerce",
3
- "version": "1.1.0",
3
+ "version": "1.2.0",
4
4
  "description": "Create a complete HSZRDM Commerce webshop project.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
package/src/cli.mjs CHANGED
@@ -14,6 +14,9 @@ import { createInterface } from "node:readline/promises"
14
14
  import { stdin as input, stdout as output } from "node:process"
15
15
 
16
16
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), "..")
17
+ const packageVersion = clean(
18
+ JSON.parse(readFileSync(join(packageRoot, "package.json"), "utf8")).version,
19
+ )
17
20
 
18
21
  export async function main(argv = process.argv.slice(2)) {
19
22
  const parsed = parseArgs(argv)
@@ -191,7 +194,7 @@ async function collectSettings(projectName, flags) {
191
194
  cookieSecret: secret(48),
192
195
  integrationEncryptionKey: secret(48),
193
196
  shippingWebhookSecret: secret(48),
194
- coreVersion: clean(flags["core-version"] || "1.0.3"),
197
+ coreVersion: clean(flags["core-version"] || packageVersion),
195
198
  }
196
199
  } finally {
197
200
  rl?.close()
@@ -582,5 +585,5 @@ function bool(value) {
582
585
  }
583
586
 
584
587
  function printHelp() {
585
- console.log(`HSZRDM Commerce project generator\n\nHasználat:\n npx @hszrdm/create-commerce <project-name> [opciók]\n\nFő opciók:\n --name <név>\n --slug <slug>\n --locale hu-HU\n --country HU\n --currency HUF\n --backend-url http://localhost:9000\n --storefront-url http://localhost:3000\n --admin-email <email>\n --admin-password <password>\n --database-url postgres://...\n --redis-url redis://...\n --postgres-port <port>\n --redis-port <port>\n --core-version 1.0.3\n --non-interactive\n --force\n\nInfrastruktúra:\n Ha --database-url és --redis-url meg van adva, a generátor Dockert nem használ.\n Ha nincsenek megadva, Docker Compose a fallback.\n\nFejlesztői kapcsolók:\n --skip-install\n --skip-docker\n --skip-bootstrap\n --skip-verify\n --skip-git\n\nLokális Core package teszthez:\n HSZRDM_CORE_PACKAGE=/abs/path/to/packages/core npx @hszrdm/create-commerce test-shop\n`)
588
+ console.log(`HSZRDM Commerce project generator\n\nHasználat:\n npx @hszrdm/create-commerce <project-name> [opciók]\n\nFő opciók:\n --name <név>\n --slug <slug>\n --locale hu-HU\n --country HU\n --currency HUF\n --backend-url http://localhost:9000\n --storefront-url http://localhost:3000\n --admin-email <email>\n --admin-password <password>\n --database-url postgres://...\n --redis-url redis://...\n --postgres-port <port>\n --redis-port <port>\n --core-version <verzió> (alapértelmezett: a generator package verziója)\n --non-interactive\n --force\n\nInfrastruktúra:\n Ha --database-url és --redis-url meg van adva, a generátor Dockert nem használ.\n Ha nincsenek megadva, Docker Compose a fallback.\n\nFejlesztői kapcsolók:\n --skip-install\n --skip-docker\n --skip-bootstrap\n --skip-verify\n --skip-git\n\nLokális Core package teszthez:\n HSZRDM_CORE_PACKAGE=/abs/path/to/packages/core npx @hszrdm/create-commerce test-shop\n`)
586
589
  }
@@ -1,14 +1,19 @@
1
1
  import { notFound } from "next/navigation"
2
2
  import { AddToCart } from "@/components/add-to-cart"
3
+ import { Breadcrumbs } from "@/components/breadcrumbs"
4
+ import { ProductGallery } from "@/components/product-gallery"
3
5
  import { ProductViewTracker } from "@/components/product-view-tracker"
6
+ import { ShareButton } from "@/components/share-button"
7
+ import { VariantPriceDisplay } from "@/components/variant-price-display"
8
+ import { WishlistButton } from "@/components/wishlist-button"
4
9
  import { getCoreConfig } from "@/lib/core/client"
5
10
  import { checkoutApi } from "@/lib/core/checkout"
6
11
  import { getProductByHandle } from "@/lib/core/catalog"
7
- import { asRecords, formatMoney, productVariantCurrency, productVariantPrice, stringValue } from "@/lib/core/commerce"
12
+ import { asRecords, productVariantCurrency, productVariantPrice, stringValue } from "@/lib/core/commerce"
8
13
  import { metadataFromCore, structuredDataForEntity } from "@/lib/core/seo"
9
14
  import { ecommerceItemFromProduct } from "@/lib/core/tracking"
10
15
  import { storefrontCopy } from "@/lib/storefront-copy"
11
- import { medusaLocale, storefrontLocale } from "@/lib/storefront-routes"
16
+ import { medusaLocale, STOREFRONT_ROUTES, storefrontLocale } from "@/lib/storefront-routes"
12
17
 
13
18
  export async function generateMetadata({ params }: { params: Promise<{ countryCode: string; handle: string }> }) {
14
19
  const { handle, countryCode } = await params
@@ -20,6 +25,7 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
20
25
  const { handle, countryCode } = await params
21
26
  const locale = storefrontLocale(countryCode)
22
27
  const copy = storefrontCopy(locale)
28
+ const routes = STOREFRONT_ROUTES[locale]
23
29
  const config = await getCoreConfig()
24
30
  const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
25
31
  const product = await getProductByHandle(handle, region ? stringValue(region.id) : undefined, medusaLocale(locale)).then((result) => result.products[0]).catch(() => null)
@@ -31,22 +37,48 @@ export default async function ProductPage({ params }: { params: Promise<{ countr
31
37
  const currency = productVariantCurrency(first, config.store.default_currency)
32
38
  const tracking = ecommerceItemFromProduct({ product, variant: first, currency })
33
39
  const images = asRecords(product.images)
40
+ const productId = stringValue(product.id)
41
+ const title = stringValue(product.title)
34
42
  const thumbnail = stringValue(product.thumbnail || images[0]?.url)
43
+ const formatLocale = locale === "en" ? "en-US" : "hu-HU"
44
+ const galleryImages = [
45
+ ...(thumbnail ? [{ id: "thumbnail", url: thumbnail, alt: title }] : []),
46
+ ...images
47
+ .map((image, index) => ({
48
+ id: stringValue(image.id || `image-${index}`),
49
+ url: stringValue(image.url),
50
+ alt: `${title} – ${index + 1}`,
51
+ }))
52
+ .filter((image) => image.url && image.url !== thumbnail),
53
+ ]
35
54
 
36
55
  return (
37
56
  <div className="stack page-section">
38
57
  {jsonLd ? <script className="jsonld" type="application/ld+json" dangerouslySetInnerHTML={{ __html: JSON.stringify(jsonLd) }} /> : null}
39
58
  <ProductViewTracker analytics={config.analytics} item={tracking.item} currency={tracking.currency} value={tracking.value} />
59
+ <Breadcrumbs
60
+ label={locale === "en" ? "Breadcrumb" : "Morzsanavigáció"}
61
+ items={[
62
+ { label: locale === "en" ? "Products" : "Termékek", href: routes.products },
63
+ { label: title },
64
+ ]}
65
+ />
40
66
  <div className="product-detail">
41
- <div className="product-gallery">
42
- <div className="product-main-image">{thumbnail ? <img src={thumbnail} alt={stringValue(product.title)} /> : <span className="media-placeholder">{copy.noImage}</span>}</div>
43
- {images.length > 1 ? <div className="thumbnail-row">{images.slice(0, 6).map((image, index) => <img key={`${stringValue(image.id)}:${index}`} src={stringValue(image.url)} alt="" />)}</div> : null}
44
- </div>
45
- <section className="product-copy stack">
46
- <div><p className="eyebrow">{copy.product}</p><h1>{stringValue(product.title)}</h1></div>
47
- {Number.isFinite(price) ? <div className="product-price">{formatMoney(price, currency, locale === "en" ? "en-US" : "hu-HU")}</div> : null}
67
+ <ProductGallery
68
+ title={title}
69
+ images={galleryImages}
70
+ emptyLabel={copy.noImage}
71
+ galleryLabel={locale === "en" ? "Product images" : "Termékképek"}
72
+ />
73
+ <section className="product-copy stack" aria-labelledby="product-title">
74
+ <div><p className="eyebrow">{copy.product}</p><h1 id="product-title">{title}</h1></div>
75
+ <VariantPriceDisplay initialPrice={price} initialCurrency={currency} locale={formatLocale} />
48
76
  {product.description ? <p className="product-description">{stringValue(product.description)}</p> : null}
49
77
  <AddToCart product={product} config={config} />
78
+ <div className="button-row product-secondary-actions">
79
+ {productId ? <WishlistButton productId={productId} /> : null}
80
+ <ShareButton title={title} text={stringValue(product.description)} />
81
+ </div>
50
82
  <div className="product-meta">{product.subtitle ? <span>{stringValue(product.subtitle)}</span> : null}{product.material ? <span>{copy.material}: {stringValue(product.material)}</span> : null}{product.origin_country ? <span>{copy.origin}: {stringValue(product.origin_country)}</span> : null}</div>
51
83
  </section>
52
84
  </div>
@@ -1,10 +1,21 @@
1
+ import Link from "next/link"
1
2
  import { AccountDashboard } from "@/components/account-dashboard"
2
3
  import { getCoreConfig } from "@/lib/core/client"
4
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
5
+ import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
3
6
 
4
7
  export default async function AccountPage() {
5
- const config = await getCoreConfig()
8
+ const [config, locale] = await Promise.all([
9
+ getCoreConfig(),
10
+ requestStorefrontLocale(),
11
+ ])
6
12
  return (
7
13
  <div className="stack page-section">
14
+ <div className="button-row">
15
+ <Link className="button secondary" href={STOREFRONT_ROUTES[locale].wishlist}>
16
+ {locale === "en" ? "Wishlist" : "Kedvencek"}
17
+ </Link>
18
+ </div>
8
19
  <AccountDashboard config={config} />
9
20
  </div>
10
21
  )
@@ -0,0 +1,9 @@
1
+ import { AccountWishlist } from "@/components/account-wishlist"
2
+
3
+ export default function AccountWishlistPage() {
4
+ return (
5
+ <div className="stack page-section">
6
+ <AccountWishlist />
7
+ </div>
8
+ )
9
+ }
@@ -0,0 +1,244 @@
1
+ /* HSZRDM Commerce generic storefront UX/accessibility layer.
2
+ * Brand colors remain storefront-owned; these rules define behavior and states.
3
+ */
4
+
5
+ .skip-link {
6
+ position: fixed;
7
+ z-index: 1000;
8
+ top: 10px;
9
+ left: 10px;
10
+ transform: translateY(-160%);
11
+ border-radius: 8px;
12
+ background: var(--text);
13
+ color: var(--surface);
14
+ padding: 10px 14px;
15
+ font-weight: 800;
16
+ }
17
+ .skip-link:focus { transform: translateY(0); }
18
+
19
+ :where(a, button, input, select, textarea, [tabindex]):focus-visible {
20
+ outline: 3px solid #2563eb;
21
+ outline-offset: 3px;
22
+ }
23
+ :where(button, [role="button"], .text-button, .chip, .category-chip) { min-width: 24px; min-height: 24px; }
24
+ [aria-invalid="true"] { border-color: var(--danger) !important; }
25
+ [aria-current="page"] { text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 5px; }
26
+
27
+ .field-label { display: block; margin-bottom: 7px; color: #384152; font-size: .88rem; font-weight: 700; }
28
+ .field-hint { display: block; margin-top: 5px; color: var(--muted); font-size: .78rem; }
29
+ .field-error { margin: 5px 0 0; color: var(--danger); font-size: .82rem; }
30
+ .required-mark { margin-left: 3px; color: var(--danger); }
31
+
32
+ .quantity-stepper {
33
+ display: grid;
34
+ grid-template-columns: 38px minmax(52px, 64px) 38px;
35
+ width: fit-content;
36
+ overflow: hidden;
37
+ border: 1px solid var(--line);
38
+ border-radius: 10px;
39
+ background: var(--surface);
40
+ }
41
+ .quantity-stepper button {
42
+ min-width: 38px;
43
+ min-height: 42px;
44
+ border: 0;
45
+ background: var(--surface-soft);
46
+ color: var(--text);
47
+ cursor: pointer;
48
+ font-size: 1.1rem;
49
+ font-weight: 800;
50
+ }
51
+ .quantity-stepper input {
52
+ min-height: 42px;
53
+ border: 0;
54
+ border-inline: 1px solid var(--line);
55
+ border-radius: 0;
56
+ padding: 5px;
57
+ text-align: center;
58
+ font-weight: 750;
59
+ appearance: textfield;
60
+ }
61
+ .quantity-stepper input::-webkit-inner-spin-button,
62
+ .quantity-stepper input::-webkit-outer-spin-button { margin: 0; appearance: none; }
63
+
64
+ .stock-status { width: fit-content; border-radius: 999px; padding: 6px 10px; font-size: .82rem; font-weight: 800; }
65
+ .stock-status.is-available { background: #e7f8ef; color: var(--success); }
66
+ .stock-status.is-unavailable { background: #fff1f0; color: var(--danger); }
67
+ .sku-row { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; font-size: .86rem; }
68
+ .sku-row code { user-select: all; }
69
+ .tier-progress-hint { margin: 0; color: var(--muted); font-size: .86rem; }
70
+
71
+ .thumbnail-button {
72
+ flex: 0 0 auto;
73
+ width: 76px;
74
+ height: 76px;
75
+ overflow: hidden;
76
+ border: 1px solid var(--line);
77
+ border-radius: 10px;
78
+ background: var(--surface);
79
+ padding: 0;
80
+ cursor: pointer;
81
+ }
82
+ .thumbnail-button img { width: 100%; height: 100%; object-fit: cover; }
83
+ .thumbnail-button.is-active { box-shadow: inset 0 0 0 2px var(--text); }
84
+
85
+ .product-secondary-actions { align-items: flex-start; }
86
+ .wishlist-button { gap: 8px; }
87
+ .wishlist-button > span[aria-hidden="true"] { font-size: 1.15em; line-height: 1; }
88
+ .wishlist-button.is-saved { border-color: var(--danger); }
89
+ .wishlist-button.is-saved > span[aria-hidden="true"] { color: var(--danger); }
90
+
91
+ .share-control { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
92
+ .share-links { display: flex; flex-wrap: wrap; gap: 10px; flex-basis: 100%; font-size: .88rem; }
93
+ .share-links a { text-decoration: underline; text-underline-offset: 3px; }
94
+
95
+ .breadcrumbs { color: var(--muted); font-size: .86rem; }
96
+ .breadcrumbs ol { display: flex; flex-wrap: wrap; gap: 7px; margin: 0; padding: 0; list-style: none; }
97
+ .breadcrumbs li { display: inline-flex; gap: 7px; align-items: center; }
98
+ .breadcrumbs li:not(:last-child)::after { content: "/"; color: #9aa1ab; }
99
+ .breadcrumbs a { text-decoration: underline; text-decoration-color: transparent; text-underline-offset: 3px; }
100
+ .breadcrumbs a:hover { text-decoration-color: currentColor; }
101
+
102
+ .toast-region {
103
+ position: fixed;
104
+ z-index: 180;
105
+ right: 18px;
106
+ bottom: 18px;
107
+ display: flex;
108
+ width: min(420px, calc(100vw - 36px));
109
+ flex-direction: column;
110
+ gap: 9px;
111
+ pointer-events: none;
112
+ }
113
+ .toast {
114
+ display: grid;
115
+ grid-template-columns: minmax(0, 1fr) auto auto;
116
+ gap: 12px;
117
+ align-items: center;
118
+ border: 1px solid var(--line);
119
+ border-radius: 13px;
120
+ background: var(--surface);
121
+ color: var(--text);
122
+ padding: 12px 13px;
123
+ box-shadow: 0 14px 44px rgba(16, 24, 40, .18);
124
+ pointer-events: auto;
125
+ }
126
+ .toast-success { border-color: #a6dfc1; }
127
+ .toast-error { border-color: #efb5ae; }
128
+ .toast-action { border: 0; background: none; color: var(--text); cursor: pointer; font-weight: 850; text-decoration: underline; text-underline-offset: 3px; }
129
+ .toast-close { width: 32px; height: 32px; border: 0; border-radius: 50%; background: var(--surface-soft); cursor: pointer; font-size: 1.1rem; }
130
+
131
+ .accessibility-control { position: relative; }
132
+ .accessibility-panel {
133
+ position: absolute;
134
+ z-index: 50;
135
+ right: 0;
136
+ bottom: calc(100% + 10px);
137
+ width: min(310px, calc(100vw - 32px));
138
+ border: 1px solid var(--line);
139
+ border-radius: 14px;
140
+ background: var(--surface);
141
+ padding: 16px;
142
+ box-shadow: var(--shadow);
143
+ }
144
+
145
+ .mobile-menu-trigger { display: none; }
146
+ .mobile-menu-drawer {
147
+ position: absolute;
148
+ top: 0;
149
+ bottom: 0;
150
+ left: 0;
151
+ width: min(420px, 92vw);
152
+ overflow-y: auto;
153
+ background: var(--surface);
154
+ padding: 24px;
155
+ box-shadow: 20px 0 60px rgba(15, 23, 42, .16);
156
+ }
157
+ .mobile-nav-links { display: flex; flex-direction: column; gap: 4px; }
158
+ .mobile-nav-links a,
159
+ .mobile-locale-switch a { min-height: 46px; display: flex; align-items: center; border-radius: 10px; padding: 10px 12px; font-weight: 750; }
160
+ .mobile-nav-links a:hover,
161
+ .mobile-locale-switch a:hover { background: var(--surface-soft); }
162
+ .mobile-locale-switch { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; border-top: 1px solid var(--line); padding-top: 16px; }
163
+
164
+ .shipping-progress { border: 1px solid var(--line); border-radius: 12px; padding: 14px; background: var(--surface); }
165
+ .shipping-progress-copy { display: flex; justify-content: space-between; gap: 12px; font-size: .84rem; }
166
+ .shipping-progress-copy span { color: var(--muted); white-space: nowrap; }
167
+ .progress-track { height: 8px; overflow: hidden; border-radius: 999px; background: var(--surface-soft); }
168
+ .progress-track span { display: block; height: 100%; border-radius: inherit; background: var(--brand); transition: width .2s ease; }
169
+
170
+ .back-to-top {
171
+ position: fixed;
172
+ z-index: 70;
173
+ right: 16px;
174
+ bottom: 16px;
175
+ min-height: 40px;
176
+ border: 1px solid var(--line);
177
+ border-radius: 999px;
178
+ background: var(--surface);
179
+ color: var(--text);
180
+ padding: 8px 12px;
181
+ box-shadow: 0 6px 24px rgba(16, 24, 40, .12);
182
+ cursor: pointer;
183
+ font-weight: 750;
184
+ }
185
+
186
+ html[data-font-scale="large"] { font-size: 112.5%; }
187
+
188
+ html[data-contrast="high"] {
189
+ --bg: #fff;
190
+ --surface: #fff;
191
+ --surface-soft: #f1f1f1;
192
+ --text: #000;
193
+ --muted: #343434;
194
+ --line: #565656;
195
+ --brand: #000;
196
+ --brand-contrast: #fff;
197
+ --success: #006b32;
198
+ --danger: #9b0000;
199
+ --warning: #714c00;
200
+ }
201
+ html[data-contrast="high"] :where(input, select, textarea, .panel, .card, .product-card, .quantity-stepper) { border-color: #565656; }
202
+ html[data-contrast="high"] :where(a, button, input, select, textarea, [tabindex]):focus-visible {
203
+ outline-color: #005fcc;
204
+ outline-width: 4px;
205
+ }
206
+
207
+ @media (prefers-reduced-motion: reduce) {
208
+ html:not([data-motion="full"]) { scroll-behavior: auto; }
209
+ html:not([data-motion="full"]) *,
210
+ html:not([data-motion="full"]) *::before,
211
+ html:not([data-motion="full"]) *::after {
212
+ animation-duration: .01ms !important;
213
+ animation-iteration-count: 1 !important;
214
+ scroll-behavior: auto !important;
215
+ transition-duration: .01ms !important;
216
+ }
217
+ }
218
+ html[data-motion="reduced"] { scroll-behavior: auto; }
219
+ html[data-motion="reduced"] *,
220
+ html[data-motion="reduced"] *::before,
221
+ html[data-motion="reduced"] *::after {
222
+ animation-duration: .01ms !important;
223
+ animation-iteration-count: 1 !important;
224
+ scroll-behavior: auto !important;
225
+ transition-duration: .01ms !important;
226
+ }
227
+
228
+ @media (max-width: 760px) {
229
+ .toast-region { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
230
+ .accessibility-control { width: 100%; }
231
+ .accessibility-panel { right: auto; left: 0; }
232
+ .mobile-menu-trigger { display: inline-grid; place-items: center; }
233
+ .locale-switch { display: none; }
234
+ .sticky-mobile-cta {
235
+ position: sticky;
236
+ z-index: 20;
237
+ bottom: 10px;
238
+ width: 100%;
239
+ box-shadow: 0 8px 30px rgba(16, 24, 40, .18);
240
+ }
241
+ .shipping-progress-copy { flex-direction: column; }
242
+ .product-secondary-actions { flex-direction: column; align-items: stretch; }
243
+ .product-secondary-actions > * { width: 100%; }
244
+ }
@@ -1,10 +1,13 @@
1
1
  import "./globals.css"
2
+ import "./core-ux.css"
2
3
  import type { Metadata } from "next"
3
4
  import Link from "next/link"
5
+ import { AccessibilityPreferencesControl, AccessibilityPreferencesProvider } from "@/components/accessibility-preferences"
4
6
  import { AnalyticsGate } from "@/components/analytics"
5
7
  import { CartProvider } from "@/components/cart-provider"
6
8
  import { ConsentBanner } from "@/components/consent-banner"
7
9
  import { StorefrontHeader } from "@/components/storefront-header"
10
+ import { ToastProvider } from "@/components/toast-provider"
8
11
  import { getCoreConfig } from "@/lib/core/client"
9
12
  import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
10
13
  import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
@@ -43,23 +46,39 @@ export default async function RootLayout({ children }: Readonly<{ children: Reac
43
46
  requestStorefrontLocale(),
44
47
  ])
45
48
  const routes = STOREFRONT_ROUTES[locale]
49
+ const en = locale === "en"
46
50
 
47
51
  return (
48
52
  <html lang={locale}>
49
53
  <head><script dangerouslySetInnerHTML={{ __html: consentDefaultScript }} /></head>
50
54
  <body>
51
- <CartProvider config={config}>
52
- <StorefrontHeader config={config} />
53
- <main className="shell main">{children}</main>
54
- <footer className="footer">
55
- <div className="shell footer-inner">
56
- <div><strong>{config.store.name}</strong><p className="muted small">Powered by HSZRDM Commerce</p></div>
57
- <nav className="footer-nav"><Link href={routes.legal}>Jogi dokumentumok</Link><Link href={routes.account}>Fiókom</Link><Link href={routes.products}>Termékek</Link></nav>
58
- </div>
59
- </footer>
60
- <AnalyticsGate analytics={config.analytics} />
61
- <ConsentBanner enabled={config.features.analytics} />
62
- </CartProvider>
55
+ <AccessibilityPreferencesProvider>
56
+ <ToastProvider locale={locale}>
57
+ <CartProvider config={config}>
58
+ <a className="skip-link" href="#main-content">
59
+ {en ? "Skip to content" : "Ugrás a tartalomhoz"}
60
+ </a>
61
+ <StorefrontHeader config={config} />
62
+ <main id="main-content" className="shell main" tabIndex={-1}>{children}</main>
63
+ <footer className="footer">
64
+ <div className="shell footer-inner">
65
+ <div>
66
+ <strong>{config.store.name}</strong>
67
+ <p className="muted small">Powered by HSZRDM Commerce</p>
68
+ </div>
69
+ <nav className="footer-nav" aria-label={en ? "Footer navigation" : "Lábléc navigáció"}>
70
+ <Link href={routes.legal}>{en ? "Legal documents" : "Jogi dokumentumok"}</Link>
71
+ <Link href={routes.account}>{en ? "Account" : "Fiókom"}</Link>
72
+ <Link href={routes.products}>{en ? "Products" : "Termékek"}</Link>
73
+ </nav>
74
+ <AccessibilityPreferencesControl locale={locale} />
75
+ </div>
76
+ </footer>
77
+ <AnalyticsGate analytics={config.analytics} />
78
+ <ConsentBanner enabled={config.features.analytics} />
79
+ </CartProvider>
80
+ </ToastProvider>
81
+ </AccessibilityPreferencesProvider>
63
82
  </body>
64
83
  </html>
65
84
  )
@@ -0,0 +1,19 @@
1
+ import { NewsletterAction } from "@/components/newsletter-action"
2
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
3
+
4
+ type PageProps = {
5
+ searchParams: Promise<Record<string, string | string[] | undefined>>
6
+ }
7
+
8
+ export default async function NewsletterConfirmPage({ searchParams }: PageProps) {
9
+ const [params, locale] = await Promise.all([searchParams, requestStorefrontLocale()])
10
+ const rawToken = params.token
11
+ const token = Array.isArray(rawToken) ? rawToken[0] || "" : rawToken || ""
12
+ const language = String(locale).startsWith("en") ? "en" : "hu"
13
+
14
+ return (
15
+ <div className="page-section narrow-page">
16
+ <NewsletterAction action="confirm" token={token} locale={language} />
17
+ </div>
18
+ )
19
+ }
@@ -0,0 +1,19 @@
1
+ import { NewsletterAction } from "@/components/newsletter-action"
2
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
3
+
4
+ type PageProps = {
5
+ searchParams: Promise<Record<string, string | string[] | undefined>>
6
+ }
7
+
8
+ export default async function NewsletterUnsubscribePage({ searchParams }: PageProps) {
9
+ const [params, locale] = await Promise.all([searchParams, requestStorefrontLocale()])
10
+ const rawToken = params.token
11
+ const token = Array.isArray(rawToken) ? rawToken[0] || "" : rawToken || ""
12
+ const language = String(locale).startsWith("en") ? "en" : "hu"
13
+
14
+ return (
15
+ <div className="page-section narrow-page">
16
+ <NewsletterAction action="unsubscribe" token={token} locale={language} />
17
+ </div>
18
+ )
19
+ }
@@ -0,0 +1,126 @@
1
+ "use client"
2
+
3
+ import {
4
+ createContext,
5
+ useContext,
6
+ useEffect,
7
+ useMemo,
8
+ useState,
9
+ type ReactNode,
10
+ } from "react"
11
+
12
+ type ContrastPreference = "normal" | "high"
13
+ type MotionPreference = "system" | "reduced" | "full"
14
+ type FontScalePreference = "normal" | "large"
15
+
16
+ type AccessibilityPreferences = {
17
+ contrast: ContrastPreference
18
+ motion: MotionPreference
19
+ fontScale: FontScalePreference
20
+ }
21
+
22
+ type AccessibilityContextValue = AccessibilityPreferences & {
23
+ setContrast: (value: ContrastPreference) => void
24
+ setMotion: (value: MotionPreference) => void
25
+ setFontScale: (value: FontScalePreference) => void
26
+ reset: () => void
27
+ }
28
+
29
+ const STORAGE_KEY = "hszrdm_accessibility_preferences"
30
+ const defaults: AccessibilityPreferences = {
31
+ contrast: "normal",
32
+ motion: "system",
33
+ fontScale: "normal",
34
+ }
35
+
36
+ const AccessibilityContext = createContext<AccessibilityContextValue | null>(null)
37
+
38
+ export function AccessibilityPreferencesProvider({ children }: { children: ReactNode }) {
39
+ const [preferences, setPreferences] = useState<AccessibilityPreferences>(defaults)
40
+
41
+ useEffect(() => {
42
+ try {
43
+ const raw = window.localStorage.getItem(STORAGE_KEY)
44
+ if (!raw) return
45
+ const parsed = JSON.parse(raw) as Partial<AccessibilityPreferences>
46
+ setPreferences({
47
+ contrast: parsed.contrast === "high" ? "high" : "normal",
48
+ motion: parsed.motion === "reduced" || parsed.motion === "full" ? parsed.motion : "system",
49
+ fontScale: parsed.fontScale === "large" ? "large" : "normal",
50
+ })
51
+ } catch {
52
+ // Invalid legacy preference must not block rendering.
53
+ }
54
+ }, [])
55
+
56
+ useEffect(() => {
57
+ const root = document.documentElement
58
+ root.dataset.contrast = preferences.contrast
59
+ root.dataset.motion = preferences.motion
60
+ root.dataset.fontScale = preferences.fontScale
61
+ window.localStorage.setItem(STORAGE_KEY, JSON.stringify(preferences))
62
+ }, [preferences])
63
+
64
+ const value = useMemo<AccessibilityContextValue>(() => ({
65
+ ...preferences,
66
+ setContrast: (contrast) => setPreferences((current) => ({ ...current, contrast })),
67
+ setMotion: (motion) => setPreferences((current) => ({ ...current, motion })),
68
+ setFontScale: (fontScale) => setPreferences((current) => ({ ...current, fontScale })),
69
+ reset: () => setPreferences(defaults),
70
+ }), [preferences])
71
+
72
+ return <AccessibilityContext.Provider value={value}>{children}</AccessibilityContext.Provider>
73
+ }
74
+
75
+ export function AccessibilityPreferencesControl({ locale = "hu" }: { locale?: "hu" | "en" }) {
76
+ const preferences = useAccessibilityPreferences()
77
+ const [open, setOpen] = useState(false)
78
+ const en = locale === "en"
79
+
80
+ return (
81
+ <div className="accessibility-control">
82
+ <button
83
+ type="button"
84
+ className="text-button"
85
+ aria-expanded={open}
86
+ aria-controls="accessibility-preferences-panel"
87
+ onClick={() => setOpen((current) => !current)}
88
+ >
89
+ {en ? "Display preferences" : "Megjelenési beállítások"}
90
+ </button>
91
+ {open ? (
92
+ <div id="accessibility-preferences-panel" className="accessibility-panel stack-sm">
93
+ <label>
94
+ {en ? "Contrast" : "Kontraszt"}
95
+ <select value={preferences.contrast} onChange={(event) => preferences.setContrast(event.target.value as ContrastPreference)}>
96
+ <option value="normal">{en ? "Normal" : "Normál"}</option>
97
+ <option value="high">{en ? "High contrast" : "Magas kontraszt"}</option>
98
+ </select>
99
+ </label>
100
+ <label>
101
+ {en ? "Motion" : "Mozgás"}
102
+ <select value={preferences.motion} onChange={(event) => preferences.setMotion(event.target.value as MotionPreference)}>
103
+ <option value="system">{en ? "System preference" : "Rendszerbeállítás"}</option>
104
+ <option value="reduced">{en ? "Reduced" : "Csökkentett"}</option>
105
+ <option value="full">{en ? "Full" : "Teljes"}</option>
106
+ </select>
107
+ </label>
108
+ <label>
109
+ {en ? "Text size" : "Betűméret"}
110
+ <select value={preferences.fontScale} onChange={(event) => preferences.setFontScale(event.target.value as FontScalePreference)}>
111
+ <option value="normal">{en ? "Normal" : "Normál"}</option>
112
+ <option value="large">{en ? "Larger" : "Nagyobb"}</option>
113
+ </select>
114
+ </label>
115
+ <button type="button" className="button secondary" onClick={preferences.reset}>{en ? "Reset" : "Alaphelyzet"}</button>
116
+ </div>
117
+ ) : null}
118
+ </div>
119
+ )
120
+ }
121
+
122
+ export function useAccessibilityPreferences() {
123
+ const context = useContext(AccessibilityContext)
124
+ if (!context) throw new Error("useAccessibilityPreferences csak AccessibilityPreferencesProvider alatt használható.")
125
+ return context
126
+ }