@tanqory/partner-cli 0.0.0-stage → 0.1.0-alpha.2
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 +66 -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 +2420 -0
- package/package.json +59 -4
- package/starter/LICENSE +18 -0
- package/starter/README.md +44 -0
- package/starter/config/settings.json +5 -0
- package/starter/gitignore +3 -0
- package/starter/locales/en.json +22 -0
- package/starter/locales/en.schema.json +69 -0
- package/starter/locales/th.json +22 -0
- package/starter/locales/th.schema.json +69 -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 +211 -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 +115 -0
- package/starter/src/sections/editorial.tsx +232 -0
- package/starter/src/settings.ts +12 -0
- package/starter/src/styles/theme.css +241 -0
- package/starter/src/templates.ts +14 -0
- package/starter/src/theme.tsx +86 -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 +116 -0
- package/starter/templates/page.contact.json +22 -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,32 @@
|
|
|
1
|
+
/** Starter's small shared parts: the product card and the section heading. All markup and classes are Starter's. */
|
|
2
|
+
import { Image, formatMoney, useTranslate, type Product } from '@tanqory/theme-kit/headless'
|
|
3
|
+
|
|
4
|
+
export const cx = (...names: Array<string | false | null | undefined>): string => names.filter(Boolean).join(' ')
|
|
5
|
+
|
|
6
|
+
export function ProductCard({ product, eager = false }: { product: Product; eager?: boolean }): JSX.Element {
|
|
7
|
+
const t = useTranslate()
|
|
8
|
+
const min = product.priceRange.min
|
|
9
|
+
const ranged = product.priceRange.max.amount > min.amount
|
|
10
|
+
return (
|
|
11
|
+
<li className="st-card">
|
|
12
|
+
<a className="st-card__link" href={product.url}>
|
|
13
|
+
<span className="st-card__frame">
|
|
14
|
+
<Image image={product.featuredImage} alt="" className="st-card__img" loading={eager ? 'eager' : 'lazy'} sizes="(max-width: 720px) 50vw, 25vw" fallback={<span className="st-card__img st-card__img--empty" />} />
|
|
15
|
+
</span>
|
|
16
|
+
<span className="st-card__title">{product.title}</span>
|
|
17
|
+
<span className="st-card__price">
|
|
18
|
+
{ranged ? t('starter.price.from', { price: formatMoney(min) }) : formatMoney(min)}
|
|
19
|
+
{product.available ? null : <span className="st-card__flag"> · {t('product.soldOut')}</span>}
|
|
20
|
+
</span>
|
|
21
|
+
</a>
|
|
22
|
+
</li>
|
|
23
|
+
)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export function Grid({ products, busy, eager = 0 }: { products: readonly Product[]; busy?: boolean; eager?: number }): JSX.Element {
|
|
27
|
+
return (
|
|
28
|
+
<ul className="st-grid" aria-busy={busy || undefined}>
|
|
29
|
+
{products.map((p, i) => <ProductCard key={p.id} product={p} eager={i < eager} />)}
|
|
30
|
+
</ul>
|
|
31
|
+
)
|
|
32
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Starter's serve entry (Theme ABI v2 §1): `render(request, ctx)` + `manifest`, built into one file with no imports.
|
|
3
|
+
* The render is the kit's; `storefront` turns on what the headless API needs, and `plan.localization` lists the
|
|
4
|
+
* store's countries for the header's market selector.
|
|
5
|
+
*/
|
|
6
|
+
import type { ThemeManifest } from '@tanqory/theme-abi'
|
|
7
|
+
import { createRender } from '@tanqory/theme-kit/server'
|
|
8
|
+
import { bundle } from './bundle'
|
|
9
|
+
import manifestJson from './generated/manifest.json'
|
|
10
|
+
|
|
11
|
+
export const manifest = manifestJson as unknown as ThemeManifest
|
|
12
|
+
|
|
13
|
+
export const render = createRender({ manifest, bundle, storefront: { plan: { localization: true, recommendations: true } } })
|
|
@@ -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: 't:labels.header',
|
|
57
|
+
description: 't:descriptions.the_shop_name_the_main_menu',
|
|
58
|
+
category: 'chrome',
|
|
59
|
+
zone: 'header',
|
|
60
|
+
settings: {
|
|
61
|
+
menu: field.resource('menu', 'main-menu', { label: 't:labels.menu' }),
|
|
62
|
+
tagline: field.text('', { label: 't:labels.tagline' }),
|
|
63
|
+
// The data plan's convention: the masthead shows the market selector.
|
|
64
|
+
showLocale: field.boolean(true, { label: 't:labels.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: 't:labels.menu_column',
|
|
73
|
+
settings: { heading: field.text('Explore', { label: 't:labels.heading' }), menu: field.resource('menu', 'footer', { label: 't:labels.menu' }) },
|
|
74
|
+
})
|
|
75
|
+
const footerBrand = defineBlock({
|
|
76
|
+
type: 'footer-brand',
|
|
77
|
+
title: 't:labels.brand',
|
|
78
|
+
settings: { tagline: field.textarea('Thank you for shopping with us.', { label: 't:labels.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: 't:labels.footer',
|
|
125
|
+
description: 't:descriptions.the_shop_name_menu_columns_and',
|
|
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: 't:labels.product',
|
|
75
|
+
description: 't:descriptions.the_product_image_title_price_options',
|
|
76
|
+
category: 'products',
|
|
77
|
+
requires: ['product'],
|
|
78
|
+
settings: { showVendor: field.boolean(true, { label: 't:labels.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: 't:labels.recommendations',
|
|
86
|
+
description: 't:descriptions.products_shoppers_buy_with_this_one',
|
|
87
|
+
category: 'products',
|
|
88
|
+
requires: ['product'],
|
|
89
|
+
settings: { heading: field.text('You may also like', { label: 't:labels.heading' }) },
|
|
90
|
+
presets: [{ name: 't:labels.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: 't:labels.collection',
|
|
108
|
+
description: 't:descriptions.the_collections_products_with_sort_filters',
|
|
109
|
+
category: 'products',
|
|
110
|
+
requires: ['collection'],
|
|
111
|
+
settings: { showDescription: field.boolean(true, { label: 't:labels.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: 't:labels.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: 't:labels.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: 't:labels.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,115 @@
|
|
|
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: 't:labels.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: 't:labels.contact_form',
|
|
25
|
+
description: 't:descriptions.a_message_form_that_reaches_the',
|
|
26
|
+
category: 'forms',
|
|
27
|
+
settings: {
|
|
28
|
+
heading: field.text('Contact us', { label: 't:labels.heading' }),
|
|
29
|
+
intro: field.textarea('Write to us and we will answer within one working day.', { label: 't:labels.text_above_the_form' }),
|
|
30
|
+
},
|
|
31
|
+
presets: [{ name: 't:labels.contact_form', settings: { heading: 'Contact us', intro: 'Write to us and we will answer within one working day.' } }],
|
|
32
|
+
component: ({ settings }) => (
|
|
33
|
+
<section className="st-contact">
|
|
34
|
+
{settings.heading ? <h2 className="st-contact__title">{settings.heading}</h2> : null}
|
|
35
|
+
{settings.intro ? <p className="st-muted">{settings.intro}</p> : null}
|
|
36
|
+
<ContactForm className="st-form" inputClassName="st-input" labelClassName="st-label" buttonClassName="st-btn st-btn--solid" messageClassName="st-form__msg" />
|
|
37
|
+
</section>
|
|
38
|
+
),
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
export const blog = defineSection({
|
|
42
|
+
type: 'blog',
|
|
43
|
+
title: 't:labels.blog',
|
|
44
|
+
category: 'content',
|
|
45
|
+
requires: ['blog'],
|
|
46
|
+
settings: {},
|
|
47
|
+
component: function Journal() {
|
|
48
|
+
const b = useBlog()
|
|
49
|
+
const t = useTranslate()
|
|
50
|
+
if (!b) return <section className="st-journal" />
|
|
51
|
+
return (
|
|
52
|
+
<section className="st-journal">
|
|
53
|
+
<h1 className="st-journal__title">{b.title}</h1>
|
|
54
|
+
<ul className="st-journal__list">
|
|
55
|
+
{b.articles.map((a) => (
|
|
56
|
+
<li key={a.id} className="st-journal__item">
|
|
57
|
+
<a className="st-journal__link" href={a.url}>
|
|
58
|
+
<span className="st-journal__name">{a.title}</span>
|
|
59
|
+
{a.excerpt ? <span className="st-journal__excerpt">{a.excerpt}</span> : null}
|
|
60
|
+
<span className="st-journal__more">{t('starter.journal.read')}</span>
|
|
61
|
+
</a>
|
|
62
|
+
</li>
|
|
63
|
+
))}
|
|
64
|
+
</ul>
|
|
65
|
+
</section>
|
|
66
|
+
)
|
|
67
|
+
},
|
|
68
|
+
})
|
|
69
|
+
|
|
70
|
+
export const article = defineSection({
|
|
71
|
+
type: 'article',
|
|
72
|
+
title: 't:labels.article',
|
|
73
|
+
category: 'content',
|
|
74
|
+
requires: ['article'],
|
|
75
|
+
settings: {},
|
|
76
|
+
component: function Story() {
|
|
77
|
+
const a = useArticle()
|
|
78
|
+
const b = useBlog()
|
|
79
|
+
const t = useTranslate()
|
|
80
|
+
if (!a) return <article className="st-story" />
|
|
81
|
+
return (
|
|
82
|
+
<article className="st-story">
|
|
83
|
+
{b ? (
|
|
84
|
+
<a className="st-story__back" href={b.url}>
|
|
85
|
+
{t('starter.journal.back', { blog: b.title })}
|
|
86
|
+
</a>
|
|
87
|
+
) : null}
|
|
88
|
+
<h1 className="st-story__title">{a.title}</h1>
|
|
89
|
+
{a.author ? <p className="st-muted">{t('starter.journal.by', { author: a.author })}</p> : null}
|
|
90
|
+
<div className="st-prose" dangerouslySetInnerHTML={{ __html: a.contentHtml ?? '' }} />
|
|
91
|
+
</article>
|
|
92
|
+
)
|
|
93
|
+
},
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
export const notFound = defineSection({
|
|
97
|
+
// The runtime renders this type as the body of every 404 page (an unknown product, collection, page, blog).
|
|
98
|
+
type: 'not-found',
|
|
99
|
+
title: 't:labels.not_found',
|
|
100
|
+
category: 'content',
|
|
101
|
+
settings: {},
|
|
102
|
+
component: function Lost() {
|
|
103
|
+
const t = useTranslate()
|
|
104
|
+
return (
|
|
105
|
+
<section className="st-lost">
|
|
106
|
+
<p className="st-hero__kicker">404</p>
|
|
107
|
+
<h1 className="st-lost__title">{t('starter.notFound.title')}</h1>
|
|
108
|
+
<p className="st-muted">{t('starter.notFound.body')}</p>
|
|
109
|
+
<a className="st-btn" href="/">
|
|
110
|
+
{t('starter.notFound.home')}
|
|
111
|
+
</a>
|
|
112
|
+
</section>
|
|
113
|
+
)
|
|
114
|
+
},
|
|
115
|
+
})
|