@thorprovider/storefront 0.11.0 → 0.13.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +19 -6
- package/assets/templates/app/lib/__STOREFRONT__/footer-content.ts +241 -0
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +8 -24
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +5 -3
- package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +14 -13
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +7 -2
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +52 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.universal-main-menu.ts +136 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-main-menu.client.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/universal-main-menu.tsx +16 -0
- package/assets/templates/views/home/assembly/assembly.json +7 -0
- package/bin/storefront.js +54 -19
- package/package.json +1 -1
- package/recipes/recipes.json +3 -1
- package/recipes/sections.json +13 -3
- package/scripts/candidate.mjs +1 -1
- package/scripts/default-sections.mjs +1 -0
- package/scripts/file-classes.mjs +3 -0
- package/scripts/scaffold-env.mjs +48 -0
- package/skills/sf-view-gen/assets/recipes/recipes.json +3 -1
- package/skills/sf-view-gen/assets/recipes/sections.json +13 -3
- package/skills/sf-view-gen/assets/templates/views/sections/schema.universal-main-menu.ts +136 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-main-menu.client.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/universal-main-menu.tsx +16 -0
package/README.md
CHANGED
|
@@ -472,12 +472,25 @@ The shell's derived `spec/index.ts` imports the user-owned `shell/props.ts`
|
|
|
472
472
|
surface and footer copy are configured without touching derived files. Configure
|
|
473
473
|
`shell/content.ts` (`logoAccent`/`brandAccent`, `navbarClassName`/`footerClassName`,
|
|
474
474
|
`brandDescription`, `linkColumns`); defaults are neutral and link only to served routes
|
|
475
|
-
(`/`, `/categories`, `/checkout`), never dead `#` links. `
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
The generated footer
|
|
480
|
-
|
|
475
|
+
(`/`, `/categories`, `/checkout`), never dead `#` links. `shippingNote` defaults to `''`:
|
|
476
|
+
while it is empty (and there are no utility links) the navbar renders no utility strip,
|
|
477
|
+
so no placeholder note is shown.
|
|
478
|
+
|
|
479
|
+
The generated footer **is** the `UniversalFooter` design block, rendered in its `commerce`
|
|
480
|
+
preset. Its own copy — newsletter, contact, payments, legal, region — comes from
|
|
481
|
+
`lib/<name>/footer-content.ts`, whose Zod schema is also the response contract of
|
|
482
|
+
`GET /store/footer`: a backend that owns the footer serves that shape and the shell drops
|
|
483
|
+
its defaults. Until then, override individual keys with `footerContent` in
|
|
484
|
+
`shell/content.ts`; the full contract and its wiring live in
|
|
485
|
+
`docs/footer-content-endpoint.md`. The scaffold ships no subscribe callback, so the
|
|
486
|
+
newsletter section is left out of the rendered preset (`toUniversalFooterProps` passes the
|
|
487
|
+
commerce sections minus `newsletter`) instead of shipping a disabled form; adding the
|
|
488
|
+
section back is binding `onSubscribe` plus one entry in that list. Region options default to
|
|
489
|
+
a Mercosur set (Español/English/Português, Uruguay…Paraguay, UYU/USD/ARS/BRL) and the
|
|
490
|
+
selectors are presentational: choosing a value emits an action the shell does not consume.
|
|
491
|
+
No app-store listing or QR image is invented (the app band hides itself while `apps.links`
|
|
492
|
+
is empty). Navigation stays derived from `linkColumns`, so the footer cannot drift from the
|
|
493
|
+
rest of the chrome.
|
|
481
494
|
|
|
482
495
|
A view's derived `index.tsx` imports the user-owned `content.ts`/`props.ts`/
|
|
483
496
|
`data.ts`, so a customization changes real spec/loader output and survives `sync`.
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
// Footer content: the data contract behind the site footer, plus the neutral
|
|
2
|
+
// defaults a fresh storefront ships with.
|
|
3
|
+
//
|
|
4
|
+
// `UniversalFooter` (the footer block) renders `data`, and the shell supplies it.
|
|
5
|
+
// The shape below is the whole contract, so a backend can serve it as-is:
|
|
6
|
+
//
|
|
7
|
+
// GET /store/footer
|
|
8
|
+
// 200 application/json → { ...footerContentSchema }
|
|
9
|
+
//
|
|
10
|
+
// Nothing here performs a request. The generated storefront reads the defaults
|
|
11
|
+
// in this file at build time; replacing them with a `GET /store/footer` read is
|
|
12
|
+
// a one-file change in `shell/props.ts` (see `footerContentEndpoint`), and does
|
|
13
|
+
// not touch the block, the registry, or the shell schema.
|
|
14
|
+
//
|
|
15
|
+
// Defaults are neutral on purpose: no delivery, shipping, or promo promise, no
|
|
16
|
+
// invented social account, no fake app store listing. Phone, address, payment
|
|
17
|
+
// methods and app links are placeholders a merchant must replace.
|
|
18
|
+
|
|
19
|
+
import { z } from 'zod'
|
|
20
|
+
import type { UniversalFooterProps } from '@thorprovider/blocks'
|
|
21
|
+
|
|
22
|
+
export const footerContentSchema = z.object({
|
|
23
|
+
/** Footer navigation, grouped. Derived from `shell/content.ts` link columns by default. */
|
|
24
|
+
nav: z.array(
|
|
25
|
+
z.object({
|
|
26
|
+
title: z.string(),
|
|
27
|
+
links: z.array(z.object({ label: z.string(), href: z.string() })),
|
|
28
|
+
}),
|
|
29
|
+
),
|
|
30
|
+
/** Accessible label for the navigation region. */
|
|
31
|
+
navLabel: z.string(),
|
|
32
|
+
newsletter: z.object({
|
|
33
|
+
title: z.string(),
|
|
34
|
+
description: z.string(),
|
|
35
|
+
fieldLabel: z.string(),
|
|
36
|
+
placeholder: z.string(),
|
|
37
|
+
buttonLabel: z.string(),
|
|
38
|
+
/** Feedback copy for a successful subscription. */
|
|
39
|
+
success: z.string(),
|
|
40
|
+
/** Feedback copy for a failed subscription. */
|
|
41
|
+
error: z.string(),
|
|
42
|
+
}),
|
|
43
|
+
contact: z.object({
|
|
44
|
+
title: z.string(),
|
|
45
|
+
email: z.string(),
|
|
46
|
+
phone: z.string(),
|
|
47
|
+
address: z.string(),
|
|
48
|
+
hours: z.string(),
|
|
49
|
+
}),
|
|
50
|
+
apps: z.object({
|
|
51
|
+
available: z.boolean(),
|
|
52
|
+
title: z.string(),
|
|
53
|
+
description: z.string(),
|
|
54
|
+
eyebrow: z.string(),
|
|
55
|
+
/** Short glyph shown beside the app invitation. */
|
|
56
|
+
mark: z.string(),
|
|
57
|
+
qr: z.object({ src: z.string(), alt: z.string(), fallback: z.string() }),
|
|
58
|
+
links: z.array(z.object({ label: z.string(), href: z.string(), caption: z.string() })),
|
|
59
|
+
}),
|
|
60
|
+
payments: z.object({ title: z.string(), methods: z.array(z.string()) }),
|
|
61
|
+
legal: z.object({
|
|
62
|
+
company: z.string(),
|
|
63
|
+
title: z.string(),
|
|
64
|
+
copyright: z.string(),
|
|
65
|
+
links: z.array(z.object({ label: z.string(), href: z.string() })),
|
|
66
|
+
}),
|
|
67
|
+
region: z.object({
|
|
68
|
+
label: z.string(),
|
|
69
|
+
languageLabel: z.string(),
|
|
70
|
+
countryLabel: z.string(),
|
|
71
|
+
currencyLabel: z.string(),
|
|
72
|
+
/** Human-readable summary of the active selection (e.g. `Español · Uruguay · UYU`). */
|
|
73
|
+
active: z.string(),
|
|
74
|
+
languages: z.array(z.object({ value: z.string(), label: z.string() })),
|
|
75
|
+
countries: z.array(z.object({ value: z.string(), label: z.string() })),
|
|
76
|
+
currencies: z.array(z.object({ value: z.string(), label: z.string() })),
|
|
77
|
+
}),
|
|
78
|
+
})
|
|
79
|
+
|
|
80
|
+
export type FooterContent = z.infer<typeof footerContentSchema>
|
|
81
|
+
|
|
82
|
+
/** The endpoint a backend implements to own the footer; the shape is the schema above. */
|
|
83
|
+
export const footerContentEndpoint = {
|
|
84
|
+
method: 'GET',
|
|
85
|
+
path: '/store/footer',
|
|
86
|
+
/** Every field is required; partial responses are rejected by the shell schema. */
|
|
87
|
+
response: 'FooterContent',
|
|
88
|
+
} as const
|
|
89
|
+
|
|
90
|
+
/**
|
|
91
|
+
* Default footer content: complete enough to render the commerce footer in a
|
|
92
|
+
* fresh storefront (apps band, newsletter, contact, payments, legal, region).
|
|
93
|
+
* Placeholder values are marked; a merchant replaces them.
|
|
94
|
+
*/
|
|
95
|
+
export const footerContentDefaults: FooterContent = {
|
|
96
|
+
// Navigation comes from the shell's link columns; a backend response carries its own.
|
|
97
|
+
nav: [],
|
|
98
|
+
navLabel: 'Navegación del sitio',
|
|
99
|
+
newsletter: {
|
|
100
|
+
title: 'Novedades del catálogo',
|
|
101
|
+
description: 'Productos nuevos y reposiciones, una vez al mes.',
|
|
102
|
+
fieldLabel: 'Correo electrónico',
|
|
103
|
+
placeholder: 'tu@email.com',
|
|
104
|
+
buttonLabel: 'Suscribirme',
|
|
105
|
+
success: 'Listo. Te escribimos cuando haya novedades.',
|
|
106
|
+
error: 'No pudimos suscribirte. Probá de nuevo.',
|
|
107
|
+
},
|
|
108
|
+
contact: {
|
|
109
|
+
title: 'Contacto',
|
|
110
|
+
email: 'hola@example.com',
|
|
111
|
+
phone: '+00 0000 0000',
|
|
112
|
+
address: 'Dirección a definir',
|
|
113
|
+
hours: 'Lunes a viernes, 10:00 a 18:00',
|
|
114
|
+
},
|
|
115
|
+
apps: {
|
|
116
|
+
available: true,
|
|
117
|
+
title: 'Tu catálogo, siempre a mano.',
|
|
118
|
+
description: 'Seguí tus pedidos y mirá las novedades desde el teléfono.',
|
|
119
|
+
eyebrow: 'EN TU TELÉFONO',
|
|
120
|
+
mark: 'S',
|
|
121
|
+
// No QR and no store listing is shipped: a QR image would be a binary asset
|
|
122
|
+
// the scaffold does not own, and invented store URLs would dead-end.
|
|
123
|
+
qr: { src: '', alt: 'Código QR de la aplicación', fallback: '' },
|
|
124
|
+
links: [],
|
|
125
|
+
},
|
|
126
|
+
payments: {
|
|
127
|
+
title: 'Medios de pago',
|
|
128
|
+
methods: ['Tarjeta de crédito', 'Tarjeta de débito', 'Transferencia'],
|
|
129
|
+
},
|
|
130
|
+
legal: {
|
|
131
|
+
company: 'Nombre de la empresa',
|
|
132
|
+
title: 'Legal',
|
|
133
|
+
copyright: 'Todos los derechos reservados.',
|
|
134
|
+
links: [
|
|
135
|
+
{ label: 'Términos', href: '/terms' },
|
|
136
|
+
{ label: 'Privacidad', href: '/privacy' },
|
|
137
|
+
],
|
|
138
|
+
},
|
|
139
|
+
region: {
|
|
140
|
+
label: 'Idioma y región',
|
|
141
|
+
languageLabel: 'Idioma',
|
|
142
|
+
countryLabel: 'País',
|
|
143
|
+
currencyLabel: 'Moneda',
|
|
144
|
+
active: 'Español · Uruguay · UYU',
|
|
145
|
+
// A backend that owns the footer serves the real lists (`GET /store/footer`);
|
|
146
|
+
// these are the markets a fresh scaffold advertises. The selectors are
|
|
147
|
+
// presentational: choosing a value emits an action the shell does not consume.
|
|
148
|
+
languages: [
|
|
149
|
+
{ value: 'es', label: 'Español' },
|
|
150
|
+
{ value: 'en', label: 'English' },
|
|
151
|
+
{ value: 'pt', label: 'Português' },
|
|
152
|
+
],
|
|
153
|
+
countries: [
|
|
154
|
+
{ value: 'uy', label: 'Uruguay' },
|
|
155
|
+
{ value: 'ar', label: 'Argentina' },
|
|
156
|
+
{ value: 'br', label: 'Brasil' },
|
|
157
|
+
{ value: 'cl', label: 'Chile' },
|
|
158
|
+
{ value: 'py', label: 'Paraguay' },
|
|
159
|
+
],
|
|
160
|
+
currencies: [
|
|
161
|
+
{ value: 'uyu', label: 'UYU' },
|
|
162
|
+
{ value: 'usd', label: 'USD' },
|
|
163
|
+
{ value: 'ars', label: 'ARS' },
|
|
164
|
+
{ value: 'brl', label: 'BRL' },
|
|
165
|
+
],
|
|
166
|
+
},
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* Footer navigation from the user-owned shell link columns, so the footer and the
|
|
171
|
+
* rest of the shell never carry two competing link lists. Entries without an
|
|
172
|
+
* `href` are labels, not links, and are dropped.
|
|
173
|
+
*/
|
|
174
|
+
export function navFromLinkColumns(
|
|
175
|
+
columns: { title: string; links: { label: string; href?: string }[] }[],
|
|
176
|
+
): FooterContent['nav'] {
|
|
177
|
+
return columns
|
|
178
|
+
.map((column) => ({
|
|
179
|
+
title: column.title,
|
|
180
|
+
links: column.links
|
|
181
|
+
.filter((link): link is { label: string; href: string } => typeof link.href === 'string')
|
|
182
|
+
.map(({ label, href }) => ({ label, href })),
|
|
183
|
+
}))
|
|
184
|
+
.filter((column) => column.links.length > 0)
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
/** The shell props `UniversalFooter` needs, mirroring `footerPropsSchema`. */
|
|
188
|
+
export interface FooterShellProps {
|
|
189
|
+
brandName: string
|
|
190
|
+
brandAccent?: { text: string; className?: string }
|
|
191
|
+
brandDescription?: string
|
|
192
|
+
linkColumns: { title: string; links: { label: string; href?: string }[] }[]
|
|
193
|
+
className?: string
|
|
194
|
+
footerContent?: FooterContent
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
/**
|
|
198
|
+
* The commerce preset's pieces minus `newsletter`.
|
|
199
|
+
*
|
|
200
|
+
* The block renders the newsletter form only when a host binds `onSubscribe`,
|
|
201
|
+
* and the scaffold ships no subscribe endpoint. A visible-but-disabled form
|
|
202
|
+
* reads as broken, so the section is left out until one exists: bind
|
|
203
|
+
* `onSubscribe` in the registry, add `'newsletter'` here, and the preset's form
|
|
204
|
+
* comes back with the copy from `footerContent.newsletter`.
|
|
205
|
+
*/
|
|
206
|
+
const commerceSections: NonNullable<UniversalFooterProps['sections']> = [
|
|
207
|
+
'brand',
|
|
208
|
+
'nav',
|
|
209
|
+
'contact',
|
|
210
|
+
'apps',
|
|
211
|
+
'payments',
|
|
212
|
+
'legal',
|
|
213
|
+
'region',
|
|
214
|
+
]
|
|
215
|
+
|
|
216
|
+
/**
|
|
217
|
+
* Map the shell seam onto the footer block. The commerce preset is fixed: this
|
|
218
|
+
* is the storefront shell footer, not a chooser. Link columns stay authoritative
|
|
219
|
+
* for navigation so the footer and the rest of the chrome cannot drift apart;
|
|
220
|
+
* `footerContent.nav` is the backend-owned fallback for a shell that ships none.
|
|
221
|
+
*/
|
|
222
|
+
export function toUniversalFooterProps(shell: FooterShellProps): UniversalFooterProps {
|
|
223
|
+
const content = shell.footerContent ?? footerContentDefaults
|
|
224
|
+
return {
|
|
225
|
+
data: {
|
|
226
|
+
niche: 'commerce',
|
|
227
|
+
navLabel: content.navLabel,
|
|
228
|
+
brand: { name: shell.brandName, description: shell.brandDescription ?? '' },
|
|
229
|
+
nav: shell.linkColumns.length ? navFromLinkColumns(shell.linkColumns) : content.nav,
|
|
230
|
+
newsletter: content.newsletter,
|
|
231
|
+
contact: content.contact,
|
|
232
|
+
apps: content.apps,
|
|
233
|
+
payments: content.payments,
|
|
234
|
+
legal: content.legal,
|
|
235
|
+
region: content.region,
|
|
236
|
+
},
|
|
237
|
+
sections: commerceSections,
|
|
238
|
+
brandAccent: shell.brandAccent,
|
|
239
|
+
className: shell.className,
|
|
240
|
+
}
|
|
241
|
+
}
|
|
@@ -16,7 +16,7 @@ import { BackToTop as BackToTopBlock } from '@thorprovider/blocks/blocks/e-comme
|
|
|
16
16
|
import { MobileBottomNav as MobileBottomNavBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
17
17
|
import { SkipToContent as SkipToContentBlock } from '@thorprovider/blocks/blocks/e-commerce/navigation/skip-to-content'
|
|
18
18
|
import Banner1 from '@thorprovider/blocks/blocks/marketing/banners/banner-1'
|
|
19
|
-
import {
|
|
19
|
+
import { Navbar, StorefrontNavbar, UniversalFooter } from '@thorprovider/blocks'
|
|
20
20
|
import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
|
|
21
21
|
import type { BackToTopProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/back-to-top'
|
|
22
22
|
import type { MobileBottomNavProps } from '@thorprovider/blocks/blocks/e-commerce/navigation/mobile-bottom-nav'
|
|
@@ -28,6 +28,7 @@ import type { CartLineState, CartTotalsState } from './state'
|
|
|
28
28
|
import { useStorefrontHandlers } from './handlers'
|
|
29
29
|
import { cartViewAvailable, checkoutAvailable, mountedFeatureNames } from './composition'
|
|
30
30
|
import { accountStoreUser } from './account-user.core'
|
|
31
|
+
import { toUniversalFooterProps } from './footer-content'
|
|
31
32
|
import type { AccountIdentity, AccountResolution } from './account-session.core'
|
|
32
33
|
import {
|
|
33
34
|
bannerPropsSchema,
|
|
@@ -306,29 +307,12 @@ const baseComponents = {
|
|
|
306
307
|
},
|
|
307
308
|
Footer: ({ props }: { props: Record<string, unknown> }) => {
|
|
308
309
|
const parsed = footerPropsSchema.parse(props)
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
linkColumns={parsed.linkColumns}
|
|
316
|
-
className={parsed.className}
|
|
317
|
-
linkBehavior="native"
|
|
318
|
-
// The scaffold ships no newsletter submit callback. The seam's
|
|
319
|
-
// `newsletter` is content only, so the block swallows it and renders no
|
|
320
|
-
// form. Wiring a real host callback (which would enable the form) is an
|
|
321
|
-
// external integration, out of scope for the scaffold.
|
|
322
|
-
newsletter={
|
|
323
|
-
parsed.newsletter
|
|
324
|
-
? {
|
|
325
|
-
placeholder: parsed.newsletter.placeholder,
|
|
326
|
-
buttonLabel: parsed.newsletter.buttonLabel ?? 'Suscribirme',
|
|
327
|
-
}
|
|
328
|
-
: undefined
|
|
329
|
-
}
|
|
330
|
-
/>
|
|
331
|
-
)
|
|
310
|
+
// The storefront shell footer is the design block itself. Brand name,
|
|
311
|
+
// description, accent, surface classes and the content contract all arrive
|
|
312
|
+
// through the shell seam, so the merchant surface stays `shell/content.ts`.
|
|
313
|
+
// No `onSubscribe` is bound: the scaffold ships no newsletter endpoint, and
|
|
314
|
+
// the block disables the form rather than faking a subscription.
|
|
315
|
+
return <UniversalFooter {...toUniversalFooterProps(parsed)} />
|
|
332
316
|
},
|
|
333
317
|
}
|
|
334
318
|
|
|
@@ -6,6 +6,8 @@
|
|
|
6
6
|
|
|
7
7
|
import { z } from 'zod'
|
|
8
8
|
|
|
9
|
+
import { footerContentSchema } from './footer-content'
|
|
10
|
+
|
|
9
11
|
export const ctaSchema = z.object({
|
|
10
12
|
label: z.string(),
|
|
11
13
|
href: z.string().optional(),
|
|
@@ -170,9 +172,9 @@ export const footerPropsSchema = z.object({
|
|
|
170
172
|
brandDescription: z.string().optional(),
|
|
171
173
|
linkColumns: z.array(footerLinkColumnSchema),
|
|
172
174
|
className: z.string().optional(),
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
175
|
+
// The footer's own content contract, shared with `GET /store/footer`. Optional
|
|
176
|
+
// so an older scaffold that predates it keeps rendering from the defaults.
|
|
177
|
+
footerContent: footerContentSchema.optional(),
|
|
176
178
|
})
|
|
177
179
|
|
|
178
180
|
// Navigability chrome contracts, mirrored from @thorprovider/blocks so the
|
|
@@ -10,10 +10,11 @@
|
|
|
10
10
|
// `/about`, `/terms`, `/privacy`). Brand colors and copy belong
|
|
11
11
|
// in your own content, never in the package.
|
|
12
12
|
//
|
|
13
|
-
// The
|
|
14
|
-
//
|
|
15
|
-
//
|
|
16
|
-
|
|
13
|
+
// The footer's own copy (newsletter, contact, payments, legal, region) lives in
|
|
14
|
+
// the footer content contract, not here: `GET /store/footer` is what a backend
|
|
15
|
+
// implements, and `../footer-content.ts` documents its shape and defaults.
|
|
16
|
+
|
|
17
|
+
import type { FooterContent } from '../footer-content'
|
|
17
18
|
|
|
18
19
|
export interface ShellAccent {
|
|
19
20
|
/** Trailing segment of the site-name wordmark to render with the accent. */
|
|
@@ -33,11 +34,6 @@ export interface ShellLinkColumn {
|
|
|
33
34
|
links: ShellLink[]
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
export interface ShellNewsletter {
|
|
37
|
-
placeholder?: string
|
|
38
|
-
buttonLabel: string
|
|
39
|
-
}
|
|
40
|
-
|
|
41
37
|
/**
|
|
42
38
|
* Optional trailing accent for the navbar wordmark, e.g. the "Cuba" in
|
|
43
39
|
* "ElectroCuba". Leave `undefined` to render the wordmark in one colour. The
|
|
@@ -97,11 +93,16 @@ export const linkColumns: ShellLinkColumn[] = [
|
|
|
97
93
|
]
|
|
98
94
|
|
|
99
95
|
/**
|
|
100
|
-
* Footer
|
|
101
|
-
*
|
|
102
|
-
*
|
|
96
|
+
* Footer copy overrides, merged over the package defaults in
|
|
97
|
+
* `../footer-content.ts` (newsletter, contact, apps, payments, legal, region).
|
|
98
|
+
* Same shape as the `GET /store/footer` response, so a backend that owns the
|
|
99
|
+
* footer replaces this seam instead of filling it in. Leave a key out to keep
|
|
100
|
+
* the default; set `undefined` for no overrides.
|
|
101
|
+
*
|
|
102
|
+
* Placeholders shipped by default (contact phone/address, company name, payment
|
|
103
|
+
* methods) are not customer-ready — a merchant must replace them.
|
|
103
104
|
*/
|
|
104
|
-
export const
|
|
105
|
+
export const footerContent: Partial<FooterContent> | undefined = undefined
|
|
105
106
|
|
|
106
107
|
// Primary destinations for the mobile bottom navigation. Only routes the
|
|
107
108
|
// storefront actually serves; the icons come from the shared category icon set.
|
|
@@ -8,12 +8,13 @@ import {
|
|
|
8
8
|
brandAccent,
|
|
9
9
|
brandDescription,
|
|
10
10
|
footerClassName,
|
|
11
|
+
footerContent,
|
|
11
12
|
linkColumns,
|
|
12
13
|
logoAccent,
|
|
13
14
|
navbarClassName,
|
|
14
|
-
newsletter,
|
|
15
15
|
shippingNote,
|
|
16
16
|
} from './content'
|
|
17
|
+
import { footerContentDefaults } from '../footer-content'
|
|
17
18
|
|
|
18
19
|
export const navbarShellProps = {
|
|
19
20
|
logoAccent,
|
|
@@ -34,5 +35,9 @@ export const footerShellProps = {
|
|
|
34
35
|
brandDescription,
|
|
35
36
|
linkColumns,
|
|
36
37
|
className: footerClassName,
|
|
37
|
-
|
|
38
|
+
// The footer's own content contract. Neutral defaults ship with the scaffold;
|
|
39
|
+
// a backend that owns the footer replaces this with a `GET /store/footer`
|
|
40
|
+
// read (shape: `footerContentSchema` in ../footer-content.ts). Merchant
|
|
41
|
+
// overrides in `content.ts` win over the package defaults.
|
|
42
|
+
footerContent: { ...footerContentDefaults, ...footerContent },
|
|
38
43
|
}
|
|
@@ -13,8 +13,9 @@ import { marketplaceProductCardSection } from './marketplace-product-card'
|
|
|
13
13
|
import { megaMenuUniversalSection } from './mega-menu-universal'
|
|
14
14
|
import { productsSection } from './products'
|
|
15
15
|
import { universalBannerSection } from './universal-banner'
|
|
16
|
+
import { universalMainMenuSection } from './universal-main-menu'
|
|
16
17
|
|
|
17
|
-
export const sectionModules = [checkoutCommerceV1Section, faqSection, ctaSection, marketplaceProductCardSection, megaMenuUniversalSection, productsSection, universalBannerSection] as const
|
|
18
|
+
export const sectionModules = [checkoutCommerceV1Section, faqSection, ctaSection, marketplaceProductCardSection, megaMenuUniversalSection, productsSection, universalBannerSection, universalMainMenuSection] as const
|
|
18
19
|
|
|
19
20
|
export const sectionCatalog: Record<string, ViewCatalogEntry> = Object.assign(
|
|
20
21
|
{},
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
// `variant`. The selection and resolved products arrive through the view state;
|
|
8
8
|
// this boundary only validates them and wires navigation/purchase callbacks.
|
|
9
9
|
|
|
10
|
+
import { UniversalProductSlider, type UniversalProductSliderProps } from '@thorprovider/blocks'
|
|
10
11
|
import { ProductGrid as ProductGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-list/product-grid'
|
|
11
12
|
import ProductShowcase1Block from '@thorprovider/blocks/blocks/e-commerce/product-list/product-showcase-1'
|
|
12
13
|
import type { ProductPresentation } from '@thorprovider/blocks/contracts'
|
|
@@ -15,6 +16,27 @@ import { useSectionObservation } from '../../section-observation'
|
|
|
15
16
|
import { productsPropsSchema, type ProductsStatus } from './schema.products'
|
|
16
17
|
import type { ViewRegistry } from '../types'
|
|
17
18
|
|
|
19
|
+
// The merchandising rail reads the same resolved selection as the grid, so the
|
|
20
|
+
// only translation is the presentation shape. Host-owned state (navigation and
|
|
21
|
+
// purchase callbacks) is mapped back to the source product by id, which keeps
|
|
22
|
+
// `lastClicked` and the cart actions identical across variants.
|
|
23
|
+
type SliderProductProp = UniversalProductSliderProps['products'][number]
|
|
24
|
+
|
|
25
|
+
function toSliderProduct(product: ProductPresentation): SliderProductProp {
|
|
26
|
+
return {
|
|
27
|
+
id: product.id,
|
|
28
|
+
name: product.title,
|
|
29
|
+
...(product.image ? { image: product.image } : {}),
|
|
30
|
+
...(product.imageAlt ? { imageAlt: product.imageAlt } : {}),
|
|
31
|
+
...(product.href ? { href: product.href } : {}),
|
|
32
|
+
price: product.price,
|
|
33
|
+
...(product.compareAtPrice ? { compareAtPrice: product.compareAtPrice } : {}),
|
|
34
|
+
...(product.rating === undefined ? {} : { rating: product.rating }),
|
|
35
|
+
...(product.badge ? { badge: product.badge } : {}),
|
|
36
|
+
...(product.inStock === false ? { availability: 'out-of-stock' as const } : {}),
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
18
40
|
// Truthful, actionable messages for the non-`ready` states. A failed or
|
|
19
41
|
// unconfigured section never fabricates products.
|
|
20
42
|
function sectionStatusMessage(status: ProductsStatus): string {
|
|
@@ -82,9 +104,38 @@ export const productsRegistry: ViewRegistry = {
|
|
|
82
104
|
onProductClick: openProduct,
|
|
83
105
|
}
|
|
84
106
|
|
|
107
|
+
// The rail's callbacks are typed with its own product shape; map back to the
|
|
108
|
+
// resolved presentation so both variants share one host action path.
|
|
109
|
+
const byId = new Map(parsed.products.map((product) => [String(product.id), product]))
|
|
110
|
+
|
|
85
111
|
return (
|
|
86
112
|
<div ref={containerRef}>
|
|
87
|
-
{parsed.variant === '
|
|
113
|
+
{parsed.variant === 'ProductSlider' ? (
|
|
114
|
+
<UniversalProductSlider
|
|
115
|
+
header={{
|
|
116
|
+
title: parsed.heading ?? 'Productos',
|
|
117
|
+
...(parsed.description ? { description: parsed.description } : {}),
|
|
118
|
+
...(parsed.ctaLabel
|
|
119
|
+
? {
|
|
120
|
+
action: {
|
|
121
|
+
label: parsed.ctaLabel,
|
|
122
|
+
...(parsed.ctaHref ? { href: parsed.ctaHref } : {}),
|
|
123
|
+
variant: 'link' as const,
|
|
124
|
+
},
|
|
125
|
+
}
|
|
126
|
+
: {}),
|
|
127
|
+
}}
|
|
128
|
+
products={parsed.products.map(toSliderProduct)}
|
|
129
|
+
onAddToCart={(product) => {
|
|
130
|
+
const source = byId.get(String(product.id))
|
|
131
|
+
if (source) addToCart(source)
|
|
132
|
+
}}
|
|
133
|
+
onProductClick={(product) => {
|
|
134
|
+
const source = byId.get(String(product.id))
|
|
135
|
+
if (source) openProduct(source)
|
|
136
|
+
}}
|
|
137
|
+
/>
|
|
138
|
+
) : parsed.variant === 'ProductShowcase1' ? (
|
|
88
139
|
<ProductShowcase1Block
|
|
89
140
|
{...shared}
|
|
90
141
|
heading={parsed.heading}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
// Optional section fragment: universal-main-menu (mirrors recipes/sections.json) — shared contract.
|
|
2
|
+
// Zod mirror of the UniversalMainMenu block contract (delivery universal-main-menu, contract version 4.3.2),
|
|
3
|
+
// shared by the server catalog (universal-main-menu.tsx) and the client registry (universal-main-menu.client.tsx).
|
|
4
|
+
// The React-only callbacks (onNavigate, onOpenChange) are intentionally excluded.
|
|
5
|
+
|
|
6
|
+
import { z } from 'zod'
|
|
7
|
+
|
|
8
|
+
export type universalMainMenuItem = {
|
|
9
|
+
id: string
|
|
10
|
+
label: string
|
|
11
|
+
href?: string
|
|
12
|
+
description?: string
|
|
13
|
+
image?: {
|
|
14
|
+
src: string
|
|
15
|
+
alt: string
|
|
16
|
+
}
|
|
17
|
+
badge?: {
|
|
18
|
+
label: string
|
|
19
|
+
tone: "accent" | "neutral" | "promo"
|
|
20
|
+
}
|
|
21
|
+
count?: number
|
|
22
|
+
children?: universalMainMenuItem[]
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export const universalMainMenuItemSchema: z.ZodType<universalMainMenuItem> = z.object({
|
|
26
|
+
id: z.string(),
|
|
27
|
+
label: z.string(),
|
|
28
|
+
href: z.string().optional(),
|
|
29
|
+
description: z.string().optional(),
|
|
30
|
+
image: z.object({
|
|
31
|
+
src: z.string(),
|
|
32
|
+
alt: z.string(),
|
|
33
|
+
}).optional(),
|
|
34
|
+
badge: z.object({
|
|
35
|
+
label: z.string(),
|
|
36
|
+
tone: z.enum(["accent", "neutral", "promo"]),
|
|
37
|
+
}).optional(),
|
|
38
|
+
count: z.number().optional(),
|
|
39
|
+
children: z.array(z.lazy(() => universalMainMenuItemSchema)).optional(),
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
export const universalMainMenuDataSchema = z.object({
|
|
43
|
+
categories: z.array(universalMainMenuItemSchema),
|
|
44
|
+
config: z.object({
|
|
45
|
+
layouts: z.object({
|
|
46
|
+
default: z.string(),
|
|
47
|
+
desktop: z.string(),
|
|
48
|
+
mobile: z.string(),
|
|
49
|
+
bindings: z.record(z.string(), z.object({
|
|
50
|
+
desktop: z.string().optional(),
|
|
51
|
+
mobile: z.string().optional(),
|
|
52
|
+
options: z.object({
|
|
53
|
+
columns: z.number().optional(),
|
|
54
|
+
panelWidth: z.string().optional(),
|
|
55
|
+
panelHeight: z.string().optional(),
|
|
56
|
+
imageRatio: z.string().optional(),
|
|
57
|
+
showImages: z.boolean().optional(),
|
|
58
|
+
showDescriptions: z.boolean().optional(),
|
|
59
|
+
showCounts: z.boolean().optional(),
|
|
60
|
+
showBadges: z.boolean().optional(),
|
|
61
|
+
showViewAll: z.boolean().optional(),
|
|
62
|
+
railWidth: z.string().optional(),
|
|
63
|
+
featuredId: z.string().optional(),
|
|
64
|
+
}).optional(),
|
|
65
|
+
})),
|
|
66
|
+
options: z.record(z.string(), z.object({
|
|
67
|
+
columns: z.number().optional(),
|
|
68
|
+
panelWidth: z.string().optional(),
|
|
69
|
+
panelHeight: z.string().optional(),
|
|
70
|
+
imageRatio: z.string().optional(),
|
|
71
|
+
showImages: z.boolean().optional(),
|
|
72
|
+
showDescriptions: z.boolean().optional(),
|
|
73
|
+
showCounts: z.boolean().optional(),
|
|
74
|
+
showBadges: z.boolean().optional(),
|
|
75
|
+
showViewAll: z.boolean().optional(),
|
|
76
|
+
railWidth: z.string().optional(),
|
|
77
|
+
featuredId: z.string().optional(),
|
|
78
|
+
})),
|
|
79
|
+
}),
|
|
80
|
+
behavior: z.object({
|
|
81
|
+
platform: z.string().optional(),
|
|
82
|
+
mobilePattern: z.string().optional(),
|
|
83
|
+
openOnHover: z.boolean().optional(),
|
|
84
|
+
openDelayMs: z.number().optional(),
|
|
85
|
+
closeDelayMs: z.number().optional(),
|
|
86
|
+
direction: z.string().optional(),
|
|
87
|
+
}),
|
|
88
|
+
transition: z.object({
|
|
89
|
+
panel: z.string().optional(),
|
|
90
|
+
level: z.string().optional(),
|
|
91
|
+
duration: z.string().optional(),
|
|
92
|
+
respectReducedMotion: z.boolean().optional(),
|
|
93
|
+
}),
|
|
94
|
+
}),
|
|
95
|
+
labels: z.object({
|
|
96
|
+
menuTrigger: z.string(),
|
|
97
|
+
menuTitle: z.string(),
|
|
98
|
+
close: z.string(),
|
|
99
|
+
back: z.string(),
|
|
100
|
+
openSubmenu: z.string(),
|
|
101
|
+
viewAll: z.string(),
|
|
102
|
+
productCount: z.string(),
|
|
103
|
+
productCountOne: z.string(),
|
|
104
|
+
featured: z.string(),
|
|
105
|
+
empty: z.string(),
|
|
106
|
+
emptyHint: z.string(),
|
|
107
|
+
panelLabel: z.string(),
|
|
108
|
+
railLabel: z.string(),
|
|
109
|
+
levelLabel: z.string(),
|
|
110
|
+
noImage: z.string(),
|
|
111
|
+
browseLabel: z.string().optional(),
|
|
112
|
+
keyboardHint: z.string().optional(),
|
|
113
|
+
escapeLabel: z.string().optional(),
|
|
114
|
+
}),
|
|
115
|
+
promotion: z.object({
|
|
116
|
+
id: z.string(),
|
|
117
|
+
eyebrow: z.string(),
|
|
118
|
+
title: z.string(),
|
|
119
|
+
description: z.string().optional(),
|
|
120
|
+
href: z.string(),
|
|
121
|
+
ctaLabel: z.string(),
|
|
122
|
+
image: z.object({
|
|
123
|
+
src: z.string(),
|
|
124
|
+
alt: z.string(),
|
|
125
|
+
}).optional(),
|
|
126
|
+
categoryIds: z.array(z.string()).optional(),
|
|
127
|
+
}).optional(),
|
|
128
|
+
preview: z.object({
|
|
129
|
+
defaultOpen: z.boolean().optional(),
|
|
130
|
+
openNodeId: z.string().optional(),
|
|
131
|
+
}).optional(),
|
|
132
|
+
})
|
|
133
|
+
|
|
134
|
+
export const universalMainMenuPropsSchema = z.object({
|
|
135
|
+
data: universalMainMenuDataSchema,
|
|
136
|
+
})
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
// Optional section fragment: universal-main-menu (mirrors recipes/sections.json) — client registry.
|
|
4
|
+
// The matching server-side catalog lives in universal-main-menu.tsx. @thorprovider/blocks ships a
|
|
5
|
+
// 'use client' boundary, but this fragment keeps the explicit client boundary so
|
|
6
|
+
// the section composes identically in any consumer graph.
|
|
7
|
+
|
|
8
|
+
import { UniversalMainMenu } from '@thorprovider/blocks'
|
|
9
|
+
import { universalMainMenuPropsSchema } from './schema.universal-main-menu'
|
|
10
|
+
import type { ViewRegistry } from '../types'
|
|
11
|
+
|
|
12
|
+
export const universalMainMenuRegistry: ViewRegistry = {
|
|
13
|
+
UniversalMainMenu: ({ props }) => {
|
|
14
|
+
const parsed = universalMainMenuPropsSchema.parse(props)
|
|
15
|
+
return (
|
|
16
|
+
<UniversalMainMenu data={parsed.data} />
|
|
17
|
+
)
|
|
18
|
+
},
|
|
19
|
+
}
|