@hszrdm/create-commerce 1.0.3 → 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 (69) hide show
  1. package/bin/create-commerce.mjs +9 -2
  2. package/package.json +1 -1
  3. package/src/cli.mjs +5 -2
  4. package/templates/backend/.env.example +66 -7
  5. package/templates/backend/medusa-config.ts +17 -1
  6. package/templates/backend/package.json +2 -1
  7. package/templates/backend/src/scripts/core-init.ts +13 -1
  8. package/templates/storefront/next-env.d.ts +4 -1
  9. package/templates/storefront/src/app/[countryCode]/categories/[handle]/page.tsx +9 -3
  10. package/templates/storefront/src/app/[countryCode]/products/[handle]/page.tsx +46 -10
  11. package/templates/storefront/src/app/[countryCode]/products/page.tsx +17 -10
  12. package/templates/storefront/src/app/account/page.tsx +12 -1
  13. package/templates/storefront/src/app/account/wishlist/page.tsx +9 -0
  14. package/templates/storefront/src/app/checkout/page.tsx +12 -3
  15. package/templates/storefront/src/app/checkout/success/page.tsx +58 -18
  16. package/templates/storefront/src/app/core-ux.css +244 -0
  17. package/templates/storefront/src/app/layout.tsx +40 -14
  18. package/templates/storefront/src/app/legal/page.tsx +11 -5
  19. package/templates/storefront/src/app/newsletter/confirm/page.tsx +19 -0
  20. package/templates/storefront/src/app/newsletter/unsubscribe/page.tsx +19 -0
  21. package/templates/storefront/src/app/page.tsx +18 -12
  22. package/templates/storefront/src/app/reset-password/page.tsx +8 -2
  23. package/templates/storefront/src/components/accessibility-preferences.tsx +126 -0
  24. package/templates/storefront/src/components/accessible-dialog.tsx +88 -0
  25. package/templates/storefront/src/components/accessible-dropdown.tsx +98 -0
  26. package/templates/storefront/src/components/account-dashboard.tsx +197 -76
  27. package/templates/storefront/src/components/account-wishlist.tsx +95 -0
  28. package/templates/storefront/src/components/add-to-cart.tsx +127 -18
  29. package/templates/storefront/src/components/back-to-top.tsx +26 -0
  30. package/templates/storefront/src/components/breadcrumbs.tsx +26 -0
  31. package/templates/storefront/src/components/cart-provider.tsx +29 -12
  32. package/templates/storefront/src/components/cart-view.tsx +96 -32
  33. package/templates/storefront/src/components/checkout-analytics.tsx +23 -0
  34. package/templates/storefront/src/components/checkout-flow.tsx +354 -102
  35. package/templates/storefront/src/components/form-ux.tsx +47 -0
  36. package/templates/storefront/src/components/free-shipping-progress.tsx +35 -0
  37. package/templates/storefront/src/components/newsletter-action.tsx +66 -0
  38. package/templates/storefront/src/components/order-detail.tsx +84 -45
  39. package/templates/storefront/src/components/product-card.tsx +16 -8
  40. package/templates/storefront/src/components/product-gallery.tsx +64 -0
  41. package/templates/storefront/src/components/quantity-stepper.tsx +41 -0
  42. package/templates/storefront/src/components/reset-password-form.tsx +19 -13
  43. package/templates/storefront/src/components/share-button.tsx +63 -0
  44. package/templates/storefront/src/components/storefront-header.tsx +88 -20
  45. package/templates/storefront/src/components/stripe-payment.tsx +20 -4
  46. package/templates/storefront/src/components/tier-progress-hint.tsx +32 -0
  47. package/templates/storefront/src/components/toast-provider.tsx +92 -0
  48. package/templates/storefront/src/components/variant-price-display.tsx +31 -0
  49. package/templates/storefront/src/components/wishlist-button.tsx +88 -0
  50. package/templates/storefront/src/lib/core/account.ts +3 -0
  51. package/templates/storefront/src/lib/core/catalog.ts +37 -5
  52. package/templates/storefront/src/lib/core/client.ts +5 -0
  53. package/templates/storefront/src/lib/core/cms-contract.ts +35 -0
  54. package/templates/storefront/src/lib/core/cms.ts +171 -0
  55. package/templates/storefront/src/lib/core/commerce.ts +14 -4
  56. package/templates/storefront/src/lib/core/form-ux.ts +57 -0
  57. package/templates/storefront/src/lib/core/leads.ts +50 -0
  58. package/templates/storefront/src/lib/core/newsletter.ts +53 -0
  59. package/templates/storefront/src/lib/core/pricing.ts +68 -0
  60. package/templates/storefront/src/lib/core/quotes.ts +43 -0
  61. package/templates/storefront/src/lib/core/reviews.ts +40 -0
  62. package/templates/storefront/src/lib/core/seo.ts +44 -6
  63. package/templates/storefront/src/lib/core/share.ts +57 -0
  64. package/templates/storefront/src/lib/core/wishlist.ts +88 -0
  65. package/templates/storefront/src/lib/storefront-copy.ts +435 -0
  66. package/templates/storefront/src/lib/storefront-locale-server.ts +11 -0
  67. package/templates/storefront/src/lib/storefront-routes.ts +94 -0
  68. package/templates/storefront/src/proxy.ts +145 -0
  69. package/templates/storefront/tsconfig.json +23 -5
