@thorprovider/storefront 0.4.0-mvp.0 → 0.4.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 +174 -156
- package/VENDOR.md +69 -0
- package/assets/openspec/config.yaml +38 -0
- package/assets/templates/AGENTS.md +76 -0
- package/assets/templates/app/app/[[...slug]]/page.tsx +56 -2
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +44 -2
- package/assets/templates/app/app/globals.css +5 -8
- package/assets/templates/app/app/layout.tsx +1 -5
- package/assets/templates/app/app/robots.ts +9 -3
- package/assets/templates/app/app/sitemap.ts +64 -5
- package/assets/templates/app/lib/__STOREFRONT__/account-boundary.client.tsx +76 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-lifecycle.client.tsx +461 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-mutation.client.ts +46 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-private.core.ts +103 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-reconcile.client.ts +465 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-session.core.ts +177 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-session.ts +44 -0
- package/assets/templates/app/lib/__STOREFRONT__/account-user.core.ts +65 -0
- package/assets/templates/app/lib/__STOREFRONT__/actions.ts +135 -16
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +19 -9
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +61 -0
- package/assets/templates/app/lib/__STOREFRONT__/composition.ts +26 -0
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +36 -4
- package/assets/templates/app/lib/__STOREFRONT__/mappers.ts +17 -18
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.client.tsx +209 -0
- package/assets/templates/app/lib/__STOREFRONT__/projection-ownership.ts +247 -0
- package/assets/templates/app/lib/__STOREFRONT__/registry.tsx +123 -62
- package/assets/templates/app/lib/__STOREFRONT__/runtime.ts +3 -0
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +78 -25
- package/assets/templates/app/lib/__STOREFRONT__/section-observation.ts +182 -0
- package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +128 -0
- package/assets/templates/app/lib/__STOREFRONT__/shell/content.ts +31 -7
- package/assets/templates/app/lib/__STOREFRONT__/shell/props.ts +4 -0
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +81 -26
- package/assets/templates/app/lib/__STOREFRONT__/spec/seo.ts +165 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +4 -2
- package/assets/templates/app/lib/__STOREFRONT__/store-context.ts +26 -7
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/cta.client.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/faq.client.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/index.ts +2 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/logoCloud.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/pricing.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.client.tsx +100 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/products.tsx +19 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +39 -0
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/statistics.tsx +1 -1
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/testimonials.tsx +1 -1
- package/assets/templates/features/checkout/handlers.ts +6 -0
- package/assets/templates/features/customer-auth/handlers.ts +19 -23
- package/assets/templates/features/customer-auth/state.ts +31 -1
- package/assets/templates/views/account/index.tsx +20 -8
- package/assets/templates/views/account/registry.tsx +294 -154
- package/assets/templates/views/account/schema.ts +1 -0
- package/assets/templates/views/cart/content.ts +11 -0
- package/assets/templates/views/cart/data.ts +23 -0
- package/assets/templates/views/cart/index.tsx +53 -0
- package/assets/templates/views/cart/props.ts +12 -0
- package/assets/templates/views/cart/registry.tsx +82 -0
- package/assets/templates/views/cart/schema.ts +52 -0
- package/assets/templates/views/category/assembly/assembly.json +2 -1
- package/assets/templates/views/category/assembly/index.skeleton.tsx +64 -6
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +7 -6
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +5 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/catalog.part +4 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/element.part +7 -0
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/registry.part +18 -0
- package/assets/templates/views/category/index.tsx +76 -7
- package/assets/templates/views/category/props.ts +7 -0
- package/assets/templates/views/category/registry.tsx +25 -6
- package/assets/templates/views/category/schema.ts +13 -0
- package/assets/templates/views/checkout/registry.tsx +3 -5
- package/assets/templates/views/home/assembly/assembly.json +12 -3
- package/assets/templates/views/home/assembly/index.skeleton.tsx +24 -5
- package/assets/templates/views/home/assembly/registry.skeleton.tsx +4 -1
- package/assets/templates/views/home/assembly/slots/benefits/cards/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/cards/registry.part +17 -0
- package/assets/templates/views/home/assembly/slots/benefits/split/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → split}/registry.part +6 -2
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/catalog.part +8 -0
- package/assets/templates/views/home/assembly/slots/categories/{ProductCategory2 → CategoryGrid}/element.part +1 -1
- package/assets/templates/views/home/assembly/slots/categories/CategoryGrid/registry.part +31 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/catalog.part +4 -0
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero/element.part +5 -0
- package/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/registry.part +5 -3
- package/assets/templates/views/home/content.ts +22 -0
- package/assets/templates/views/home/data.ts +9 -0
- package/assets/templates/views/home/index.tsx +34 -11
- package/assets/templates/views/home/props.ts +1 -0
- package/assets/templates/views/home/registry.tsx +41 -17
- package/assets/templates/views/home/schema.ts +141 -24
- package/assets/templates/views/product/data.ts +5 -3
- package/assets/templates/views/product/index.tsx +49 -5
- package/assets/templates/views/product/props.ts +7 -0
- package/assets/templates/views/product/registry.tsx +34 -5
- package/assets/templates/views/product/schema.ts +49 -1
- package/assets/templates/views/static/content.ts +4 -4
- package/assets/templates/views/static/index.tsx +1 -1
- package/bin/storefront.js +1231 -154
- package/examples/merchandising/category-led.json +37 -0
- package/examples/merchandising/collection-led.json +37 -0
- package/package.json +10 -7
- package/recipes/archetypes.json +33 -46
- package/recipes/catalog.json +245 -153
- package/recipes/catalog.mjs +10 -0
- package/recipes/catalog.schema.json +4 -0
- package/recipes/features.json +28 -5
- package/recipes/recipe.schema.json +1 -1
- package/recipes/recipes.json +159 -59
- package/recipes/sections.json +10 -0
- package/recipes/validate.mjs +75 -4
- package/scripts/candidate.mjs +4 -4
- package/scripts/composers.mjs +25 -5
- package/scripts/env-file.mjs +86 -0
- package/scripts/file-classes.mjs +15 -0
- package/scripts/migrate-english-routes.mjs +276 -0
- package/scripts/ownership-conflict.mjs +5 -2
- package/scripts/pinning.mjs +74 -5
- package/scripts/plan-apply.mjs +149 -5
- package/scripts/reconcile.mjs +49 -11
- package/scripts/render-templates.mjs +97 -44
- package/scripts/section-config.mjs +253 -0
- package/scripts/starter.mjs +17 -0
- package/scripts/theme/color.mjs +185 -0
- package/scripts/theme/css-theme.mjs +233 -0
- package/scripts/theme/fonts.mjs +123 -0
- package/scripts/theme/import-export.mjs +125 -0
- package/scripts/theme/preset.mjs +93 -0
- package/scripts/theme/theme-plan.mjs +292 -0
- package/scripts/theme/tokens.mjs +137 -0
- package/scripts/view-assembly.mjs +57 -3
- package/scripts/view-selection.mjs +1 -1
- package/skills/sf-feature/SKILL.md +32 -19
- package/skills/sf-setup/SKILL.md +79 -0
- package/skills/sf-theme-gen/SKILL.md +99 -36
- package/skills/sf-theme-gen/references/shadcn-theming.md +87 -0
- package/skills/{shadcn-theming/references/templates → sf-theme-gen/references}/theme-setup.md +15 -19
- package/skills/{shadcn-theming → sf-theme-gen}/references/theming-guide.md +6 -11
- package/skills/sf-view-gen/SKILL.md +63 -40
- package/skills/sf-view-gen/assets/recipes/archetypes.json +33 -46
- package/skills/sf-view-gen/assets/recipes/catalog.json +245 -153
- package/skills/sf-view-gen/assets/recipes/catalog.schema.json +4 -0
- package/skills/sf-view-gen/assets/recipes/features.json +28 -5
- package/skills/sf-view-gen/assets/recipes/recipes.json +159 -59
- package/skills/sf-view-gen/assets/recipes/sections.json +10 -0
- package/skills/sf-view-gen/assets/templates/views/sections/cta.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/faq.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/logoCloud.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/pricing.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/products.client.tsx +100 -0
- package/skills/sf-view-gen/assets/templates/views/sections/products.tsx +19 -0
- package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +39 -0
- package/skills/sf-view-gen/assets/templates/views/sections/statistics.client.tsx +1 -1
- package/skills/sf-view-gen/assets/templates/views/sections/testimonials.client.tsx +1 -1
- package/skills/{json-render-core/SKILL.md → sf-view-gen/references/json-render-core.md} +4 -27
- package/skills/{json-render-next/SKILL.md → sf-view-gen/references/json-render-next.md} +5 -8
- package/skills/{json-render-react/SKILL.md → sf-view-gen/references/json-render-react.md} +3 -5
- package/skills/{json-render-shadcn/SKILL.md → sf-view-gen/references/json-render-shadcn.md} +3 -5
- package/skills/sf-view-gen/references/views.md +28 -37
- package/skills/sf-view-gen/scripts/catalog.mjs +10 -0
- package/skills/sf-view-gen/scripts/validate.mjs +75 -4
- package/skills/storefront-workflow/SKILL.md +94 -31
- package/skills/{storefront-best-practices/reference/design.md → storefront-workflow/references/design-consistency.md} +13 -29
- package/CHANGELOG.md +0 -84
- package/assets/templates/views/home/assembly/slots/benefits/Feature1/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/benefits/Feature2/registry.part +0 -10
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/catalog.part +0 -4
- package/assets/templates/views/home/assembly/slots/categories/ProductCategory2/registry.part +0 -16
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/binding.json +0 -5
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/catalog.part +0 -4
- package/assets/templates/views/home/assembly/slots/hero/StorefrontHero1/element.part +0 -5
- package/assets/templates/views/user-panel/index.tsx +0 -106
- package/assets/templates/views/user-panel/registry.tsx +0 -54
- package/assets/templates/views/user-panel/schema.ts +0 -79
- package/commands/sf-add-view.md +0 -57
- package/commands/sf-feature.md +0 -28
- package/commands/sf-theme.md +0 -26
- package/commands/sf-view.md +0 -67
- package/skills/building-storefronts/SKILL.md +0 -178
- package/skills/building-storefronts/references/frontend-integration.md +0 -229
- package/skills/json-render-remotion/SKILL.md +0 -111
- package/skills/json-render-solid/SKILL.md +0 -204
- package/skills/nextjs-shadcn/SKILL.md +0 -367
- package/skills/nextjs-shadcn/references/architecture.md +0 -499
- package/skills/nextjs-shadcn/references/project-setup.md +0 -162
- package/skills/nextjs-shadcn/references/shadcn-platform.md +0 -261
- package/skills/nextjs-shadcn/references/sidebar.md +0 -274
- package/skills/nextjs-shadcn/references/styling.md +0 -555
- package/skills/shadcn-component-discovery/SKILL.md +0 -273
- package/skills/shadcn-component-discovery/references/registries.md +0 -226
- package/skills/shadcn-theming/SKILL.md +0 -104
- package/skills/storefront-best-practices/SKILL.md +0 -421
- package/skills/storefront-best-practices/reference/components/breadcrumbs.md +0 -123
- package/skills/storefront-best-practices/reference/components/cart-popup.md +0 -189
- package/skills/storefront-best-practices/reference/components/country-selector.md +0 -298
- package/skills/storefront-best-practices/reference/components/footer.md +0 -112
- package/skills/storefront-best-practices/reference/components/hero.md +0 -241
- package/skills/storefront-best-practices/reference/components/megamenu.md +0 -239
- package/skills/storefront-best-practices/reference/components/navbar.md +0 -397
- package/skills/storefront-best-practices/reference/components/popups.md +0 -221
- package/skills/storefront-best-practices/reference/components/product-card.md +0 -125
- package/skills/storefront-best-practices/reference/components/product-reviews.md +0 -217
- package/skills/storefront-best-practices/reference/components/product-slider.md +0 -174
- package/skills/storefront-best-practices/reference/components/search.md +0 -101
- package/skills/storefront-best-practices/reference/connecting-to-backend.md +0 -391
- package/skills/storefront-best-practices/reference/features/promotions.md +0 -307
- package/skills/storefront-best-practices/reference/features/wishlist.md +0 -230
- package/skills/storefront-best-practices/reference/layouts/account.md +0 -380
- package/skills/storefront-best-practices/reference/layouts/cart.md +0 -316
- package/skills/storefront-best-practices/reference/layouts/checkout.md +0 -486
- package/skills/storefront-best-practices/reference/layouts/home-page.md +0 -264
- package/skills/storefront-best-practices/reference/layouts/order-confirmation.md +0 -231
- package/skills/storefront-best-practices/reference/layouts/product-details.md +0 -527
- package/skills/storefront-best-practices/reference/layouts/product-listing.md +0 -520
- package/skills/storefront-best-practices/reference/layouts/static-pages.md +0 -356
- package/skills/storefront-best-practices/reference/medusa.md +0 -307
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/catalog.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/element.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/catalog.part +0 -0
- /package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/element.part +0 -0
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/mobile-responsiveness.md +0 -0
- /package/skills/{storefront-best-practices/reference → storefront-workflow/references}/seo.md +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
{
|
|
2
2
|
"view": "home",
|
|
3
3
|
"slots": [
|
|
4
|
-
{ "id": "home.hero", "slot": "hero", "default": "
|
|
5
|
-
{ "id": "home.benefits", "slot": "benefits", "default": "
|
|
6
|
-
{ "id": "home.categories", "slot": "categories", "default": "
|
|
4
|
+
{ "id": "home.hero", "slot": "hero", "default": "StorefrontHero" },
|
|
5
|
+
{ "id": "home.benefits", "slot": "benefits", "default": "cards" },
|
|
6
|
+
{ "id": "home.categories", "slot": "categories", "default": "CategoryGrid" }
|
|
7
7
|
],
|
|
8
8
|
"sections": {
|
|
9
9
|
"faq": {
|
|
@@ -19,6 +19,15 @@
|
|
|
19
19
|
"registryExport": "ctaRegistry",
|
|
20
20
|
"propsModule": "./content",
|
|
21
21
|
"defaultProps": "{}"
|
|
22
|
+
},
|
|
23
|
+
"products": {
|
|
24
|
+
"elementType": "Products",
|
|
25
|
+
"registryModule": "../sections/products.client",
|
|
26
|
+
"registryExport": "productsRegistry",
|
|
27
|
+
"propsModule": "./content",
|
|
28
|
+
"defaultProps": "{}",
|
|
29
|
+
"dataBound": true,
|
|
30
|
+
"defaultVariant": "ProductGrid"
|
|
22
31
|
}
|
|
23
32
|
}
|
|
24
33
|
}
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
// on the server. Registered by importing it in ../index.ts. Recipe: recipes.json -> "home".
|
|
6
6
|
|
|
7
7
|
import { getCatalog } from '@thorprovider/runtime/commerce'
|
|
8
|
-
import { getDataSource } from '../../store-context'
|
|
8
|
+
import { getDataSource, getStoreContext } from '../../store-context'
|
|
9
9
|
import { pageRoot } from '../../spec/page-root'
|
|
10
10
|
import type { StorefrontElement } from '../../spec/types'
|
|
11
11
|
import type { ViewModule } from '../types'
|
|
12
12
|
import { registry } from './registry'
|
|
13
13
|
import { benefitsProps, categoriesProps, heroProps } from './props'
|
|
14
|
-
import
|
|
14
|
+
import * as homeData from './data'
|
|
15
15
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
16
|
+
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
16
17
|
import {
|
|
17
|
-
|
|
18
|
+
categoryCardPropsSchema,
|
|
19
|
+
categoryGridPropsSchema,
|
|
18
20
|
featurePropsSchema,
|
|
19
21
|
storefrontHeroPropsSchema,
|
|
20
22
|
} from './schema'@@SECTION_IMPORTS@@
|
|
@@ -46,14 +48,30 @@ export const home: ViewModule = {
|
|
|
46
48
|
},
|
|
47
49
|
loader: {
|
|
48
50
|
home: async () => {
|
|
51
|
+
// Data-bound sections resolve independently through the canonical catalog
|
|
52
|
+
// bridge; equal queries share request-local work and differing contexts
|
|
53
|
+
// stay isolated. A section failure never erases its siblings, and it is
|
|
54
|
+
// resolved separately so a catalog failure still yields truthful
|
|
55
|
+
// per-section state instead of a missing one.
|
|
56
|
+
let sections: Record<string, unknown> = {}
|
|
57
|
+
try {
|
|
58
|
+
sections = await resolveSectionViewStates(
|
|
59
|
+
@@SECTION_LOADERS@@,
|
|
60
|
+
resolveSectionSources(homeData),
|
|
61
|
+
getStoreContext(),
|
|
62
|
+
)
|
|
63
|
+
} catch {
|
|
64
|
+
sections = {}
|
|
65
|
+
}
|
|
49
66
|
try {
|
|
50
67
|
const { products, categories, source } = await getCatalog()
|
|
51
68
|
return {
|
|
52
|
-
heroProducts: selectHeroProducts(products).map(toFeaturedProduct),
|
|
69
|
+
heroProducts: homeData.selectHeroProducts(products).map(toFeaturedProduct),
|
|
53
70
|
categories: categories.map(toCategoryCard),
|
|
54
|
-
navCategories: toNavCategories(categories),
|
|
71
|
+
navCategories: homeData.toNavCategories(categories),
|
|
55
72
|
dataSource: source,
|
|
56
73
|
dataError: null,
|
|
74
|
+
sections,
|
|
57
75
|
}
|
|
58
76
|
} catch (error) {
|
|
59
77
|
// A real-mode failure is surfaced as a visible error, never as fictional
|
|
@@ -65,6 +83,7 @@ export const home: ViewModule = {
|
|
|
65
83
|
dataSource: getDataSource(),
|
|
66
84
|
dataError:
|
|
67
85
|
error instanceof Error ? error.message : 'No se pudo cargar el catálogo.',
|
|
86
|
+
sections,
|
|
68
87
|
}
|
|
69
88
|
}
|
|
70
89
|
},
|
|
@@ -10,12 +10,15 @@
|
|
|
10
10
|
// schema (./schema.ts) before binding, so a contract mismatch fails loudly at
|
|
11
11
|
// the boundary instead of rendering undefined fields or literal icon tags.
|
|
12
12
|
|
|
13
|
+
import { CategoryCard as CategoryCardBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/category-card'
|
|
13
14
|
@@BLOCK_IMPORTS@@@@SECTION_REGISTRY_IMPORTS@@
|
|
14
15
|
import { useStateStore } from '@json-render/react'
|
|
15
16
|
import { resolveIcon } from '../../icon-map'
|
|
16
17
|
import type { ViewRegistry } from '../types'
|
|
18
|
+
import * as featureSchemas from './schema'
|
|
17
19
|
import {
|
|
18
|
-
|
|
20
|
+
categoryCardPropsSchema,
|
|
21
|
+
categoryGridPropsSchema,
|
|
19
22
|
featurePropsSchema,
|
|
20
23
|
storefrontHeroPropsSchema,
|
|
21
24
|
} from './schema'
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Feature: ({ props }) => {
|
|
2
|
+
const feature = featureSchemas.featureCardsSpecSchema.parse({
|
|
3
|
+
...props,
|
|
4
|
+
presentation: 'cards',
|
|
5
|
+
})
|
|
6
|
+
return (
|
|
7
|
+
<FeatureBlock
|
|
8
|
+
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
9
|
+
presentation='cards'
|
|
10
|
+
badge={feature.badge}
|
|
11
|
+
title={feature.title}
|
|
12
|
+
description={feature.description}
|
|
13
|
+
ctaLabel={feature.ctaLabel}
|
|
14
|
+
learnMoreLabel={feature.learnMoreLabel}
|
|
15
|
+
/>
|
|
16
|
+
)
|
|
17
|
+
},
|
package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → split}/registry.part
RENAMED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
Feature: ({ props }) => {
|
|
2
|
-
const feature =
|
|
2
|
+
const feature = featureSchemas.featureSplitSpecSchema.parse({
|
|
3
|
+
...props,
|
|
4
|
+
presentation: 'split',
|
|
5
|
+
})
|
|
3
6
|
return (
|
|
4
7
|
<FeatureBlock
|
|
5
8
|
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
6
|
-
|
|
9
|
+
presentation='split'
|
|
7
10
|
title={feature.title}
|
|
8
11
|
description={feature.description}
|
|
12
|
+
image={feature.image}
|
|
9
13
|
/>
|
|
10
14
|
)
|
|
11
15
|
},
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
CategoryCard: ({ props, emit }) => {
|
|
2
|
+
const { set } = useStateStore()
|
|
3
|
+
const card = categoryCardPropsSchema.parse(props)
|
|
4
|
+
return (
|
|
5
|
+
<CategoryCardBlock
|
|
6
|
+
{...card}
|
|
7
|
+
onBrowse={(category) => {
|
|
8
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
9
|
+
emit('openCategory')
|
|
10
|
+
}}
|
|
11
|
+
/>
|
|
12
|
+
)
|
|
13
|
+
},
|
|
14
|
+
CategoryGrid: ({ props, emit }) => {
|
|
15
|
+
const { set } = useStateStore()
|
|
16
|
+
const grid = categoryGridPropsSchema.parse(props)
|
|
17
|
+
return (
|
|
18
|
+
<CategoryGridBlock
|
|
19
|
+
{...grid}
|
|
20
|
+
onBrowse={(category) => {
|
|
21
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
22
|
+
emit('openCategory')
|
|
23
|
+
}}
|
|
24
|
+
onViewAll={() => {
|
|
25
|
+
set('/lastCategory', '/categories')
|
|
26
|
+
emit('openCategory')
|
|
27
|
+
}}
|
|
28
|
+
onQueryChange={(query) => set('/categoryQuery', query)}
|
|
29
|
+
/>
|
|
30
|
+
)
|
|
31
|
+
},
|
|
@@ -5,22 +5,24 @@
|
|
|
5
5
|
<StorefrontHeroBlock
|
|
6
6
|
title={hero.title}
|
|
7
7
|
description={hero.description}
|
|
8
|
+
presentation={hero.presentation}
|
|
9
|
+
currency={hero.currency}
|
|
8
10
|
products={hero.products}
|
|
9
11
|
titleAccent={hero.titleAccent}
|
|
10
12
|
badge={hero.badge}
|
|
11
13
|
primaryCta={hero.primaryCta}
|
|
12
14
|
secondaryCta={hero.secondaryCta}
|
|
13
15
|
heroImage={hero.heroImage}
|
|
16
|
+
rotationInterval={hero.rotationInterval}
|
|
14
17
|
onAddToCart={(product) => {
|
|
15
|
-
//
|
|
18
|
+
// Product-card shortcut: add the first purchasable variant.
|
|
16
19
|
set('/lastClicked', product)
|
|
17
|
-
emit('
|
|
20
|
+
emit('addClickedToCart')
|
|
18
21
|
}}
|
|
19
22
|
onBuyNow={(product) => {
|
|
20
23
|
set('/lastClicked', product)
|
|
21
24
|
emit('openProduct')
|
|
22
25
|
}}
|
|
23
|
-
onSelectColor={() => {}}
|
|
24
26
|
/>
|
|
25
27
|
)
|
|
26
28
|
},
|
|
@@ -27,11 +27,26 @@ export const heroContent = {
|
|
|
27
27
|
secondaryCta: { label: 'Ver categorías' },
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
+
/**
|
|
31
|
+
* Neutral editorial seed for the detailed (split) presentation. Replace it with
|
|
32
|
+
* your own image; the block renders editorial imagery in grayscale. It lives in
|
|
33
|
+
* user-owned content, not in the block library.
|
|
34
|
+
*/
|
|
35
|
+
const editorialImage = {
|
|
36
|
+
src:
|
|
37
|
+
'data:image/svg+xml;charset=utf-8,' +
|
|
38
|
+
encodeURIComponent(
|
|
39
|
+
`<svg xmlns='http://www.w3.org/2000/svg' width='1200' height='900'><rect width='100%' height='100%' fill='#e2e8f0'/><circle cx='360' cy='300' r='170' fill='#cbd5e1'/><rect x='560' y='180' width='420' height='420' rx='24' fill='#94a3b8' opacity='.55'/><path d='M120 720h960' stroke='#94a3b8' stroke-width='14' stroke-linecap='round'/></svg>`,
|
|
40
|
+
),
|
|
41
|
+
alt: '',
|
|
42
|
+
}
|
|
43
|
+
|
|
30
44
|
export const benefitsContent = {
|
|
31
45
|
badge: '__SITE_NAME__',
|
|
32
46
|
title: 'Compra con confianza',
|
|
33
47
|
// Neutral: no delivery/shipping promise.
|
|
34
48
|
description: 'Ventajas pensadas para una compra clara y segura.',
|
|
49
|
+
image: editorialImage,
|
|
35
50
|
items: [
|
|
36
51
|
{
|
|
37
52
|
id: 'pago',
|
|
@@ -57,6 +72,13 @@ export const benefitsContent = {
|
|
|
57
72
|
export const categoriesContent = {
|
|
58
73
|
title: 'Compra por categoría',
|
|
59
74
|
description: 'Explora nuestro catálogo completo.',
|
|
75
|
+
browseLabel: 'Explorar',
|
|
76
|
+
itemsLabel: 'productos',
|
|
77
|
+
searchLabel: 'Buscar categorías',
|
|
78
|
+
searchPlaceholder: 'Buscar categorías',
|
|
79
|
+
emptyLabel: 'No hay categorías disponibles.',
|
|
80
|
+
noResultsLabel: 'No se encontraron categorías.',
|
|
81
|
+
viewAllLabel: 'Ver todas las categorías',
|
|
60
82
|
}
|
|
61
83
|
|
|
62
84
|
/**
|
|
@@ -13,3 +13,12 @@ export function toNavCategories(
|
|
|
13
13
|
): { label: string; href: string }[] {
|
|
14
14
|
return categories.map((category) => ({ label: category.label, href: category.href }))
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
// Per-instance selection for data-bound sections (for example `products`), keyed
|
|
18
|
+
// by the section's stable id from the composition manifest. Each value is a
|
|
19
|
+
// canonical catalog selection (category/collection/search/ordering) that the
|
|
20
|
+
// generated host loader resolves through the runtime catalog bridge. Left empty
|
|
21
|
+
// by default: a data-bound section with no entry renders an `unconfigured`
|
|
22
|
+
// state. Entries whose id is no longer referenced by the composition are kept
|
|
23
|
+
// but never queried, so re-adding the section with the same id restores them.
|
|
24
|
+
export const sectionSources: Record<string, unknown> = {}
|
|
@@ -5,16 +5,18 @@
|
|
|
5
5
|
// on the server. Registered by importing it in ../index.ts. Recipe: recipes.json -> "home".
|
|
6
6
|
|
|
7
7
|
import { getCatalog } from '@thorprovider/runtime/commerce'
|
|
8
|
-
import { getDataSource } from '../../store-context'
|
|
8
|
+
import { getDataSource, getStoreContext } from '../../store-context'
|
|
9
9
|
import { pageRoot } from '../../spec/page-root'
|
|
10
10
|
import type { StorefrontElement } from '../../spec/types'
|
|
11
11
|
import type { ViewModule } from '../types'
|
|
12
12
|
import { registry } from './registry'
|
|
13
13
|
import { benefitsProps, categoriesProps, heroProps } from './props'
|
|
14
|
-
import
|
|
14
|
+
import * as homeData from './data'
|
|
15
15
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
16
|
+
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
16
17
|
import {
|
|
17
|
-
|
|
18
|
+
categoryCardPropsSchema,
|
|
19
|
+
categoryGridPropsSchema,
|
|
18
20
|
featurePropsSchema,
|
|
19
21
|
storefrontHeroPropsSchema,
|
|
20
22
|
} from './schema'
|
|
@@ -25,14 +27,14 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
25
27
|
'home.hero': {
|
|
26
28
|
type: 'StorefrontHero',
|
|
27
29
|
props: heroProps,
|
|
28
|
-
on: {
|
|
30
|
+
on: { addClickedToCart: { action: 'addClickedToCart' }, openProduct: { action: 'openProduct' } },
|
|
29
31
|
},
|
|
30
32
|
'home.benefits': {
|
|
31
33
|
type: 'Feature',
|
|
32
34
|
props: benefitsProps,
|
|
33
35
|
},
|
|
34
36
|
'home.categories': {
|
|
35
|
-
type: '
|
|
37
|
+
type: 'CategoryGrid',
|
|
36
38
|
props: categoriesProps,
|
|
37
39
|
on: { openCategory: { action: 'openCategory' } },
|
|
38
40
|
},
|
|
@@ -41,15 +43,19 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
41
43
|
const catalog = {
|
|
42
44
|
StorefrontHero: {
|
|
43
45
|
props: storefrontHeroPropsSchema,
|
|
44
|
-
description: 'Landing hero.',
|
|
46
|
+
description: 'Landing hero (presentations: compact, showcase, editorial, promotional).',
|
|
45
47
|
},
|
|
46
48
|
Feature: {
|
|
47
49
|
props: featurePropsSchema,
|
|
48
50
|
description: 'Benefit highlights.',
|
|
49
51
|
},
|
|
50
|
-
|
|
51
|
-
props:
|
|
52
|
-
description: 'Category
|
|
52
|
+
CategoryGrid: {
|
|
53
|
+
props: categoryGridPropsSchema,
|
|
54
|
+
description: 'Category listing that renders category cells.',
|
|
55
|
+
},
|
|
56
|
+
CategoryCard: {
|
|
57
|
+
props: categoryCardPropsSchema,
|
|
58
|
+
description: 'One category cell, without listing section chrome.',
|
|
53
59
|
},
|
|
54
60
|
}
|
|
55
61
|
|
|
@@ -70,14 +76,30 @@ export const home: ViewModule = {
|
|
|
70
76
|
},
|
|
71
77
|
loader: {
|
|
72
78
|
home: async () => {
|
|
79
|
+
// Data-bound sections resolve independently through the canonical catalog
|
|
80
|
+
// bridge; equal queries share request-local work and differing contexts
|
|
81
|
+
// stay isolated. A section failure never erases its siblings, and it is
|
|
82
|
+
// resolved separately so a catalog failure still yields truthful
|
|
83
|
+
// per-section state instead of a missing one.
|
|
84
|
+
let sections: Record<string, unknown> = {}
|
|
85
|
+
try {
|
|
86
|
+
sections = await resolveSectionViewStates(
|
|
87
|
+
[],
|
|
88
|
+
resolveSectionSources(homeData),
|
|
89
|
+
getStoreContext(),
|
|
90
|
+
)
|
|
91
|
+
} catch {
|
|
92
|
+
sections = {}
|
|
93
|
+
}
|
|
73
94
|
try {
|
|
74
95
|
const { products, categories, source } = await getCatalog()
|
|
75
96
|
return {
|
|
76
|
-
heroProducts: selectHeroProducts(products).map(toFeaturedProduct),
|
|
97
|
+
heroProducts: homeData.selectHeroProducts(products).map(toFeaturedProduct),
|
|
77
98
|
categories: categories.map(toCategoryCard),
|
|
78
|
-
navCategories: toNavCategories(categories),
|
|
99
|
+
navCategories: homeData.toNavCategories(categories),
|
|
79
100
|
dataSource: source,
|
|
80
101
|
dataError: null,
|
|
102
|
+
sections,
|
|
81
103
|
}
|
|
82
104
|
} catch (error) {
|
|
83
105
|
// A real-mode failure is surfaced as a visible error, never as fictional
|
|
@@ -89,6 +111,7 @@ export const home: ViewModule = {
|
|
|
89
111
|
dataSource: getDataSource(),
|
|
90
112
|
dataError:
|
|
91
113
|
error instanceof Error ? error.message : 'No se pudo cargar el catálogo.',
|
|
114
|
+
sections,
|
|
92
115
|
}
|
|
93
116
|
}
|
|
94
117
|
},
|
|
@@ -10,16 +10,17 @@
|
|
|
10
10
|
// schema (./schema.ts) before binding, so a contract mismatch fails loudly at
|
|
11
11
|
// the boundary instead of rendering undefined fields or literal icon tags.
|
|
12
12
|
|
|
13
|
-
import {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
} from '@thorprovider/blocks'
|
|
13
|
+
import { CategoryCard as CategoryCardBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/category-card'
|
|
14
|
+
import { CategoryGrid as CategoryGridBlock } from '@thorprovider/blocks/blocks/e-commerce/product-categories/product-category-grid'
|
|
15
|
+
import { StorefrontHero as StorefrontHeroBlock } from '@thorprovider/blocks/blocks/e-commerce/storefront-hero/storefront-hero'
|
|
16
|
+
import { Feature as FeatureBlock } from '@thorprovider/blocks/blocks/marketing/features/feature'
|
|
18
17
|
import { useStateStore } from '@json-render/react'
|
|
19
18
|
import { resolveIcon } from '../../icon-map'
|
|
20
19
|
import type { ViewRegistry } from '../types'
|
|
20
|
+
import * as featureSchemas from './schema'
|
|
21
21
|
import {
|
|
22
|
-
|
|
22
|
+
categoryCardPropsSchema,
|
|
23
|
+
categoryGridPropsSchema,
|
|
23
24
|
featurePropsSchema,
|
|
24
25
|
storefrontHeroPropsSchema,
|
|
25
26
|
} from './schema'
|
|
@@ -32,45 +33,50 @@ export const registry: ViewRegistry = {
|
|
|
32
33
|
<StorefrontHeroBlock
|
|
33
34
|
title={hero.title}
|
|
34
35
|
description={hero.description}
|
|
36
|
+
presentation={hero.presentation}
|
|
37
|
+
currency={hero.currency}
|
|
35
38
|
products={hero.products}
|
|
36
39
|
titleAccent={hero.titleAccent}
|
|
37
40
|
badge={hero.badge}
|
|
38
41
|
primaryCta={hero.primaryCta}
|
|
39
42
|
secondaryCta={hero.secondaryCta}
|
|
40
43
|
heroImage={hero.heroImage}
|
|
44
|
+
rotationInterval={hero.rotationInterval}
|
|
41
45
|
onAddToCart={(product) => {
|
|
42
|
-
//
|
|
46
|
+
// Product-card shortcut: add the first purchasable variant.
|
|
43
47
|
set('/lastClicked', product)
|
|
44
|
-
emit('
|
|
48
|
+
emit('addClickedToCart')
|
|
45
49
|
}}
|
|
46
50
|
onBuyNow={(product) => {
|
|
47
51
|
set('/lastClicked', product)
|
|
48
52
|
emit('openProduct')
|
|
49
53
|
}}
|
|
50
|
-
onSelectColor={() => {}}
|
|
51
54
|
/>
|
|
52
55
|
)
|
|
53
56
|
},
|
|
54
57
|
Feature: ({ props }) => {
|
|
55
|
-
const feature =
|
|
58
|
+
const feature = featureSchemas.featureCardsSpecSchema.parse({
|
|
59
|
+
...props,
|
|
60
|
+
presentation: 'cards',
|
|
61
|
+
})
|
|
56
62
|
return (
|
|
57
63
|
<FeatureBlock
|
|
58
64
|
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
65
|
+
presentation='cards'
|
|
59
66
|
badge={feature.badge}
|
|
60
67
|
title={feature.title}
|
|
61
68
|
description={feature.description}
|
|
69
|
+
ctaLabel={feature.ctaLabel}
|
|
70
|
+
learnMoreLabel={feature.learnMoreLabel}
|
|
62
71
|
/>
|
|
63
72
|
)
|
|
64
73
|
},
|
|
65
|
-
|
|
74
|
+
CategoryCard: ({ props, emit }) => {
|
|
66
75
|
const { set } = useStateStore()
|
|
67
|
-
const
|
|
76
|
+
const card = categoryCardPropsSchema.parse(props)
|
|
68
77
|
return (
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
description={cards.description}
|
|
72
|
-
categories={cards.categories}
|
|
73
|
-
cta={cards.cta}
|
|
78
|
+
<CategoryCardBlock
|
|
79
|
+
{...card}
|
|
74
80
|
onBrowse={(category) => {
|
|
75
81
|
set('/lastCategory', category.handle ?? String(category.id))
|
|
76
82
|
emit('openCategory')
|
|
@@ -78,4 +84,22 @@ export const registry: ViewRegistry = {
|
|
|
78
84
|
/>
|
|
79
85
|
)
|
|
80
86
|
},
|
|
87
|
+
CategoryGrid: ({ props, emit }) => {
|
|
88
|
+
const { set } = useStateStore()
|
|
89
|
+
const grid = categoryGridPropsSchema.parse(props)
|
|
90
|
+
return (
|
|
91
|
+
<CategoryGridBlock
|
|
92
|
+
{...grid}
|
|
93
|
+
onBrowse={(category) => {
|
|
94
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
95
|
+
emit('openCategory')
|
|
96
|
+
}}
|
|
97
|
+
onViewAll={() => {
|
|
98
|
+
set('/lastCategory', '/categories')
|
|
99
|
+
emit('openCategory')
|
|
100
|
+
}}
|
|
101
|
+
onQueryChange={(query) => set('/categoryQuery', query)}
|
|
102
|
+
/>
|
|
103
|
+
)
|
|
104
|
+
},
|
|
81
105
|
}
|