@thorprovider/storefront 0.4.0-mvp.2 → 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 +10 -12
- package/assets/templates/app/app/[[...slug]]/page.tsx +14 -1
- package/assets/templates/app/app/[[...slug]]/renderer.tsx +43 -12
- 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 +76 -27
- package/assets/templates/app/lib/__STOREFRONT__/catalog.ts +4 -4
- package/assets/templates/app/lib/__STOREFRONT__/commerce.ts +0 -10
- package/assets/templates/app/lib/__STOREFRONT__/handlers.core.ts +3 -3
- 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 +48 -19
- package/assets/templates/app/lib/__STOREFRONT__/schema.ts +49 -11
- package/assets/templates/app/lib/__STOREFRONT__/section-sources.ts +3 -5
- package/assets/templates/app/lib/__STOREFRONT__/spec/index.ts +25 -0
- package/assets/templates/app/lib/__STOREFRONT__/state.core.ts +4 -2
- 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/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 +16 -16
- package/assets/templates/app/lib/__STOREFRONT__/views/sections/schema.products.ts +1 -1
- 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/customer-auth/handlers.ts +19 -23
- package/assets/templates/features/customer-auth/state.ts +21 -0
- package/assets/templates/views/account/index.tsx +19 -7
- package/assets/templates/views/account/registry.tsx +234 -155
- package/assets/templates/views/cart/data.ts +7 -7
- package/assets/templates/views/cart/registry.tsx +4 -3
- package/assets/templates/views/category/assembly/assembly.json +1 -1
- package/assets/templates/views/category/assembly/registry.skeleton.tsx +6 -6
- package/assets/templates/views/category/assembly/slots/breadcrumb/Breadcrumb/binding.json +1 -1
- package/assets/templates/views/category/registry.tsx +7 -7
- package/assets/templates/views/checkout/registry.tsx +3 -5
- package/assets/templates/views/home/assembly/assembly.json +4 -4
- package/assets/templates/views/home/assembly/index.skeleton.tsx +2 -1
- 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/{Feature1 → cards}/registry.part +7 -1
- package/assets/templates/views/home/assembly/slots/benefits/split/binding.json +5 -0
- package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/registry.part +6 -1
- 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/{StorefrontHero1 → StorefrontHero}/registry.part +3 -1
- package/assets/templates/views/home/content.ts +22 -0
- package/assets/templates/views/home/index.tsx +11 -6
- package/assets/templates/views/home/props.ts +1 -0
- package/assets/templates/views/home/registry.tsx +39 -15
- package/assets/templates/views/home/schema.ts +141 -24
- package/assets/templates/views/product/data.ts +1 -1
- package/assets/templates/views/product/registry.tsx +10 -6
- package/assets/templates/views/product/schema.ts +36 -1
- package/package.json +4 -5
- package/recipes/archetypes.json +25 -25
- package/recipes/catalog.json +213 -160
- package/recipes/catalog.mjs +10 -0
- package/recipes/catalog.schema.json +4 -0
- package/recipes/features.json +3 -3
- package/recipes/recipes.json +138 -40
- package/recipes/sections.json +2 -2
- package/recipes/validate.mjs +21 -4
- package/scripts/candidate.mjs +2 -2
- package/scripts/file-classes.mjs +10 -0
- package/scripts/ownership-conflict.mjs +5 -2
- package/scripts/view-assembly.mjs +10 -2
- package/scripts/view-selection.mjs +1 -1
- package/skills/sf-view-gen/assets/recipes/archetypes.json +25 -25
- package/skills/sf-view-gen/assets/recipes/catalog.json +213 -160
- package/skills/sf-view-gen/assets/recipes/catalog.schema.json +4 -0
- package/skills/sf-view-gen/assets/recipes/features.json +3 -3
- package/skills/sf-view-gen/assets/recipes/recipes.json +138 -40
- package/skills/sf-view-gen/assets/recipes/sections.json +2 -2
- 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 +16 -16
- package/skills/sf-view-gen/assets/templates/views/sections/schema.products.ts +1 -1
- 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/sf-view-gen/scripts/catalog.mjs +10 -0
- package/skills/sf-view-gen/scripts/validate.mjs +21 -4
- 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/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/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/assets/templates/views/home/assembly/slots/hero/{StorefrontHero1 → StorefrontHero}/element.part +0 -0
|
@@ -7,11 +7,9 @@
|
|
|
7
7
|
// spec (elements/catalog/route/loader) stays a pure Server Component module.
|
|
8
8
|
|
|
9
9
|
import { useEffect, useRef } from 'react'
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
CheckoutConfirmation as CheckoutConfirmationBlock,
|
|
14
|
-
} from '@thorprovider/blocks'
|
|
10
|
+
import { Button } from '@thorprovider/blocks/ui/button'
|
|
11
|
+
import CheckoutBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout-form-1'
|
|
12
|
+
import CheckoutConfirmationBlock from '@thorprovider/blocks/blocks/e-commerce/checkout-forms/checkout-confirmation'
|
|
15
13
|
import { useStateStore } from '@json-render/react'
|
|
16
14
|
import { loadCheckoutAction, reconcileReceiptAction } from '../../actions'
|
|
17
15
|
import type { CartStatePatch, PlaceOrderResult } from '../../commerce'
|
|
@@ -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": {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
"propsModule": "./content",
|
|
28
28
|
"defaultProps": "{}",
|
|
29
29
|
"dataBound": true,
|
|
30
|
-
"defaultVariant": "
|
|
30
|
+
"defaultVariant": "ProductGrid"
|
|
31
31
|
}
|
|
32
32
|
}
|
|
33
33
|
}
|
|
@@ -15,7 +15,8 @@ import * as homeData from './data'
|
|
|
15
15
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
16
16
|
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
17
17
|
import {
|
|
18
|
-
|
|
18
|
+
categoryCardPropsSchema,
|
|
19
|
+
categoryGridPropsSchema,
|
|
19
20
|
featurePropsSchema,
|
|
20
21
|
storefrontHeroPropsSchema,
|
|
21
22
|
} from './schema'@@SECTION_IMPORTS@@
|
|
@@ -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'
|
package/assets/templates/views/home/assembly/slots/benefits/{Feature1 → cards}/registry.part
RENAMED
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
Feature: ({ props }) => {
|
|
2
|
-
const feature =
|
|
2
|
+
const feature = featureSchemas.featureCardsSpecSchema.parse({
|
|
3
|
+
...props,
|
|
4
|
+
presentation: 'cards',
|
|
5
|
+
})
|
|
3
6
|
return (
|
|
4
7
|
<FeatureBlock
|
|
5
8
|
items={feature.items.map((item) => ({ ...item, icon: resolveIcon(item.icon) }))}
|
|
9
|
+
presentation='cards'
|
|
6
10
|
badge={feature.badge}
|
|
7
11
|
title={feature.title}
|
|
8
12
|
description={feature.description}
|
|
13
|
+
ctaLabel={feature.ctaLabel}
|
|
14
|
+
learnMoreLabel={feature.learnMoreLabel}
|
|
9
15
|
/>
|
|
10
16
|
)
|
|
11
17
|
},
|
package/assets/templates/views/home/assembly/slots/benefits/{Feature2 → split}/registry.part
RENAMED
|
@@ -1,10 +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) }))}
|
|
9
|
+
presentation='split'
|
|
6
10
|
title={feature.title}
|
|
7
11
|
description={feature.description}
|
|
12
|
+
image={feature.image}
|
|
8
13
|
/>
|
|
9
14
|
)
|
|
10
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,12 +5,15 @@
|
|
|
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)
|
|
@@ -20,7 +23,6 @@
|
|
|
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
|
/**
|
|
@@ -15,7 +15,8 @@ import * as homeData from './data'
|
|
|
15
15
|
import { toCategoryCard, toFeaturedProduct } from '../../mappers'
|
|
16
16
|
import { resolveSectionSources, resolveSectionViewStates } from '../../section-sources'
|
|
17
17
|
import {
|
|
18
|
-
|
|
18
|
+
categoryCardPropsSchema,
|
|
19
|
+
categoryGridPropsSchema,
|
|
19
20
|
featurePropsSchema,
|
|
20
21
|
storefrontHeroPropsSchema,
|
|
21
22
|
} from './schema'
|
|
@@ -33,7 +34,7 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
33
34
|
props: benefitsProps,
|
|
34
35
|
},
|
|
35
36
|
'home.categories': {
|
|
36
|
-
type: '
|
|
37
|
+
type: 'CategoryGrid',
|
|
37
38
|
props: categoriesProps,
|
|
38
39
|
on: { openCategory: { action: 'openCategory' } },
|
|
39
40
|
},
|
|
@@ -42,15 +43,19 @@ const elements: Record<string, StorefrontElement> = {
|
|
|
42
43
|
const catalog = {
|
|
43
44
|
StorefrontHero: {
|
|
44
45
|
props: storefrontHeroPropsSchema,
|
|
45
|
-
description: 'Landing hero.',
|
|
46
|
+
description: 'Landing hero (presentations: compact, showcase, editorial, promotional).',
|
|
46
47
|
},
|
|
47
48
|
Feature: {
|
|
48
49
|
props: featurePropsSchema,
|
|
49
50
|
description: 'Benefit highlights.',
|
|
50
51
|
},
|
|
51
|
-
|
|
52
|
-
props:
|
|
53
|
-
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.',
|
|
54
59
|
},
|
|
55
60
|
}
|
|
56
61
|
|
|
@@ -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,12 +33,15 @@ 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)
|
|
@@ -47,34 +51,54 @@ export const registry: ViewRegistry = {
|
|
|
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}
|
|
71
|
+
/>
|
|
72
|
+
)
|
|
73
|
+
},
|
|
74
|
+
CategoryCard: ({ props, emit }) => {
|
|
75
|
+
const { set } = useStateStore()
|
|
76
|
+
const card = categoryCardPropsSchema.parse(props)
|
|
77
|
+
return (
|
|
78
|
+
<CategoryCardBlock
|
|
79
|
+
{...card}
|
|
80
|
+
onBrowse={(category) => {
|
|
81
|
+
set('/lastCategory', category.handle ?? String(category.id))
|
|
82
|
+
emit('openCategory')
|
|
83
|
+
}}
|
|
62
84
|
/>
|
|
63
85
|
)
|
|
64
86
|
},
|
|
65
|
-
|
|
87
|
+
CategoryGrid: ({ props, emit }) => {
|
|
66
88
|
const { set } = useStateStore()
|
|
67
|
-
const
|
|
89
|
+
const grid = categoryGridPropsSchema.parse(props)
|
|
68
90
|
return (
|
|
69
|
-
<
|
|
70
|
-
|
|
71
|
-
description={cards.description}
|
|
72
|
-
categories={cards.categories}
|
|
73
|
-
cta={cards.cta}
|
|
91
|
+
<CategoryGridBlock
|
|
92
|
+
{...grid}
|
|
74
93
|
onBrowse={(category) => {
|
|
75
94
|
set('/lastCategory', category.handle ?? String(category.id))
|
|
76
95
|
emit('openCategory')
|
|
77
96
|
}}
|
|
97
|
+
onViewAll={() => {
|
|
98
|
+
set('/lastCategory', '/categories')
|
|
99
|
+
emit('openCategory')
|
|
100
|
+
}}
|
|
101
|
+
onQueryChange={(query) => set('/categoryQuery', query)}
|
|
78
102
|
/>
|
|
79
103
|
)
|
|
80
104
|
},
|
|
@@ -12,25 +12,33 @@ export const ctaSchema = z.object({
|
|
|
12
12
|
href: z.string().optional(),
|
|
13
13
|
})
|
|
14
14
|
|
|
15
|
-
// Mirrors the StorefrontHero block contract (FeaturedProduct
|
|
16
|
-
//
|
|
15
|
+
// Mirrors the canonical StorefrontHero block contract (FeaturedProduct,
|
|
16
|
+
// @thorprovider/blocks). Every popularity, review, or availability field is
|
|
17
|
+
// host-supplied evidence: omitted fields render nothing (honest omission)
|
|
18
|
+
// instead of fabricated defaults.
|
|
17
19
|
export const featuredProductSchema = z.object({
|
|
18
20
|
id: z.string(),
|
|
19
21
|
name: z.string(),
|
|
20
|
-
brand: z.string(),
|
|
21
22
|
price: z.number(),
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
23
|
+
// Real compare-at price. Discount treatments render only from a real
|
|
24
|
+
// `originalPrice > price` pair — never fabricated when the backend lacks one.
|
|
25
|
+
originalPrice: z.number().optional(),
|
|
26
|
+
image: z.string().optional(),
|
|
27
|
+
imageAlt: z.string().optional(),
|
|
28
|
+
brand: z.string().optional(),
|
|
29
|
+
colors: z.array(z.string()).optional(),
|
|
30
|
+
rating: z.number().optional(),
|
|
31
|
+
reviewCount: z.number().optional(),
|
|
32
|
+
inStock: z.boolean().optional(),
|
|
33
|
+
isNew: z.boolean().optional(),
|
|
34
|
+
tag: z.string().optional(),
|
|
30
35
|
})
|
|
31
36
|
|
|
32
|
-
// Mirrors the
|
|
33
|
-
//
|
|
37
|
+
// Mirrors the canonical Feature block contract (@thorprovider/blocks
|
|
38
|
+
// featurePropsSchema); `icon` is a NAME here and only becomes a component when
|
|
39
|
+
// the registry resolves it through the shared icon map. The presentation
|
|
40
|
+
// selects the bounded cards/split surface; CTA/learn-more are cards-only
|
|
41
|
+
// labels, the image a split-only column.
|
|
34
42
|
export const featureItemSchema = z.object({
|
|
35
43
|
id: z.string(),
|
|
36
44
|
title: z.string(),
|
|
@@ -38,18 +46,22 @@ export const featureItemSchema = z.object({
|
|
|
38
46
|
icon: z.string(),
|
|
39
47
|
})
|
|
40
48
|
|
|
41
|
-
// Mirrors the
|
|
42
|
-
// `itemCount` is optional: when the backend count is
|
|
43
|
-
// omits it (the block renders no count) rather than
|
|
44
|
-
// `0` is preserved.
|
|
49
|
+
// Mirrors the canonical category item contract (@thorprovider/blocks
|
|
50
|
+
// productCategoryItemSchema). `itemCount` is optional: when the backend count is
|
|
51
|
+
// unknown the projection omits it (the block renders no count) rather than
|
|
52
|
+
// fabricating a `0`; a real `0` is preserved. `icon` is a serializable icon-key
|
|
53
|
+
// resolved by the block; `subcategories`/`featured` feed the `list` reading.
|
|
45
54
|
export const categoryCardSchema = z.object({
|
|
46
55
|
id: z.string(),
|
|
47
56
|
handle: z.string().optional(),
|
|
48
57
|
name: z.string(),
|
|
49
|
-
description: z.string(),
|
|
58
|
+
description: z.string().optional(),
|
|
50
59
|
itemCount: z.number().optional(),
|
|
51
|
-
image: z.string(),
|
|
52
|
-
trending: z.boolean(),
|
|
60
|
+
image: z.string().optional(),
|
|
61
|
+
trending: z.boolean().optional(),
|
|
62
|
+
icon: z.string().optional(),
|
|
63
|
+
subcategories: z.array(z.string()).optional(),
|
|
64
|
+
featured: z.boolean().optional(),
|
|
53
65
|
})
|
|
54
66
|
|
|
55
67
|
// Optional editorial hero image (mirrors the StorefrontHero block contract).
|
|
@@ -60,34 +72,139 @@ export const heroImageSchema = z.object({
|
|
|
60
72
|
alt: z.string(),
|
|
61
73
|
})
|
|
62
74
|
|
|
75
|
+
// Mirrors the canonical StorefrontHero block contract
|
|
76
|
+
// (storefrontHeroPropsSchema, @thorprovider/blocks). The bounded presentation
|
|
77
|
+
// option reuses the registry's archetype intent vocabulary. Callbacks are
|
|
78
|
+
// consumer bindings, not serializable props, so they are bound in registry.tsx
|
|
79
|
+
// and deliberately absent here.
|
|
80
|
+
export const heroDepartmentSchema = z.object({
|
|
81
|
+
id: z.string(),
|
|
82
|
+
name: z.string(),
|
|
83
|
+
image: z.string().optional(),
|
|
84
|
+
imageAlt: z.string().optional(),
|
|
85
|
+
count: z.string().optional(),
|
|
86
|
+
href: z.string().optional(),
|
|
87
|
+
})
|
|
88
|
+
|
|
89
|
+
export const heroFeaturedDealSchema = z.object({
|
|
90
|
+
id: z.string(),
|
|
91
|
+
name: z.string(),
|
|
92
|
+
description: z.string().optional(),
|
|
93
|
+
image: z.string().optional(),
|
|
94
|
+
imageAlt: z.string().optional(),
|
|
95
|
+
price: z.number(),
|
|
96
|
+
originalPrice: z.number().optional(),
|
|
97
|
+
cta: ctaSchema.optional(),
|
|
98
|
+
})
|
|
99
|
+
|
|
100
|
+
export const heroStoreLocatorSchema = z.object({
|
|
101
|
+
title: z.string(),
|
|
102
|
+
description: z.string(),
|
|
103
|
+
ctaLabel: z.string(),
|
|
104
|
+
ctaHref: z.string().optional(),
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
export const heroDealSchema = z.object({
|
|
108
|
+
id: z.string(),
|
|
109
|
+
title: z.string(),
|
|
110
|
+
discount: z.string().optional(),
|
|
111
|
+
endTime: z.string().optional(),
|
|
112
|
+
})
|
|
113
|
+
|
|
114
|
+
export const heroCategorySchema = z.object({
|
|
115
|
+
id: z.string(),
|
|
116
|
+
name: z.string(),
|
|
117
|
+
image: z.string().optional(),
|
|
118
|
+
imageAlt: z.string().optional(),
|
|
119
|
+
count: z.string().optional(),
|
|
120
|
+
href: z.string().optional(),
|
|
121
|
+
})
|
|
122
|
+
|
|
63
123
|
export const storefrontHeroPropsSchema = z.object({
|
|
64
124
|
title: z.string(),
|
|
65
125
|
description: z.string(),
|
|
66
|
-
|
|
126
|
+
presentation: z.enum(['compact', 'showcase', 'editorial', 'promotional']).optional(),
|
|
127
|
+
currency: z.string().optional(),
|
|
67
128
|
badge: z.string().optional(),
|
|
129
|
+
titleAccent: z.string().optional(),
|
|
68
130
|
products: z.array(featuredProductSchema),
|
|
69
131
|
primaryCta: ctaSchema.optional(),
|
|
70
132
|
secondaryCta: ctaSchema.optional(),
|
|
71
133
|
heroImage: heroImageSchema.optional(),
|
|
134
|
+
departments: z.array(heroDepartmentSchema).optional(),
|
|
135
|
+
featuredDeals: z.array(heroFeaturedDealSchema).optional(),
|
|
136
|
+
storeLocator: heroStoreLocatorSchema.optional(),
|
|
137
|
+
shippingInfo: z.string().optional(),
|
|
138
|
+
deals: z.array(heroDealSchema).optional(),
|
|
139
|
+
categories: z.array(heroCategorySchema).optional(),
|
|
140
|
+
rotationInterval: z.number().optional(),
|
|
72
141
|
})
|
|
73
142
|
|
|
74
|
-
export const
|
|
143
|
+
export const featureCardsSpecSchema = z.object({
|
|
75
144
|
items: z.array(featureItemSchema),
|
|
145
|
+
presentation: z.literal('cards').optional(),
|
|
76
146
|
badge: z.string().optional(),
|
|
77
147
|
title: z.string().optional(),
|
|
78
148
|
description: z.string().optional(),
|
|
149
|
+
ctaLabel: z.string().optional(),
|
|
150
|
+
learnMoreLabel: z.string().optional(),
|
|
79
151
|
})
|
|
80
152
|
|
|
81
|
-
export const
|
|
153
|
+
export const featureSplitSpecSchema = z.object({
|
|
154
|
+
items: z.array(featureItemSchema),
|
|
155
|
+
presentation: z.literal('split'),
|
|
82
156
|
title: z.string().optional(),
|
|
83
157
|
description: z.string().optional(),
|
|
158
|
+
image: z.object({ src: z.string().trim().min(1), alt: z.string() }),
|
|
159
|
+
})
|
|
160
|
+
|
|
161
|
+
export const featurePropsSchema = z.union([featureSplitSpecSchema, featureCardsSpecSchema])
|
|
162
|
+
|
|
163
|
+
export const categoryCardPropsSchema = z.object({
|
|
164
|
+
category: categoryCardSchema,
|
|
165
|
+
presentation: z.enum(['grid', 'icons', 'list']).optional(),
|
|
166
|
+
browseLabel: z.string().optional(),
|
|
167
|
+
itemsLabel: z.string().optional(),
|
|
168
|
+
trendingLabel: z.string().optional(),
|
|
169
|
+
featuredLabel: z.string().optional(),
|
|
170
|
+
imageFallback: z.string().optional(),
|
|
171
|
+
})
|
|
172
|
+
|
|
173
|
+
export const categoryGridPropsSchema = z.object({
|
|
174
|
+
title: z.string().optional(),
|
|
175
|
+
description: z.string().optional(),
|
|
176
|
+
badge: z.string().optional(),
|
|
177
|
+
presentation: z.enum(['grid', 'icons', 'list']).optional(),
|
|
84
178
|
categories: z.array(categoryCardSchema),
|
|
85
179
|
cta: ctaSchema.optional(),
|
|
180
|
+
query: z.string().optional(),
|
|
181
|
+
searchPlaceholder: z.string().optional(),
|
|
182
|
+
searchLabel: z.string().optional(),
|
|
183
|
+
emptyLabel: z.string().optional(),
|
|
184
|
+
noResultsLabel: z.string().optional(),
|
|
185
|
+
browseLabel: z.string().optional(),
|
|
186
|
+
viewAllLabel: z.string().optional(),
|
|
187
|
+
trendingLabel: z.string().optional(),
|
|
188
|
+
featuredLabel: z.string().optional(),
|
|
189
|
+
itemsLabel: z.string().optional(),
|
|
190
|
+
imageFallback: z.string().optional(),
|
|
191
|
+
className: z.string().optional(),
|
|
192
|
+
maxItems: z.number().int().positive().optional(),
|
|
193
|
+
loading: z.boolean().optional(),
|
|
194
|
+
skeletonCount: z.number().int().positive().optional(),
|
|
86
195
|
})
|
|
87
196
|
|
|
88
197
|
export type FeaturedProduct = z.infer<typeof featuredProductSchema>
|
|
89
198
|
export type FeatureItem = z.infer<typeof featureItemSchema>
|
|
90
199
|
export type CategoryCard = z.infer<typeof categoryCardSchema>
|
|
200
|
+
export type HeroDepartment = z.infer<typeof heroDepartmentSchema>
|
|
201
|
+
export type HeroFeaturedDeal = z.infer<typeof heroFeaturedDealSchema>
|
|
202
|
+
export type HeroStoreLocator = z.infer<typeof heroStoreLocatorSchema>
|
|
203
|
+
export type HeroDeal = z.infer<typeof heroDealSchema>
|
|
204
|
+
export type HeroCategory = z.infer<typeof heroCategorySchema>
|
|
91
205
|
export type StorefrontHeroProps = z.infer<typeof storefrontHeroPropsSchema>
|
|
92
206
|
export type FeatureProps = z.infer<typeof featurePropsSchema>
|
|
93
|
-
export type
|
|
207
|
+
export type FeatureCardsSpecProps = z.infer<typeof featureCardsSpecSchema>
|
|
208
|
+
export type FeatureSplitSpecProps = z.infer<typeof featureSplitSpecSchema>
|
|
209
|
+
export type CategoryCardProps = z.infer<typeof categoryCardPropsSchema>
|
|
210
|
+
export type CategoryGridProps = z.infer<typeof categoryGridPropsSchema>
|
|
@@ -9,7 +9,7 @@ import type { ProductDetailProduct } from '@thorprovider/blocks'
|
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
11
|
* Map the runtime's canonical product detail (real variants, options,
|
|
12
|
-
* availability, Money) to the
|
|
12
|
+
* availability, Money) to the canonical ProductOverview block contract.
|
|
13
13
|
*
|
|
14
14
|
* Price availability is preserved, not collapsed: a variant whose backend price
|
|
15
15
|
* is unresolved carries `price: null` (the block treats that as unavailable and
|