@@ -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,11 +1,16 @@
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"
12
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
13
+ import { STOREFRONT_ROUTES } from "@/lib/storefront-routes"
9
14
 
10
15
  const consentDefaultScript = `
11
16
  window.dataLayer = window.dataLayer || [];
@@ -36,23 +41,44 @@ export async function generateMetadata(): Promise<Metadata> {
36
41
  }
37
42
 
38
43
  export default async function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
39
- const config = await getCoreConfig()
44
+ const [config, locale] = await Promise.all([
45
+ getCoreConfig(),
46
+ requestStorefrontLocale(),
47
+ ])
48
+ const routes = STOREFRONT_ROUTES[locale]
49
+ const en = locale === "en"
50
+
40
51
  return (
41
- <html lang={config.store.locale.split("-")[0]}>
52
+ <html lang={locale}>
42
53
  <head><script dangerouslySetInnerHTML={{ __html: consentDefaultScript }} /></head>
43
54
  <body>
44
- <CartProvider config={config}>
45
- <StorefrontHeader config={config} />
46
- <main className="shell main">{children}</main>
47
- <footer className="footer">
48
- <div className="shell footer-inner">
49
- <div><strong>{config.store.name}</strong><p className="muted small">Powered by HSZRDM Commerce</p></div>
50
- <nav className="footer-nav"><Link href="/legal">Jogi dokumentumok</Link><Link href="/account">Fiókom</Link><Link href={`/${config.seo.default_country_code}/products`}>Termékek</Link></nav>
51
- </div>
52
- </footer>
53
- <AnalyticsGate analytics={config.analytics} />
54
- <ConsentBanner enabled={config.features.analytics} />
55
- </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>
56
82
  </body>
57
83
  </html>
58
84
  )
@@ -1,26 +1,32 @@
1
1
  import { getCoreConfig } from "@/lib/core/client"
2
2
  import { listLegalDocuments } from "@/lib/core/legal"
3
+ import { storefrontCopy } from "@/lib/storefront-copy"
4
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
3
5
 
4
6
  export default async function LegalPage() {
5
- const config = await getCoreConfig()
7
+ const [config, locale] = await Promise.all([
8
+ getCoreConfig(),
9
+ requestStorefrontLocale(),
10
+ ])
11
+ const copy = storefrontCopy(locale)
6
12
  const { documents } = await listLegalDocuments(config)
7
13
 
8
14
  return (
9
15
  <div className="stack page-section">
10
16
  <div className="page-heading">
11
- <div><p className="eyebrow">Jogi dokumentumok</p><h1>Aktuális szabályzatok</h1><p className="muted">Mindig a backendben verziózott, aktuális dokumentumok jelennek meg.</p></div>
17
+ <div><p className="eyebrow">{copy.legalEyebrow}</p><h1>{copy.legalTitle}</h1><p className="muted">{copy.legalDescription}</p></div>
12
18
  </div>
13
19
  {documents.length ? (
14
20
  <div className="product-grid">
15
21
  {documents.map((document) => (
16
22
  <article className="card stack-sm" key={document.key}>
17
23
  <h2>{document.title || document.key}</h2>
18
- <p className="muted">{(document.requiredAtCheckout ?? document.required_at_checkout) ? "Checkoutnál elfogadás szükséges." : "Tájékoztató dokumentum."}</p>
19
- {document.pdfEndpoint ? <a className="button secondary" href={document.pdfEndpoint} target="_blank" rel="noreferrer">PDF megnyitása</a> : null}
24
+ <p className="muted">{(document.requiredAtCheckout ?? document.required_at_checkout) ? copy.requiredAtCheckout : copy.infoDocument}</p>
25
+ {document.pdfEndpoint ? <a className="button secondary" href={document.pdfEndpoint} target="_blank" rel="noreferrer">{copy.openPdf}</a> : null}
20
26
  </article>
21
27
  ))}
22
28
  </div>
23
- ) : <div className="empty-state">Nincs publikált jogi dokumentum.</div>}
29
+ ) : <div className="empty-state">{copy.noLegalDocuments}</div>}
24
30
  </div>
25
31
  )
26
32
  }
@@ -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
+ }
@@ -4,43 +4,49 @@ import { getCoreConfig } from "@/lib/core/client"
4
4
  import { checkoutApi } from "@/lib/core/checkout"
5
5
  import { listCategories, listProducts } from "@/lib/core/catalog"
6
6
  import { stringValue } from "@/lib/core/commerce"
7
+ import { storefrontCopy } from "@/lib/storefront-copy"
8
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
9
+ import { categoryPath, medusaLocale, STOREFRONT_ROUTES } from "@/lib/storefront-routes"
7
10
 
8
11
  export default async function HomePage() {
9
12
  const config = await getCoreConfig()
13
+ const locale = await requestStorefrontLocale()
14
+ const copy = storefrontCopy(locale)
15
+ const apiLocale = medusaLocale(locale)
10
16
  const region = await checkoutApi(config).resolveDefaultRegion().catch(() => null)
11
17
  const regionId = region ? stringValue(region.id) : undefined
12
18
  const [{ products }, { product_categories: categories }] = await Promise.all([
13
- listProducts({ limit: 8, order: "-created_at", regionId }).catch(() => ({ products: [] })),
14
- listCategories().catch(() => ({ product_categories: [] })),
19
+ listProducts({ limit: 8, order: "-created_at", regionId, locale: apiLocale }).catch(() => ({ products: [] })),
20
+ listCategories(apiLocale).catch(() => ({ product_categories: [] })),
15
21
  ])
16
- const country = config.seo.default_country_code
22
+ const routes = STOREFRONT_ROUTES[locale]
17
23
 
18
24
  return (
19
25
  <div className="stack page-section">
20
26
  <section className="hero storefront-hero">
21
27
  <div className="hero-copy">
22
28
  <p className="eyebrow">{config.store.name}</p>
23
- <h1>Gyors, biztonságos vásárlás Medusa Core alapon.</h1>
24
- <p className="hero-text">A termékek, árak, kedvezmények, szállítás, fizetés és jogi szabályok közvetlenül a backend aktuális konfigurációjából érkeznek.</p>
25
- <div className="button-row"><Link className="button button-large" href={`/${country}/products`}>Termékek</Link>{config.features.account ? <Link className="button secondary button-large" href="/account">Fiókom</Link> : null}</div>
29
+ <h1>{copy.homeHeroTitle}</h1>
30
+ <p className="hero-text">{copy.homeHeroText}</p>
31
+ <div className="button-row"><Link className="button button-large" href={routes.products}>{copy.products}</Link>{config.features.account ? <Link className="button secondary button-large" href={routes.account}>{copy.account}</Link> : null}</div>
26
32
  </div>
27
33
  <div className="hero-card">
28
34
  <span className="hero-stat">Core</span>
29
- <strong>Egy starter, több webshop.</strong>
30
- <p>Az ügyfél-specifikus design cserélhető, a checkout/account/legal/SEO/analytics integrációs réteg újrahasznosítható.</p>
35
+ <strong>{copy.homeCoreTitle}</strong>
36
+ <p>{copy.homeCoreText}</p>
31
37
  </div>
32
38
  </section>
33
39
 
34
40
  {categories.length ? (
35
41
  <section className="stack-sm">
36
- <div className="section-heading"><div><p className="eyebrow">Kategóriák</p><h2>Fedezd fel a kínálatot</h2></div><Link className="text-link" href={`/${country}/products`}>Összes termék →</Link></div>
37
- <div className="category-row">{categories.slice(0, 8).map((category) => <Link className="category-chip" key={stringValue(category.id)} href={`/${country}/categories/${encodeURIComponent(stringValue(category.handle))}`}>{stringValue(category.name)}</Link>)}</div>
42
+ <div className="section-heading"><div><p className="eyebrow">{copy.categories}</p><h2>{copy.discoverOffer}</h2></div><Link className="text-link" href={routes.products}>{copy.allProducts}</Link></div>
43
+ <div className="category-row">{categories.slice(0, 8).map((category) => <Link className="category-chip" key={stringValue(category.id)} href={categoryPath(locale, stringValue(category.handle))}>{stringValue(category.name)}</Link>)}</div>
38
44
  </section>
39
45
  ) : null}
40
46
 
41
47
  <section className="stack-sm">
42
- <div className="section-heading"><div><p className="eyebrow">Újdonságok</p><h2>Legfrissebb termékek</h2></div><Link className="text-link" href={`/${country}/products`}>Teljes kínálat →</Link></div>
43
- {products.length ? <div className="product-grid">{products.map((product) => <ProductCard key={stringValue(product.id)} product={product} config={config} />)}</div> : <div className="empty-state">Még nincs publikált termék.</div>}
48
+ <div className="section-heading"><div><p className="eyebrow">{copy.newProducts}</p><h2>{copy.latestProducts}</h2></div><Link className="text-link" href={routes.products}>{copy.fullCatalog}</Link></div>
49
+ {products.length ? <div className="product-grid">{products.map((product) => <ProductCard key={stringValue(product.id)} product={product} config={config} locale={locale} />)}</div> : <div className="empty-state">{copy.noPublishedProducts}</div>}
44
50
  </section>
45
51
  </div>
46
52
  )
@@ -1,12 +1,18 @@
1
1
  import { Suspense } from "react"
2
2
  import { ResetPasswordForm } from "@/components/reset-password-form"
3
3
  import { getCoreConfig } from "@/lib/core/client"
4
+ import { storefrontCopy } from "@/lib/storefront-copy"
5
+ import { requestStorefrontLocale } from "@/lib/storefront-locale-server"
4
6
 
5
7
  export default async function ResetPasswordPage() {
6
- const config = await getCoreConfig()
8
+ const [config, locale] = await Promise.all([
9
+ getCoreConfig(),
10
+ requestStorefrontLocale(),
11
+ ])
12
+ const copy = storefrontCopy(locale)
7
13
  return (
8
14
  <div className="page-section narrow-page">
9
- <Suspense fallback={<div className="empty-state">Betöltés…</div>}>
15
+ <Suspense fallback={<div className="empty-state">{copy.loading}</div>}>
10
16
  <ResetPasswordForm config={config} />
11
17
  </Suspense>
12
18
  </div>
@@ -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
+ }