@tanqory/partner-cli 0.0.0-stage → 0.1.0-alpha.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/LICENSE +21 -0
- package/bin/tanqory-partner.mjs +10 -0
- package/config/mirror-allowlist.json +17 -0
- package/config/theme-licences.json +108 -0
- package/config/third-party-toolchains.json +45 -0
- package/lib/api.mjs +109 -0
- package/lib/auth.mjs +211 -0
- package/lib/check.mjs +63 -0
- package/lib/cli.mjs +217 -0
- package/lib/mcp.mjs +177 -0
- package/lib/ops.mjs +179 -0
- package/lib/theme.mjs +121 -0
- package/lib/vendor/partner-checks.cjs +1617 -0
- package/package.json +59 -4
- package/starter/LICENSE +18 -0
- package/starter/README.md +38 -0
- package/starter/config/settings.json +3 -0
- package/starter/gitignore +3 -0
- package/starter/locales/en.json +22 -0
- package/starter/locales/th.json +22 -0
- package/starter/package.json +29 -0
- package/starter/regions/footer.json +35 -0
- package/starter/regions/header.json +13 -0
- package/starter/scripts/build.mjs +195 -0
- package/starter/scripts/probe.ts +4 -0
- package/starter/src/bundle.ts +15 -0
- package/starter/src/components/parts.tsx +32 -0
- package/starter/src/entry.client.tsx +6 -0
- package/starter/src/entry.server.tsx +13 -0
- package/starter/src/sections/chrome.tsx +132 -0
- package/starter/src/sections/commerce.tsx +242 -0
- package/starter/src/sections/content.tsx +111 -0
- package/starter/src/sections/editorial.tsx +107 -0
- package/starter/src/settings.ts +15 -0
- package/starter/src/styles/theme.css +224 -0
- package/starter/src/templates.ts +14 -0
- package/starter/src/theme.tsx +76 -0
- package/starter/templates/404.json +14 -0
- package/starter/templates/account.json +14 -0
- package/starter/templates/article.json +14 -0
- package/starter/templates/blog.json +14 -0
- package/starter/templates/cart.json +14 -0
- package/starter/templates/collection.json +14 -0
- package/starter/templates/index.json +36 -0
- package/starter/templates/page.contact.json +18 -0
- package/starter/templates/page.json +14 -0
- package/starter/templates/product.json +18 -0
- package/starter/templates/search.json +14 -0
- package/starter/tsconfig.json +17 -0
- package/starter/vite.client.config.ts +17 -0
- package/starter/vite.probe.config.ts +16 -0
- package/starter/vite.server.config.ts +32 -0
- package/README.md +0 -3
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
/** The masthead and the colophon: Starter's shared header and footer. */
|
|
2
|
+
import { useId, useState } from 'react'
|
|
3
|
+
import {
|
|
4
|
+
CartToggle,
|
|
5
|
+
Image,
|
|
6
|
+
LocalizationForm,
|
|
7
|
+
SearchForm,
|
|
8
|
+
ai,
|
|
9
|
+
defineBlock,
|
|
10
|
+
defineSection,
|
|
11
|
+
field,
|
|
12
|
+
useMenu,
|
|
13
|
+
useShop,
|
|
14
|
+
useTranslate,
|
|
15
|
+
type BlockInstance,
|
|
16
|
+
} from '@tanqory/theme-kit/headless'
|
|
17
|
+
import { cx } from '../components/parts'
|
|
18
|
+
|
|
19
|
+
function Masthead({ settings }: { settings: { menu: string; tagline: string } }): JSX.Element {
|
|
20
|
+
const shop = useShop()
|
|
21
|
+
const menu = useMenu(settings.menu)
|
|
22
|
+
const t = useTranslate()
|
|
23
|
+
const navId = useId()
|
|
24
|
+
const [open, setOpen] = useState(false)
|
|
25
|
+
return (
|
|
26
|
+
<header className="st-mast">
|
|
27
|
+
<a className="st-mast__brand" href="/">
|
|
28
|
+
{shop.logo ? <Image image={shop.logo} alt={shop.name} className="st-mast__logo" loading="eager" /> : shop.name}
|
|
29
|
+
</a>
|
|
30
|
+
{settings.tagline ? <p className="st-mast__tagline">{settings.tagline}</p> : null}
|
|
31
|
+
<button type="button" className="st-mast__menu" data-tq-action="menu:open" aria-expanded={open} aria-controls={navId} onClick={() => setOpen((o) => !o)}>
|
|
32
|
+
{t(open ? 'menu.closeMenu' : 'menu.menu')}
|
|
33
|
+
</button>
|
|
34
|
+
<nav id={navId} className={cx('st-mast__nav', open && 'is-open')} aria-label={t('starter.nav.main')}>
|
|
35
|
+
<ul>
|
|
36
|
+
{(menu?.items ?? []).map((item) => (
|
|
37
|
+
<li key={`${item.title}-${item.url}`}>
|
|
38
|
+
<a href={item.url ?? '/'} aria-current={item.active ? 'page' : undefined}>
|
|
39
|
+
{item.title}
|
|
40
|
+
</a>
|
|
41
|
+
</li>
|
|
42
|
+
))}
|
|
43
|
+
</ul>
|
|
44
|
+
</nav>
|
|
45
|
+
<div className="st-mast__tools">
|
|
46
|
+
<SearchForm className="st-find" inputClassName="st-find__input" submit={false} resultsClassName="st-find__results" limit={5} />
|
|
47
|
+
<LocalizationForm className="st-locale" label="hidden" selectClassName="st-locale__select" />
|
|
48
|
+
<CartToggle className="st-mast__cart" />
|
|
49
|
+
</div>
|
|
50
|
+
</header>
|
|
51
|
+
)
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export const header = defineSection({
|
|
55
|
+
type: 'header',
|
|
56
|
+
title: 'Header',
|
|
57
|
+
description: 'The shop name, the main menu, search, region and the cart.',
|
|
58
|
+
category: 'chrome',
|
|
59
|
+
zone: 'header',
|
|
60
|
+
settings: {
|
|
61
|
+
menu: field.resource('menu', 'main-menu', { label: 'Menu' }),
|
|
62
|
+
tagline: field.text('', { label: 'Tagline' }),
|
|
63
|
+
// The data plan's convention: the masthead shows the market selector.
|
|
64
|
+
showLocale: field.boolean(true, { label: 'Show country and language' }),
|
|
65
|
+
},
|
|
66
|
+
ai: ai.headerMenu('menu'),
|
|
67
|
+
component: Masthead,
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
const footerMenu = defineBlock({
|
|
71
|
+
type: 'footer-menu',
|
|
72
|
+
title: 'Menu column',
|
|
73
|
+
settings: { heading: field.text('', { label: 'Heading' }), menu: field.resource('menu', 'footer', { label: 'Menu' }) },
|
|
74
|
+
})
|
|
75
|
+
const footerBrand = defineBlock({
|
|
76
|
+
type: 'footer-brand',
|
|
77
|
+
title: 'Brand',
|
|
78
|
+
settings: { tagline: field.textarea('', { label: 'Tagline' }) },
|
|
79
|
+
})
|
|
80
|
+
|
|
81
|
+
function MenuColumn({ block }: { block: BlockInstance }): JSX.Element | null {
|
|
82
|
+
const menu = useMenu(String(block.settings.menu ?? ''))
|
|
83
|
+
const t = useTranslate()
|
|
84
|
+
if (!menu) return null
|
|
85
|
+
const heading = String(block.settings.heading ?? '') || menu.title
|
|
86
|
+
return (
|
|
87
|
+
<nav className="st-foot__col" aria-label={heading || t('starter.footer.menu')}>
|
|
88
|
+
{heading ? <h2 className="st-foot__heading">{heading}</h2> : null}
|
|
89
|
+
<ul>
|
|
90
|
+
{menu.items.map((i) => (
|
|
91
|
+
<li key={`${i.title}-${i.url}`}>
|
|
92
|
+
<a href={i.url ?? '/'}>{i.title}</a>
|
|
93
|
+
</li>
|
|
94
|
+
))}
|
|
95
|
+
</ul>
|
|
96
|
+
</nav>
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function Colophon({ blocks }: { blocks: BlockInstance[] }): JSX.Element {
|
|
101
|
+
const shop = useShop()
|
|
102
|
+
const t = useTranslate()
|
|
103
|
+
return (
|
|
104
|
+
<footer className="st-foot">
|
|
105
|
+
<div className="st-foot__cols">
|
|
106
|
+
{blocks.map((b, i) =>
|
|
107
|
+
b.type === 'footer-brand' ? (
|
|
108
|
+
<div key={i} className="st-foot__brand">
|
|
109
|
+
<p className="st-foot__name">{shop.name}</p>
|
|
110
|
+
{b.settings.tagline ? <p className="st-foot__tagline">{String(b.settings.tagline)}</p> : null}
|
|
111
|
+
</div>
|
|
112
|
+
) : (
|
|
113
|
+
<MenuColumn key={i} block={b} />
|
|
114
|
+
),
|
|
115
|
+
)}
|
|
116
|
+
</div>
|
|
117
|
+
<p className="st-foot__legal">{t('starter.footer.rights', { name: shop.name })}</p>
|
|
118
|
+
</footer>
|
|
119
|
+
)
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
export const footer = defineSection({
|
|
123
|
+
type: 'footer',
|
|
124
|
+
title: 'Footer',
|
|
125
|
+
description: 'The shop name, menu columns and the legal line.',
|
|
126
|
+
category: 'chrome',
|
|
127
|
+
zone: 'footer',
|
|
128
|
+
settings: {},
|
|
129
|
+
blocks: [footerBrand, footerMenu],
|
|
130
|
+
ai: [ai.footerMenu('menu', { block: 'footer-menu' }), ai.footerBrand({ block: 'footer-brand' })],
|
|
131
|
+
component: Colophon,
|
|
132
|
+
})
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/** Starter's commerce sections: product, recommendations, collection, search, cart and the account page. */
|
|
2
|
+
import {
|
|
3
|
+
AccountSlot,
|
|
4
|
+
AddToCart,
|
|
5
|
+
CartLine,
|
|
6
|
+
CartLineDecrement,
|
|
7
|
+
CartLineIncrement,
|
|
8
|
+
CartLineQuantity,
|
|
9
|
+
CartLineRemove,
|
|
10
|
+
CheckoutButton,
|
|
11
|
+
CollectionProvider,
|
|
12
|
+
FacetFilters,
|
|
13
|
+
Image,
|
|
14
|
+
Pagination,
|
|
15
|
+
ProductForm,
|
|
16
|
+
ProductPrice,
|
|
17
|
+
ProductQuantity,
|
|
18
|
+
SearchForm,
|
|
19
|
+
SortSelect,
|
|
20
|
+
VariantPicker,
|
|
21
|
+
defineSection,
|
|
22
|
+
field,
|
|
23
|
+
formatMoney,
|
|
24
|
+
useCart,
|
|
25
|
+
useRecommendations,
|
|
26
|
+
useSearch,
|
|
27
|
+
useTranslate,
|
|
28
|
+
type ProductFormState,
|
|
29
|
+
} from '@tanqory/theme-kit/headless'
|
|
30
|
+
import { Grid } from '../components/parts'
|
|
31
|
+
|
|
32
|
+
function stockLine(p: ProductFormState, t: ReturnType<typeof useTranslate>): string {
|
|
33
|
+
if (!p.variant) return ''
|
|
34
|
+
if (!p.available) return t('product.soldOut')
|
|
35
|
+
if (p.quantityAvailable !== null && p.quantityAvailable <= 5) return t('product.lowStock', { count: p.quantityAvailable })
|
|
36
|
+
return t('product.inStock')
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function ProductDetail({ settings }: { settings: { showVendor: boolean } }): JSX.Element {
|
|
40
|
+
const t = useTranslate()
|
|
41
|
+
return (
|
|
42
|
+
<ProductForm className="st-pdp">
|
|
43
|
+
{(p) =>
|
|
44
|
+
p.product ? (
|
|
45
|
+
<>
|
|
46
|
+
<div className="st-pdp__media">
|
|
47
|
+
<Image image={p.image} className="st-pdp__img" loading="eager" sizes="(max-width: 720px) 100vw, 50vw" fallback={<span className="st-pdp__img st-pdp__img--empty" />} />
|
|
48
|
+
</div>
|
|
49
|
+
<div className="st-pdp__info">
|
|
50
|
+
{settings.showVendor && p.product.vendor ? <p className="st-pdp__vendor">{p.product.vendor}</p> : null}
|
|
51
|
+
<h1 className="st-pdp__title">{p.product.title}</h1>
|
|
52
|
+
<ProductPrice className="st-pdp__price" compareClassName="st-pdp__was" />
|
|
53
|
+
<VariantPicker className="st-pdp__options" optionClassName="st-opt" legendClassName="st-opt__legend" valueClassName="st-chip" />
|
|
54
|
+
<p className="st-pdp__stock" aria-live="polite">
|
|
55
|
+
{stockLine(p, t)}
|
|
56
|
+
</p>
|
|
57
|
+
<div className="st-pdp__buy">
|
|
58
|
+
<ProductQuantity className="st-input st-input--qty" />
|
|
59
|
+
<AddToCart className="st-btn st-btn--solid st-pdp__add" />
|
|
60
|
+
</div>
|
|
61
|
+
{p.product.descriptionHtml ? <div className="st-pdp__desc" dangerouslySetInnerHTML={{ __html: p.product.descriptionHtml }} /> : null}
|
|
62
|
+
</div>
|
|
63
|
+
</>
|
|
64
|
+
) : (
|
|
65
|
+
<p className="st-muted">{t('starter.product.missing')}</p>
|
|
66
|
+
)
|
|
67
|
+
}
|
|
68
|
+
</ProductForm>
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
export const product = defineSection({
|
|
73
|
+
type: 'product',
|
|
74
|
+
title: 'Product',
|
|
75
|
+
description: 'The product: image, title, price, options and add to cart.',
|
|
76
|
+
category: 'products',
|
|
77
|
+
requires: ['product'],
|
|
78
|
+
settings: { showVendor: field.boolean(true, { label: 'Show the brand' }) },
|
|
79
|
+
component: ProductDetail,
|
|
80
|
+
})
|
|
81
|
+
|
|
82
|
+
export const recommendations = defineSection({
|
|
83
|
+
// The data plan's convention: this type loads the product's recommendations in the server render.
|
|
84
|
+
type: 'product-recommendations',
|
|
85
|
+
title: 'Recommendations',
|
|
86
|
+
description: 'Products shoppers buy with this one.',
|
|
87
|
+
category: 'products',
|
|
88
|
+
requires: ['product'],
|
|
89
|
+
settings: { heading: field.text('You may also like', { label: 'Heading' }) },
|
|
90
|
+
presets: [{ name: 'Recommendations' }],
|
|
91
|
+
component: function Recommended({ settings }) {
|
|
92
|
+
const { products } = useRecommendations()
|
|
93
|
+
if (!products.length) return <section className="st-shelf st-shelf--empty" aria-hidden="true" />
|
|
94
|
+
return (
|
|
95
|
+
<section className="st-shelf">
|
|
96
|
+
<div className="st-shelf__head">
|
|
97
|
+
<h2 className="st-shelf__title">{settings.heading}</h2>
|
|
98
|
+
</div>
|
|
99
|
+
<Grid products={products.slice(0, 4)} />
|
|
100
|
+
</section>
|
|
101
|
+
)
|
|
102
|
+
},
|
|
103
|
+
})
|
|
104
|
+
|
|
105
|
+
export const collection = defineSection({
|
|
106
|
+
type: 'collection',
|
|
107
|
+
title: 'Collection',
|
|
108
|
+
description: 'The collection’s products with sort, filters and paging.',
|
|
109
|
+
category: 'products',
|
|
110
|
+
requires: ['collection'],
|
|
111
|
+
settings: { showDescription: field.boolean(true, { label: 'Show the description' }) },
|
|
112
|
+
component: function CollectionPage({ settings }) {
|
|
113
|
+
const t = useTranslate()
|
|
114
|
+
return (
|
|
115
|
+
<CollectionProvider>
|
|
116
|
+
{(c) => (
|
|
117
|
+
<section className="st-plp">
|
|
118
|
+
<header className="st-plp__head">
|
|
119
|
+
<p className="st-plp__kicker">{t('starter.collection.kicker')}</p>
|
|
120
|
+
<h1 className="st-plp__title">{c.collection?.title}</h1>
|
|
121
|
+
{settings.showDescription && c.collection?.description ? <p className="st-plp__desc">{c.collection.description}</p> : null}
|
|
122
|
+
{c.total !== null ? <p className="st-plp__count">{t('collection.productCount', { count: c.total })}</p> : null}
|
|
123
|
+
</header>
|
|
124
|
+
<div className="st-plp__body">
|
|
125
|
+
<aside className="st-plp__filters" aria-label={t('collection.filter')}>
|
|
126
|
+
<SortSelect className="st-sort" labelClassName="st-label" />
|
|
127
|
+
<FacetFilters className="st-facets" facetClassName="st-facet" legendClassName="st-label" valueClassName="st-check" clearClassName="st-link" />
|
|
128
|
+
</aside>
|
|
129
|
+
<div className="st-plp__main">
|
|
130
|
+
{c.products.length ? <Grid products={c.products} busy={c.status === 'loading'} eager={4} /> : <p className="st-muted">{c.filtered ? t('collection.empty') : t('starter.collection.none')}</p>}
|
|
131
|
+
{c.status === 'error' ? <p className="st-muted" role="alert">{t('collection.loadError')}</p> : null}
|
|
132
|
+
<Pagination className="st-pages" nextClassName="st-btn" previousClassName="st-btn" />
|
|
133
|
+
</div>
|
|
134
|
+
</div>
|
|
135
|
+
</section>
|
|
136
|
+
)}
|
|
137
|
+
</CollectionProvider>
|
|
138
|
+
)
|
|
139
|
+
},
|
|
140
|
+
})
|
|
141
|
+
|
|
142
|
+
export const search = defineSection({
|
|
143
|
+
type: 'search',
|
|
144
|
+
title: 'Search results',
|
|
145
|
+
category: 'products',
|
|
146
|
+
requires: ['search'],
|
|
147
|
+
settings: {},
|
|
148
|
+
component: function SearchPage() {
|
|
149
|
+
const s = useSearch()
|
|
150
|
+
const t = useTranslate()
|
|
151
|
+
return (
|
|
152
|
+
<section className="st-results">
|
|
153
|
+
<h1 className="st-results__title">{t('search.search')}</h1>
|
|
154
|
+
<SearchForm className="st-find st-find--page" inputClassName="st-find__input" buttonClassName="st-btn" resultsClassName="st-find__results" />
|
|
155
|
+
{s.query ? <p className="st-results__count" role="status">{s.products.length ? t('search.results', { count: s.total ?? s.products.length, query: s.query }) : t('search.none', { query: s.query })}</p> : null}
|
|
156
|
+
{s.products.length ? <Grid products={s.products} eager={4} /> : null}
|
|
157
|
+
</section>
|
|
158
|
+
)
|
|
159
|
+
},
|
|
160
|
+
})
|
|
161
|
+
|
|
162
|
+
export const cart = defineSection({
|
|
163
|
+
type: 'cart',
|
|
164
|
+
title: 'Cart',
|
|
165
|
+
category: 'cart',
|
|
166
|
+
requires: ['cart'],
|
|
167
|
+
settings: {},
|
|
168
|
+
component: function CartPage() {
|
|
169
|
+
const c = useCart()
|
|
170
|
+
const t = useTranslate()
|
|
171
|
+
return (
|
|
172
|
+
<section className="st-cart">
|
|
173
|
+
<h1 className="st-cart__title">{t('cart.title')}</h1>
|
|
174
|
+
{c.loadError && !c.ready ? <p className="st-muted" role="status">{t('cart.loadError')}</p> : null}
|
|
175
|
+
{c.lines.length === 0 ? (
|
|
176
|
+
<div className="st-cart__empty">
|
|
177
|
+
<p>{t('cart.empty')}</p>
|
|
178
|
+
<a className="st-btn" href="/collections/all">
|
|
179
|
+
{t('starter.cart.continue')}
|
|
180
|
+
</a>
|
|
181
|
+
</div>
|
|
182
|
+
) : (
|
|
183
|
+
<>
|
|
184
|
+
<ul className="st-lines">
|
|
185
|
+
{c.lines.map((line) => (
|
|
186
|
+
<CartLine key={line.id} line={line} className="st-line">
|
|
187
|
+
{(l) => (
|
|
188
|
+
<>
|
|
189
|
+
<Image image={line.variant.image} alt="" className="st-line__img" fallback={<span className="st-line__img st-line__img--empty" />} />
|
|
190
|
+
<div className="st-line__info">
|
|
191
|
+
<a className="st-line__title" href={line.product.url}>
|
|
192
|
+
{line.product.title}
|
|
193
|
+
</a>
|
|
194
|
+
{line.variant.title && line.variant.title !== 'Default Title' ? <p className="st-muted">{line.variant.title}</p> : null}
|
|
195
|
+
<p className="st-muted">{formatMoney(line.variant.price)}</p>
|
|
196
|
+
{l.refusal ? <p role="alert">{t('cart.limitReached', { max: l.refusal.maxQuantity ?? line.quantity })}</p> : l.failed ? <p role="alert">{t('cart.lineFailed')}</p> : null}
|
|
197
|
+
</div>
|
|
198
|
+
<div className="st-line__qty">
|
|
199
|
+
<CartLineDecrement className="st-step" />
|
|
200
|
+
<CartLineQuantity className="st-input st-input--qty" />
|
|
201
|
+
<CartLineIncrement className="st-step" />
|
|
202
|
+
</div>
|
|
203
|
+
<p className="st-line__total">{formatMoney(line.cost.total)}</p>
|
|
204
|
+
<CartLineRemove className="st-link" />
|
|
205
|
+
</>
|
|
206
|
+
)}
|
|
207
|
+
</CartLine>
|
|
208
|
+
))}
|
|
209
|
+
</ul>
|
|
210
|
+
<div className="st-cart__summary">
|
|
211
|
+
<p className="st-cart__row">
|
|
212
|
+
<span>{t('cart.subtotal')}</span> <span>{formatMoney(c.subtotal)}</span>
|
|
213
|
+
</p>
|
|
214
|
+
<p className="st-cart__row st-cart__row--total">
|
|
215
|
+
<span>{t('cart.total')}</span> <span>{formatMoney(c.total)}</span>
|
|
216
|
+
</p>
|
|
217
|
+
<p className="st-muted">{t('starter.cart.taxes')}</p>
|
|
218
|
+
<CheckoutButton className="st-btn st-btn--solid st-cart__checkout" />
|
|
219
|
+
</div>
|
|
220
|
+
</>
|
|
221
|
+
)}
|
|
222
|
+
</section>
|
|
223
|
+
)
|
|
224
|
+
},
|
|
225
|
+
})
|
|
226
|
+
|
|
227
|
+
export const account = defineSection({
|
|
228
|
+
type: 'account',
|
|
229
|
+
title: 'Account',
|
|
230
|
+
category: 'account',
|
|
231
|
+
requires: ['customer'],
|
|
232
|
+
settings: {},
|
|
233
|
+
component: function AccountPage() {
|
|
234
|
+
const t = useTranslate()
|
|
235
|
+
return (
|
|
236
|
+
<section className="st-account">
|
|
237
|
+
<h1 className="st-account__title">{t('account.title')}</h1>
|
|
238
|
+
<AccountSlot className="st-account__frame" />
|
|
239
|
+
</section>
|
|
240
|
+
)
|
|
241
|
+
},
|
|
242
|
+
})
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/** Starter's content sections: a page, the contact form, the journal (blog), an article and the 404 page. */
|
|
2
|
+
import { ContactForm, defineSection, field, useArticle, useBlog, usePageContent, useTranslate } from '@tanqory/theme-kit/headless'
|
|
3
|
+
|
|
4
|
+
export const page = defineSection({
|
|
5
|
+
type: 'page',
|
|
6
|
+
title: 'Page',
|
|
7
|
+
category: 'content',
|
|
8
|
+
requires: ['page'],
|
|
9
|
+
settings: {},
|
|
10
|
+
component: function PageBody() {
|
|
11
|
+
const p = usePageContent()
|
|
12
|
+
if (!p) return <section className="st-page" />
|
|
13
|
+
return (
|
|
14
|
+
<article className="st-page">
|
|
15
|
+
<h1 className="st-page__title">{p.title}</h1>
|
|
16
|
+
<div className="st-prose" dangerouslySetInnerHTML={{ __html: p.html }} />
|
|
17
|
+
</article>
|
|
18
|
+
)
|
|
19
|
+
},
|
|
20
|
+
})
|
|
21
|
+
|
|
22
|
+
export const contact = defineSection({
|
|
23
|
+
type: 'contact-form',
|
|
24
|
+
title: 'Contact form',
|
|
25
|
+
description: 'A message form that reaches the store.',
|
|
26
|
+
category: 'forms',
|
|
27
|
+
settings: { heading: field.text('Contact us', { label: 'Heading' }) },
|
|
28
|
+
presets: [{ name: 'Contact form' }],
|
|
29
|
+
component: ({ settings }) => (
|
|
30
|
+
<section className="st-contact">
|
|
31
|
+
<h2 className="st-contact__title">{settings.heading}</h2>
|
|
32
|
+
<ContactForm className="st-form" inputClassName="st-input" labelClassName="st-label" buttonClassName="st-btn st-btn--solid" messageClassName="st-form__msg" />
|
|
33
|
+
</section>
|
|
34
|
+
),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
export const blog = defineSection({
|
|
38
|
+
type: 'blog',
|
|
39
|
+
title: 'Blog',
|
|
40
|
+
category: 'content',
|
|
41
|
+
requires: ['blog'],
|
|
42
|
+
settings: {},
|
|
43
|
+
component: function Journal() {
|
|
44
|
+
const b = useBlog()
|
|
45
|
+
const t = useTranslate()
|
|
46
|
+
if (!b) return <section className="st-journal" />
|
|
47
|
+
return (
|
|
48
|
+
<section className="st-journal">
|
|
49
|
+
<h1 className="st-journal__title">{b.title}</h1>
|
|
50
|
+
<ul className="st-journal__list">
|
|
51
|
+
{b.articles.map((a) => (
|
|
52
|
+
<li key={a.id} className="st-journal__item">
|
|
53
|
+
<a className="st-journal__link" href={a.url}>
|
|
54
|
+
<span className="st-journal__name">{a.title}</span>
|
|
55
|
+
{a.excerpt ? <span className="st-journal__excerpt">{a.excerpt}</span> : null}
|
|
56
|
+
<span className="st-journal__more">{t('starter.journal.read')}</span>
|
|
57
|
+
</a>
|
|
58
|
+
</li>
|
|
59
|
+
))}
|
|
60
|
+
</ul>
|
|
61
|
+
</section>
|
|
62
|
+
)
|
|
63
|
+
},
|
|
64
|
+
})
|
|
65
|
+
|
|
66
|
+
export const article = defineSection({
|
|
67
|
+
type: 'article',
|
|
68
|
+
title: 'Article',
|
|
69
|
+
category: 'content',
|
|
70
|
+
requires: ['article'],
|
|
71
|
+
settings: {},
|
|
72
|
+
component: function Story() {
|
|
73
|
+
const a = useArticle()
|
|
74
|
+
const b = useBlog()
|
|
75
|
+
const t = useTranslate()
|
|
76
|
+
if (!a) return <article className="st-story" />
|
|
77
|
+
return (
|
|
78
|
+
<article className="st-story">
|
|
79
|
+
{b ? (
|
|
80
|
+
<a className="st-story__back" href={b.url}>
|
|
81
|
+
{t('starter.journal.back', { blog: b.title })}
|
|
82
|
+
</a>
|
|
83
|
+
) : null}
|
|
84
|
+
<h1 className="st-story__title">{a.title}</h1>
|
|
85
|
+
{a.author ? <p className="st-muted">{t('starter.journal.by', { author: a.author })}</p> : null}
|
|
86
|
+
<div className="st-prose" dangerouslySetInnerHTML={{ __html: a.contentHtml ?? '' }} />
|
|
87
|
+
</article>
|
|
88
|
+
)
|
|
89
|
+
},
|
|
90
|
+
})
|
|
91
|
+
|
|
92
|
+
export const notFound = defineSection({
|
|
93
|
+
// The runtime renders this type as the body of every 404 page (an unknown product, collection, page, blog).
|
|
94
|
+
type: 'not-found',
|
|
95
|
+
title: 'Not found',
|
|
96
|
+
category: 'content',
|
|
97
|
+
settings: {},
|
|
98
|
+
component: function Lost() {
|
|
99
|
+
const t = useTranslate()
|
|
100
|
+
return (
|
|
101
|
+
<section className="st-lost">
|
|
102
|
+
<p className="st-hero__kicker">404</p>
|
|
103
|
+
<h1 className="st-lost__title">{t('starter.notFound.title')}</h1>
|
|
104
|
+
<p className="st-muted">{t('starter.notFound.body')}</p>
|
|
105
|
+
<a className="st-btn" href="/">
|
|
106
|
+
{t('starter.notFound.home')}
|
|
107
|
+
</a>
|
|
108
|
+
</section>
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
})
|
|
@@ -0,0 +1,107 @@
|
|
|
1
|
+
/** Home page sections: hero, product grid, rich text, newsletter. */
|
|
2
|
+
import { Image, NewsletterForm, ai, defineSection, field, useCollection, useTranslate } from '@tanqory/theme-kit/headless'
|
|
3
|
+
import { Grid, cx } from '../components/parts'
|
|
4
|
+
|
|
5
|
+
export const hero = defineSection({
|
|
6
|
+
type: 'hero',
|
|
7
|
+
title: 'Hero',
|
|
8
|
+
description: 'A heading, a short line, an optional image and one link.',
|
|
9
|
+
category: 'editorial',
|
|
10
|
+
settings: {
|
|
11
|
+
kicker: field.text('Welcome', { label: 'Kicker' }),
|
|
12
|
+
heading: field.text('Our shop', { label: 'Heading' }),
|
|
13
|
+
body: field.richtext('', { label: 'Text' }),
|
|
14
|
+
image: field.resource('image', '', { label: 'Image' }),
|
|
15
|
+
buttonLabel: field.text('Shop all', { label: 'Button label' }),
|
|
16
|
+
buttonLink: field.url('/collections/all', { label: 'Button link' }),
|
|
17
|
+
},
|
|
18
|
+
presets: [{ name: 'Hero', settings: { kicker: 'Welcome', heading: 'Our shop' } }],
|
|
19
|
+
ai: ai.hero({ heading: 'heading', subheading: 'kicker', image: 'image', button: 'buttonLabel', link: 'buttonLink' }),
|
|
20
|
+
component: ({ settings }) => (
|
|
21
|
+
<section className={cx('st-hero', settings.image && 'st-hero--image')}>
|
|
22
|
+
{settings.image ? <Image image={settings.image} alt="" className="st-hero__img" loading="eager" /> : null}
|
|
23
|
+
<div className="st-hero__copy">
|
|
24
|
+
{settings.kicker ? <p className="st-hero__kicker">{settings.kicker}</p> : null}
|
|
25
|
+
<h1 className="st-hero__title">{settings.heading}</h1>
|
|
26
|
+
{settings.body ? <div className="st-hero__body" dangerouslySetInnerHTML={{ __html: settings.body }} /> : null}
|
|
27
|
+
{settings.buttonLabel && settings.buttonLink ? (
|
|
28
|
+
<a className="st-btn" href={settings.buttonLink}>
|
|
29
|
+
{settings.buttonLabel}
|
|
30
|
+
</a>
|
|
31
|
+
) : null}
|
|
32
|
+
</div>
|
|
33
|
+
</section>
|
|
34
|
+
),
|
|
35
|
+
})
|
|
36
|
+
|
|
37
|
+
function Shelf({ settings }: { settings: { heading: string; collection: string; count: number } }): JSX.Element {
|
|
38
|
+
const c = useCollection(settings.collection)
|
|
39
|
+
const t = useTranslate()
|
|
40
|
+
const products = c.products.slice(0, settings.count)
|
|
41
|
+
return (
|
|
42
|
+
<section className="st-shelf">
|
|
43
|
+
<div className="st-shelf__head">
|
|
44
|
+
<h2 className="st-shelf__title">{settings.heading || c.collection?.title}</h2>
|
|
45
|
+
{c.collection ? (
|
|
46
|
+
<a className="st-shelf__all" href={c.collection.url}>
|
|
47
|
+
{t('starter.shelf.viewAll')}
|
|
48
|
+
</a>
|
|
49
|
+
) : null}
|
|
50
|
+
</div>
|
|
51
|
+
{products.length ? <Grid products={products} eager={4} /> : <p className="st-muted">{t('starter.shelf.empty')}</p>}
|
|
52
|
+
</section>
|
|
53
|
+
)
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export const featuredCollection = defineSection({
|
|
57
|
+
type: 'featured-collection',
|
|
58
|
+
title: 'Product grid',
|
|
59
|
+
description: 'A row of products from one collection.',
|
|
60
|
+
category: 'products',
|
|
61
|
+
settings: {
|
|
62
|
+
heading: field.text('Products', { label: 'Heading' }),
|
|
63
|
+
collection: field.resource('collection', 'all', { label: 'Collection' }),
|
|
64
|
+
count: field.range(8, 4, 16, 4, { label: 'Products to show' }),
|
|
65
|
+
},
|
|
66
|
+
presets: [{ name: 'Product grid', settings: { heading: 'Products', collection: 'all' } }],
|
|
67
|
+
ai: ai.productGrid('collection', { heading: 'heading' }),
|
|
68
|
+
component: Shelf,
|
|
69
|
+
})
|
|
70
|
+
|
|
71
|
+
export const note = defineSection({
|
|
72
|
+
type: 'rich-text',
|
|
73
|
+
title: 'Rich text',
|
|
74
|
+
description: 'A heading and a paragraph, set narrow.',
|
|
75
|
+
category: 'editorial',
|
|
76
|
+
settings: {
|
|
77
|
+
heading: field.text('About us', { label: 'Heading' }),
|
|
78
|
+
body: field.richtext('<p>Tell shoppers who you are and what you make.</p>', { label: 'Text' }),
|
|
79
|
+
},
|
|
80
|
+
presets: [{ name: 'Rich text' }],
|
|
81
|
+
ai: ai.richText({ heading: 'heading', body: 'body' }),
|
|
82
|
+
component: ({ settings }) => (
|
|
83
|
+
<section className="st-note">
|
|
84
|
+
{settings.heading ? <h2 className="st-note__title">{settings.heading}</h2> : null}
|
|
85
|
+
{settings.body ? <div className="st-note__body" dangerouslySetInnerHTML={{ __html: settings.body }} /> : null}
|
|
86
|
+
</section>
|
|
87
|
+
),
|
|
88
|
+
})
|
|
89
|
+
|
|
90
|
+
export const letters = defineSection({
|
|
91
|
+
type: 'newsletter',
|
|
92
|
+
title: 'Newsletter',
|
|
93
|
+
description: 'An email sign-up for the store’s newsletter.',
|
|
94
|
+
category: 'forms',
|
|
95
|
+
settings: {
|
|
96
|
+
heading: field.text('Stay in touch', { label: 'Heading' }),
|
|
97
|
+
body: field.textarea('News and offers, now and then.', { label: 'Text' }),
|
|
98
|
+
},
|
|
99
|
+
presets: [{ name: 'Newsletter' }],
|
|
100
|
+
component: ({ settings }) => (
|
|
101
|
+
<section className="st-letters">
|
|
102
|
+
<h2 className="st-letters__title">{settings.heading}</h2>
|
|
103
|
+
{settings.body ? <p className="st-letters__body">{settings.body}</p> : null}
|
|
104
|
+
<NewsletterForm className="st-letters__form" inputClassName="st-input" buttonClassName="st-btn st-btn--solid" messageClassName="st-letters__msg" />
|
|
105
|
+
</section>
|
|
106
|
+
),
|
|
107
|
+
})
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** The theme settings (the editor's Theme panel). Replace with your theme's own. */
|
|
2
|
+
import { defineSettings } from '@tanqory/theme-kit/headless'
|
|
3
|
+
|
|
4
|
+
export const settings = defineSettings({
|
|
5
|
+
scheme: {
|
|
6
|
+
type: 'select',
|
|
7
|
+
label: 'Colour scheme',
|
|
8
|
+
group: 'Colours',
|
|
9
|
+
default: 'light',
|
|
10
|
+
options: [
|
|
11
|
+
{ value: 'light', label: 'Light' },
|
|
12
|
+
{ value: 'dark', label: 'Dark' },
|
|
13
|
+
],
|
|
14
|
+
},
|
|
15
|
+
})
|