create-magic-storefront 0.4.0 → 0.6.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.
Files changed (143) hide show
  1. package/package.json +3 -3
  2. package/template/.claude/skills/storefront-design/SKILL.md +14 -10
  3. package/template/.env.example +5 -0
  4. package/template/AGENTS.md +36 -17
  5. package/template/DESIGN.md +117 -0
  6. package/template/PAGES.md +116 -29
  7. package/template/README.md +15 -3
  8. package/template/app/account/addresses/page.tsx +16 -0
  9. package/template/app/account/layout.tsx +14 -0
  10. package/template/app/account/loading.tsx +15 -0
  11. package/template/app/account/orders/[id]/page.tsx +15 -0
  12. package/template/app/account/page.tsx +12 -244
  13. package/template/app/account/profile/page.tsx +16 -0
  14. package/template/app/blog/(index)/loading.tsx +22 -0
  15. package/template/app/blog/{page.tsx → (index)/page.tsx} +42 -25
  16. package/template/app/blog/[handle]/page.tsx +92 -56
  17. package/template/app/blog/author/[handle]/page.tsx +1 -1
  18. package/template/app/cart/layout.tsx +14 -0
  19. package/template/app/cart/page.tsx +49 -101
  20. package/template/app/checkout/layout.tsx +14 -0
  21. package/template/app/checkout/page.tsx +98 -281
  22. package/template/app/collections/[handle]/layout.tsx +20 -0
  23. package/template/app/collections/[handle]/loading.tsx +23 -0
  24. package/template/app/collections/[handle]/page.tsx +131 -15
  25. package/template/app/collections/page.tsx +49 -0
  26. package/template/app/contacts/page.tsx +196 -0
  27. package/template/app/error.tsx +19 -8
  28. package/template/app/fonts/OFL.txt +93 -0
  29. package/template/app/fonts/index.ts +14 -0
  30. package/template/app/fonts/onest-variable.woff2 +0 -0
  31. package/template/app/globals.css +14 -518
  32. package/template/app/layout.tsx +74 -50
  33. package/template/app/not-found.tsx +34 -4
  34. package/template/app/page.tsx +1 -1
  35. package/template/app/pages/[handle]/page.tsx +1 -1
  36. package/template/app/products/[handle]/layout.tsx +20 -0
  37. package/template/app/products/[handle]/loading.tsx +25 -0
  38. package/template/app/products/[handle]/page.tsx +112 -15
  39. package/template/app/providers.tsx +20 -7
  40. package/template/app/search/loading.tsx +12 -0
  41. package/template/app/search/page.tsx +138 -25
  42. package/template/app/sitemap.ts +5 -1
  43. package/template/app/storefront-api/[...path]/route.ts +11 -66
  44. package/template/app/styles/base.css +138 -0
  45. package/template/app/styles/components.css +1108 -0
  46. package/template/app/styles/layout.css +455 -0
  47. package/template/app/styles/pages.css +1839 -0
  48. package/template/app/styles/reset.css +55 -0
  49. package/template/app/styles/sections.css +415 -0
  50. package/template/app/styles/tokens.css +167 -0
  51. package/template/app/styles/utilities.css +37 -0
  52. package/template/app/wishlist/page.tsx +26 -0
  53. package/template/components/account/account-shell.tsx +100 -0
  54. package/template/components/account/addresses.tsx +247 -0
  55. package/template/components/account/order-detail.tsx +281 -0
  56. package/template/components/account/order-list.tsx +94 -0
  57. package/template/components/account/order-status.tsx +19 -0
  58. package/template/components/account/profile.tsx +129 -0
  59. package/template/components/account/sign-in.tsx +164 -0
  60. package/template/components/article-body.tsx +3 -2
  61. package/template/components/article-card.tsx +37 -12
  62. package/template/components/cart/cart-drawer.tsx +149 -0
  63. package/template/components/cart/cart-lines.tsx +89 -0
  64. package/template/components/cart/cart-summary.tsx +191 -0
  65. package/template/components/catalog/catalog-form.tsx +107 -0
  66. package/template/components/catalog/catalog-layout.tsx +82 -0
  67. package/template/components/catalog/facets-shell.tsx +60 -0
  68. package/template/components/catalog/facets.tsx +216 -0
  69. package/template/components/checkout/order-summary.tsx +84 -0
  70. package/template/components/checkout/radio-card.tsx +34 -0
  71. package/template/components/checkout/step-indicator.tsx +56 -0
  72. package/template/components/checkout/steps.tsx +264 -0
  73. package/template/components/checkout/thank-you.tsx +48 -0
  74. package/template/components/checkout/use-checkout.ts +90 -0
  75. package/template/components/footer/site-footer.tsx +132 -0
  76. package/template/components/header/cart-button.tsx +43 -0
  77. package/template/components/header/desktop-nav.tsx +133 -0
  78. package/template/components/header/mobile-menu.tsx +102 -0
  79. package/template/components/header/site-header.tsx +78 -0
  80. package/template/components/page-loading.tsx +20 -0
  81. package/template/components/pager.tsx +3 -1
  82. package/template/components/product/buy-box.tsx +148 -0
  83. package/template/components/product/gallery.tsx +179 -0
  84. package/template/components/product/pre-order-form.tsx +93 -0
  85. package/template/components/product/product-selection.tsx +31 -0
  86. package/template/components/product/recommendations.tsx +26 -0
  87. package/template/components/product/review-list.tsx +159 -0
  88. package/template/components/product/reviews.tsx +80 -0
  89. package/template/components/product/variant-picker.tsx +75 -0
  90. package/template/components/product-card.tsx +103 -0
  91. package/template/components/product-grid.tsx +27 -57
  92. package/template/components/quick-add.tsx +62 -0
  93. package/template/components/search/predictive-search.tsx +282 -0
  94. package/template/components/sections/announcement-bar.tsx +1 -1
  95. package/template/components/sections/banner.tsx +1 -1
  96. package/template/components/sections/collections.tsx +50 -13
  97. package/template/components/sections/deal-of-day.tsx +2 -2
  98. package/template/components/sections/product-shelves.tsx +13 -5
  99. package/template/components/sections/shoppable-stories.tsx +2 -2
  100. package/template/components/sections/store-reviews.tsx +10 -4
  101. package/template/components/share-button.tsx +42 -0
  102. package/template/components/ui/accordion.tsx +35 -0
  103. package/template/components/ui/badge.tsx +20 -0
  104. package/template/components/ui/breadcrumbs.tsx +31 -0
  105. package/template/components/ui/button.tsx +90 -0
  106. package/template/components/ui/drawer.tsx +84 -0
  107. package/template/components/ui/empty-state.tsx +27 -0
  108. package/template/components/ui/field.tsx +33 -0
  109. package/template/components/ui/icon.tsx +112 -0
  110. package/template/components/ui/price.tsx +35 -0
  111. package/template/components/ui/quantity-stepper.tsx +91 -0
  112. package/template/components/ui/rating.tsx +48 -0
  113. package/template/components/ui/skeleton.tsx +46 -0
  114. package/template/components/wishlist/wishlist-view.tsx +134 -0
  115. package/template/lib/article-outline.ts +35 -0
  116. package/template/lib/catalog-params.ts +170 -0
  117. package/template/lib/contacts.ts +34 -0
  118. package/template/lib/errors.ts +29 -0
  119. package/template/lib/i18n.ts +484 -0
  120. package/template/lib/menu.ts +70 -0
  121. package/template/lib/theme-settings.ts +36 -0
  122. package/template/lib/upstream.ts +21 -0
  123. package/template/llms.txt +13 -0
  124. package/template/theme/index.ts +7 -1
  125. package/template/theme/sections/collapsible-content.tsx +75 -0
  126. package/template/theme/sections/collection-list.tsx +32 -4
  127. package/template/theme/sections/featured-collection.tsx +22 -2
  128. package/template/theme/sections/hero.tsx +94 -7
  129. package/template/theme/sections/image-with-text.tsx +19 -3
  130. package/template/theme/sections/multicolumn.tsx +113 -0
  131. package/template/theme/sections/page-content.tsx +10 -4
  132. package/template/theme/sections/product-shelf.tsx +26 -4
  133. package/template/theme/sections/rich-text.tsx +13 -1
  134. package/template/theme/sections/testimonials.tsx +14 -9
  135. package/template/theme/settings.ts +85 -1
  136. package/template/theme/templates/index.json +4 -2
  137. package/template/.screenshots/home-1280.png +0 -0
  138. package/template/.screenshots/home-390.png +0 -0
  139. package/template/.screenshots/home-filled-1280.png +0 -0
  140. package/template/.screenshots/home-filled-390.png +0 -0
  141. package/template/.screenshots/page-1280.png +0 -0
  142. package/template/components/buy-box.tsx +0 -89
  143. package/template/components/cart-link.tsx +0 -15
@@ -1,14 +1,31 @@
1
1
  import type { Metadata } from 'next';
2
+ import Link from 'next/link';
3
+ import { Image } from '@magicstoreai/hydrogen';
2
4
  import { breadcrumbJsonLd, jsonLdScript, pageMeta } from '@magicstoreai/hydrogen/seo';
3
5
  import { CollectionView } from '@/components/analytics-views';
4
- import { Pager } from '@/components/pager';
5
- import { ProductGrid } from '@/components/product-grid';
6
+ import { CatalogLayout } from '@/components/catalog/catalog-layout';
7
+ import { Accordion } from '@/components/ui/accordion';
8
+ import { Breadcrumbs } from '@/components/ui/breadcrumbs';
9
+ import { buttonClass } from '@/components/ui/button';
10
+ import { EmptyState } from '@/components/ui/empty-state';
6
11
  import { api, locale, orNotFound } from '@/lib/api';
12
+ import {
13
+ apiQuery,
14
+ catalogQuery,
15
+ cleared,
16
+ hasFilters,
17
+ parseCatalog,
18
+ type SearchParams,
19
+ } from '@/lib/catalog-params';
7
20
  import { messages } from '@/lib/i18n';
8
21
 
9
- type Props = { params: Promise<{ handle: string }>; searchParams: Promise<{ page?: string }> };
22
+ type Props = { params: Promise<{ handle: string }>; searchParams: Promise<SearchParams> };
23
+ type ProductsQuery = NonNullable<Parameters<typeof api.collectionsProducts>[0]['query']>;
10
24
 
11
- export async function generateMetadata({ params }: Props): Promise<Metadata> {
25
+ /** 24 a page, the API's default: four full rows at desktop width. */
26
+ const PER_PAGE = 24;
27
+
28
+ export async function generateMetadata({ params, searchParams }: Props): Promise<Metadata> {
12
29
  const { handle } = await params;
13
30
  const { data: collection } = await orNotFound(api.collectionsShow({ path: { handle } }));
14
31
  const meta = pageMeta({
@@ -16,16 +33,51 @@ export async function generateMetadata({ params }: Props): Promise<Metadata> {
16
33
  title: collection.title,
17
34
  description: collection.description,
18
35
  });
19
- return { title: meta.title, description: meta.description };
36
+ const filtered = Object.keys(await searchParams).some((key) => key !== 'page');
37
+ return {
38
+ title: meta.title,
39
+ description: meta.description,
40
+ // Filtered and sorted views repeat the collection: keep them out of the index.
41
+ ...(filtered && { robots: { index: false, follow: true } }),
42
+ };
20
43
  }
21
44
 
45
+ /**
46
+ * A collection: its banner (image, title, description, count), its child collections, then the
47
+ * catalog (facets from `collectionsFilters`, sort, active filters, grid, pager), and its FAQ. The
48
+ * URL holds the filters, so every view is a link; what the API does not offer is dropped first
49
+ * (`lib/catalog-params.ts`).
50
+ */
22
51
  export default async function CollectionPage({ params, searchParams }: Props) {
23
52
  const { handle } = await params;
24
- const page = Math.max(1, Number((await searchParams).page) || 1);
25
- const [{ data: collection }, products] = await Promise.all([
53
+ const t = messages(locale);
54
+ const [{ data: collection }, { data: filters }, { data: shop }] = await Promise.all([
26
55
  orNotFound(api.collectionsShow({ path: { handle } })),
27
- orNotFound(api.collectionsProducts({ path: { handle }, query: { page, perPage: 24 } })),
56
+ orNotFound(api.collectionsFilters({ path: { handle } })),
57
+ api.shop(),
58
+ ]);
59
+ const catalog = parseCatalog(await searchParams, filters);
60
+ const [products, children] = await Promise.all([
61
+ orNotFound(
62
+ api.collectionsProducts({
63
+ path: { handle },
64
+ query: { perPage: PER_PAGE, ...apiQuery(catalog) } as ProductsQuery,
65
+ }),
66
+ ),
67
+ collection.hasChildren
68
+ ? api.collectionsIndex({
69
+ // The contract types this filter as an integer while every id is a string: a backend
70
+ // follow-up (magicbot). Until then the string id goes as its number.
71
+ query: { 'filter[parentId]': Number(collection.id), perPage: 50 },
72
+ })
73
+ : null,
28
74
  ]);
75
+ const path = `/collections/${collection.handle}`;
76
+ const crumbs = [
77
+ { name: t.home, href: '/' },
78
+ { name: t.catalog, href: '/collections' },
79
+ { name: collection.title, href: path },
80
+ ];
29
81
 
30
82
  return (
31
83
  <>
@@ -33,17 +85,81 @@ export default async function CollectionPage({ params, searchParams }: Props) {
33
85
  type="application/ld+json"
34
86
  dangerouslySetInnerHTML={{
35
87
  __html: jsonLdScript(
36
- breadcrumbJsonLd([
37
- { name: messages(locale).home, url: '/' },
38
- { name: collection.title, url: `/collections/${collection.handle}` },
39
- ]),
88
+ breadcrumbJsonLd(crumbs.map((crumb) => ({ name: crumb.name, url: crumb.href }))),
40
89
  ),
41
90
  }}
42
91
  />
43
92
  <CollectionView collectionId={collection.id} />
44
- <h1>{collection.title}</h1>
45
- <ProductGrid products={products.data} />
46
- <Pager meta={products.meta.pagination} href={(p) => `/collections/${handle}?page=${p}`} />
93
+ <Breadcrumbs items={crumbs} label={t.breadcrumbs} />
94
+ <header
95
+ className={collection.image ? 'collection-hero collection-hero--image' : 'collection-hero'}
96
+ >
97
+ {collection.image && (
98
+ <div className="collection-hero__media">
99
+ <Image data={collection.image} alt="" loading="eager" />
100
+ </div>
101
+ )}
102
+ <div className="collection-hero__text">
103
+ <h1>{collection.title}</h1>
104
+ {collection.description && (
105
+ <p className="collection-hero__description">{collection.description}</p>
106
+ )}
107
+ </div>
108
+ </header>
109
+ {children && children.data.length > 0 && (
110
+ <nav className="chips collection-children" aria-label={collection.title}>
111
+ {children.data.map((child) => (
112
+ <Link key={child.id} href={`/collections/${child.handle}`}>
113
+ {child.title}
114
+ </Link>
115
+ ))}
116
+ </nav>
117
+ )}
118
+ <CatalogLayout
119
+ filters={filters}
120
+ catalog={catalog}
121
+ products={products}
122
+ path={path}
123
+ money={{ locale, format: shop.moneyFormat }}
124
+ locale={locale}
125
+ t={t}
126
+ empty={
127
+ hasFilters(catalog) ? (
128
+ <EmptyState
129
+ title={t.noMatches}
130
+ icon="filter"
131
+ action={
132
+ <Link href={`${path}${catalogQuery(cleared(catalog))}`} className={buttonClass()}>
133
+ {t.clearAll}
134
+ </Link>
135
+ }
136
+ >
137
+ {t.noMatchesHint}
138
+ </EmptyState>
139
+ ) : (
140
+ <EmptyState
141
+ title={t.collectionEmpty}
142
+ action={
143
+ <Link href="/collections" className={buttonClass({ variant: 'primary' })}>
144
+ {t.shopNow}
145
+ </Link>
146
+ }
147
+ >
148
+ {t.collectionEmptyHint}
149
+ </EmptyState>
150
+ )
151
+ }
152
+ />
153
+ {collection.faq.length > 0 && (
154
+ <section className="collection-faq">
155
+ <h2>{t.faq}</h2>
156
+ {collection.faq.map((entry, index) => (
157
+ <Accordion key={index} title={entry.question}>
158
+ <p>{entry.answer}</p>
159
+ </Accordion>
160
+ ))}
161
+ </section>
162
+ )}
47
163
  </>
48
164
  );
49
165
  }
@@ -0,0 +1,49 @@
1
+ import type { Metadata } from 'next';
2
+ import Link from 'next/link';
3
+ import { pageMeta } from '@magicstoreai/hydrogen/seo';
4
+ import { CollectionTiles } from '@/components/sections/collections';
5
+ import { Breadcrumbs } from '@/components/ui/breadcrumbs';
6
+ import { buttonClass } from '@/components/ui/button';
7
+ import { EmptyState } from '@/components/ui/empty-state';
8
+ import { api, locale } from '@/lib/api';
9
+ import { messages } from '@/lib/i18n';
10
+
11
+ /** The API's ceiling for one page: a shop's top level fits in it. */
12
+ const PER_PAGE = 100;
13
+
14
+ export function generateMetadata(): Metadata {
15
+ const meta = pageMeta({ title: messages(locale).catalog });
16
+ return { title: meta.title, description: meta.description };
17
+ }
18
+
19
+ /** The catalog: every top-level collection as a tile (image, title, number of products). */
20
+ export default async function CollectionsPage() {
21
+ const t = messages(locale);
22
+ const { data: collections } = await api.collectionsIndex({
23
+ query: { 'filter[root]': 'true', perPage: PER_PAGE },
24
+ });
25
+
26
+ return (
27
+ <>
28
+ <Breadcrumbs
29
+ items={[{ name: t.home, href: '/' }, { name: t.catalog }]}
30
+ label={t.breadcrumbs}
31
+ />
32
+ <h1 className="page-title">{t.catalog}</h1>
33
+ {collections.length > 0 ? (
34
+ <CollectionTiles collections={collections} count={t.productsCount} />
35
+ ) : (
36
+ <EmptyState
37
+ title={t.collectionEmpty}
38
+ action={
39
+ <Link href="/search" className={buttonClass({ variant: 'primary' })}>
40
+ {t.search}
41
+ </Link>
42
+ }
43
+ >
44
+ {t.collectionEmptyHint}
45
+ </EmptyState>
46
+ )}
47
+ </>
48
+ );
49
+ }
@@ -0,0 +1,196 @@
1
+ import type { Metadata } from 'next';
2
+ import type { Schema } from '@magicstoreai/storefront-client';
3
+ import { pageMeta } from '@magicstoreai/hydrogen/seo';
4
+ import { Breadcrumbs } from '@/components/ui/breadcrumbs';
5
+ import { EmptyState } from '@/components/ui/empty-state';
6
+ import { Icon } from '@/components/ui/icon';
7
+ import { api, locale } from '@/lib/api';
8
+ import { hasContacts, mapHref, SOCIAL_NAMES, telHref } from '@/lib/contacts';
9
+ import { messages, type Messages } from '@/lib/i18n';
10
+
11
+ type Contacts = Schema<'Contacts'>;
12
+ type Location = Schema<'Location'>;
13
+
14
+ export async function generateMetadata(): Promise<Metadata> {
15
+ const { data: shop } = await api.shop();
16
+ const meta = pageMeta({ title: messages(locale).contacts, shop });
17
+ return { title: meta.title, description: meta.description };
18
+ }
19
+
20
+ /**
21
+ * How to reach the shop (`GET /contacts`): phones, email, socials, the head office with its hours,
22
+ * the branches, and the company details. Each block only when the shop filled it; a map is a plain
23
+ * link to the point, no embedded script. No contact form: the API has none.
24
+ */
25
+ export default async function ContactsPage() {
26
+ const t = messages(locale);
27
+ const { data: contacts } = await api.contacts();
28
+
29
+ return (
30
+ <div className="contacts-page">
31
+ <Breadcrumbs
32
+ items={[{ name: t.home, href: '/' }, { name: t.contacts }]}
33
+ label={t.breadcrumbs}
34
+ />
35
+ <h1 className="page-title">{t.contacts}</h1>
36
+ {hasContacts(contacts) ? (
37
+ <div className="contacts-page__grid">
38
+ <Reach contacts={contacts} t={t} />
39
+ {contacts.headOffice && <HeadOffice contacts={contacts} t={t} />}
40
+ {contacts.branches.length > 0 && (
41
+ <section className="contacts-card contacts-card--wide">
42
+ <h2 className="contacts-card__title">{t.branches}</h2>
43
+ <ul className="contacts-branches">
44
+ {contacts.branches.map((branch) => (
45
+ <Branch key={branch.id} branch={branch} t={t} />
46
+ ))}
47
+ </ul>
48
+ </section>
49
+ )}
50
+ {contacts.requisites.length > 0 && (
51
+ <section className="contacts-card contacts-card--wide">
52
+ <h2 className="contacts-card__title">{t.requisites}</h2>
53
+ <dl className="contacts-requisites">
54
+ {contacts.requisites.map((row) => (
55
+ <div key={row.label}>
56
+ <dt>{row.label}</dt>
57
+ <dd>{row.value}</dd>
58
+ </div>
59
+ ))}
60
+ </dl>
61
+ </section>
62
+ )}
63
+ {contacts.disclaimer && (
64
+ <p className="contacts-page__disclaimer muted">{contacts.disclaimer}</p>
65
+ )}
66
+ </div>
67
+ ) : (
68
+ <EmptyState title={t.contactsEmpty} icon="phone" />
69
+ )}
70
+ </div>
71
+ );
72
+ }
73
+
74
+ /** Phones, email and socials: the ways to reach the shop right away. */
75
+ function Reach({ contacts, t }: { contacts: Contacts; t: Messages }) {
76
+ if (contacts.phones.length === 0 && !contacts.email && contacts.socials.length === 0) {
77
+ return null;
78
+ }
79
+ return (
80
+ <section className="contacts-card">
81
+ <h2 className="contacts-card__title">{t.contacts}</h2>
82
+ {(contacts.phones.length > 0 || contacts.email) && (
83
+ <ul className="contacts-list">
84
+ {contacts.phones.map((phone) => (
85
+ <li key={phone.number}>
86
+ <Icon name="phone" size={18} />
87
+ <span>
88
+ <a href={telHref(phone.number)}>{phone.number}</a>
89
+ {(phone.label || phone.note) && (
90
+ <span className="muted text-sm">
91
+ {' '}
92
+ {[phone.label, phone.note].filter(Boolean).join(' · ')}
93
+ </span>
94
+ )}
95
+ </span>
96
+ </li>
97
+ ))}
98
+ {contacts.email && (
99
+ <li>
100
+ <Icon name="mail" size={18} />
101
+ <a href={`mailto:${contacts.email}`}>{contacts.email}</a>
102
+ </li>
103
+ )}
104
+ </ul>
105
+ )}
106
+ {contacts.socials.length > 0 && (
107
+ <ul className="chips" aria-label={t.socialMedia}>
108
+ {contacts.socials.map((social) => (
109
+ <li key={social.url}>
110
+ <a href={social.url} target="_blank" rel="noopener">
111
+ {SOCIAL_NAMES[social.network]}
112
+ {social.handle && <span className="muted">{social.handle}</span>}
113
+ </a>
114
+ </li>
115
+ ))}
116
+ </ul>
117
+ )}
118
+ </section>
119
+ );
120
+ }
121
+
122
+ /** The head office: address, landmark, map link, and the week's hours (or their summary). */
123
+ function HeadOffice({ contacts, t }: { contacts: Contacts; t: Messages }) {
124
+ const office = contacts.headOffice!;
125
+ const address = [office.address, office.city].filter(Boolean).join(', ');
126
+ const days = new Intl.DateTimeFormat(locale, { weekday: 'long' });
127
+ // 2024-01-01 was a Monday: ISO day `n` is January `n`.
128
+ const dayName = (day: number) => days.format(new Date(Date.UTC(2024, 0, day, 12)));
129
+ return (
130
+ <section className="contacts-card">
131
+ <h2 className="contacts-card__title">{office.name || t.headOffice}</h2>
132
+ <ul className="contacts-list">
133
+ {address && (
134
+ <li>
135
+ <Icon name="map-pin" size={18} />
136
+ <span>
137
+ {address}
138
+ {office.landmark && (
139
+ <span className="muted text-sm">
140
+ {' '}
141
+ · {t.landmark}: {office.landmark}
142
+ </span>
143
+ )}
144
+ {office.coordinates && (
145
+ <>
146
+ <br />
147
+ <a href={mapHref(office.coordinates)} target="_blank" rel="noopener">
148
+ {t.showOnMap}
149
+ </a>
150
+ </>
151
+ )}
152
+ </span>
153
+ </li>
154
+ )}
155
+ {office.hoursSummary && contacts.openingHours.length === 0 && (
156
+ <li>
157
+ <Icon name="clock" size={18} />
158
+ <span>{office.hoursSummary}</span>
159
+ </li>
160
+ )}
161
+ </ul>
162
+ {contacts.openingHours.length > 0 && (
163
+ <dl className="contacts-hours" aria-label={t.openingHours}>
164
+ {contacts.openingHours.map((day) => (
165
+ <div key={day.day}>
166
+ <dt>{dayName(day.day)}</dt>
167
+ <dd>{day.opens && day.closes ? `${day.opens}–${day.closes}` : t.closed}</dd>
168
+ </div>
169
+ ))}
170
+ </dl>
171
+ )}
172
+ </section>
173
+ );
174
+ }
175
+
176
+ function Branch({ branch, t }: { branch: Location; t: Messages }) {
177
+ const address = [branch.address, branch.apartment, branch.city].filter(Boolean).join(', ');
178
+ return (
179
+ <li className="contacts-branch">
180
+ {branch.name && <h3 className="contacts-branch__name">{branch.name}</h3>}
181
+ {address && <p>{address}</p>}
182
+ {branch.landmark && (
183
+ <p className="muted text-sm">
184
+ {t.landmark}: {branch.landmark}
185
+ </p>
186
+ )}
187
+ {branch.hours && <p className="muted text-sm">{branch.hours}</p>}
188
+ {branch.phone && <a href={telHref(branch.phone)}>{branch.phone}</a>}
189
+ {branch.coordinates && (
190
+ <a href={mapHref(branch.coordinates)} target="_blank" rel="noopener">
191
+ {t.showOnMap}
192
+ </a>
193
+ )}
194
+ </li>
195
+ );
196
+ }
@@ -1,6 +1,8 @@
1
1
  'use client';
2
2
 
3
3
  import { MagicStoreError, useMagicStore } from '@magicstoreai/hydrogen';
4
+ import { Button, buttonClass } from '@/components/ui/button';
5
+ import { EmptyState } from '@/components/ui/empty-state';
4
6
  import { messages } from '@/lib/i18n';
5
7
 
6
8
  /** Any failure a page did not handle itself: the API's detail when there is one, and a retry. */
@@ -8,13 +10,22 @@ export default function ErrorPage({ error, reset }: { error: Error; reset: () =>
8
10
  const t = messages(useMagicStore().locale);
9
11
  const unavailable = error instanceof MagicStoreError && error.code === 'STORE_UNAVAILABLE';
10
12
  return (
11
- <div className="stack">
12
- <h1>{unavailable ? t.shopClosed : t.somethingWentWrong}</h1>
13
- {error instanceof MagicStoreError && error.detail && <p>{error.detail}</p>}
14
- <div className="row">
15
- <button onClick={reset}>{t.tryAgain}</button>
16
- <a href="/">{t.backToShop}</a>
17
- </div>
18
- </div>
13
+ <EmptyState
14
+ as="h1"
15
+ title={unavailable ? t.shopClosed : t.somethingWentWrong}
16
+ action={
17
+ <div className="row">
18
+ <Button variant="primary" onClick={reset}>
19
+ {t.tryAgain}
20
+ </Button>
21
+ {/* A full load, not a client navigation: the app may be what failed. */}
22
+ <a href="/" className={buttonClass({ variant: 'link' })}>
23
+ {t.backToShop}
24
+ </a>
25
+ </div>
26
+ }
27
+ >
28
+ {error instanceof MagicStoreError && error.detail && <span role="alert">{error.detail}</span>}
29
+ </EmptyState>
19
30
  );
20
31
  }
@@ -0,0 +1,93 @@
1
+ Copyright 2021 The Onest Project Authors (https://github.com/googlefonts/onest)
2
+
3
+ This Font Software is licensed under the SIL Open Font License, Version 1.1.
4
+ This license is copied below, and is also available with a FAQ at:
5
+ https://scripts.sil.org/OFL
6
+
7
+
8
+ -----------------------------------------------------------
9
+ SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007
10
+ -----------------------------------------------------------
11
+
12
+ PREAMBLE
13
+ The goals of the Open Font License (OFL) are to stimulate worldwide
14
+ development of collaborative font projects, to support the font creation
15
+ efforts of academic and linguistic communities, and to provide a free and
16
+ open framework in which fonts may be shared and improved in partnership
17
+ with others.
18
+
19
+ The OFL allows the licensed fonts to be used, studied, modified and
20
+ redistributed freely as long as they are not sold by themselves. The
21
+ fonts, including any derivative works, can be bundled, embedded,
22
+ redistributed and/or sold with any software provided that any reserved
23
+ names are not used by derivative works. The fonts and derivatives,
24
+ however, cannot be released under any other type of license. The
25
+ requirement for fonts to remain under this license does not apply
26
+ to any document created using the fonts or their derivatives.
27
+
28
+ DEFINITIONS
29
+ "Font Software" refers to the set of files released by the Copyright
30
+ Holder(s) under this license and clearly marked as such. This may
31
+ include source files, build scripts and documentation.
32
+
33
+ "Reserved Font Name" refers to any names specified as such after the
34
+ copyright statement(s).
35
+
36
+ "Original Version" refers to the collection of Font Software components as
37
+ distributed by the Copyright Holder(s).
38
+
39
+ "Modified Version" refers to any derivative made by adding to, deleting,
40
+ or substituting -- in part or in whole -- any of the components of the
41
+ Original Version, by changing formats or by porting the Font Software to a
42
+ new environment.
43
+
44
+ "Author" refers to any designer, engineer, programmer, technical
45
+ writer or other person who contributed to the Font Software.
46
+
47
+ PERMISSION & CONDITIONS
48
+ Permission is hereby granted, free of charge, to any person obtaining
49
+ a copy of the Font Software, to use, study, copy, merge, embed, modify,
50
+ redistribute, and sell modified and unmodified copies of the Font
51
+ Software, subject to the following conditions:
52
+
53
+ 1) Neither the Font Software nor any of its individual components,
54
+ in Original or Modified Versions, may be sold by itself.
55
+
56
+ 2) Original or Modified Versions of the Font Software may be bundled,
57
+ redistributed and/or sold with any software, provided that each copy
58
+ contains the above copyright notice and this license. These can be
59
+ included either as stand-alone text files, human-readable headers or
60
+ in the appropriate machine-readable metadata fields within text or
61
+ binary files as long as those fields can be easily viewed by the user.
62
+
63
+ 3) No Modified Version of the Font Software may use the Reserved Font
64
+ Name(s) unless explicit written permission is granted by the corresponding
65
+ Copyright Holder. This restriction only applies to the primary font name as
66
+ presented to the users.
67
+
68
+ 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font
69
+ Software shall not be used to promote, endorse or advertise any
70
+ Modified Version, except to acknowledge the contribution(s) of the
71
+ Copyright Holder(s) and the Author(s) or with their explicit written
72
+ permission.
73
+
74
+ 5) The Font Software, modified or unmodified, in part or in whole,
75
+ must be distributed entirely under this license, and must not be
76
+ distributed under any other license. The requirement for fonts to
77
+ remain under this license does not apply to any document created
78
+ using the Font Software.
79
+
80
+ TERMINATION
81
+ This license becomes null and void if any of the above conditions are
82
+ not met.
83
+
84
+ DISCLAIMER
85
+ THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
86
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF
87
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT
88
+ OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE
89
+ COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
90
+ INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL
91
+ DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
92
+ FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM
93
+ OTHER DEALINGS IN THE FONT SOFTWARE.
@@ -0,0 +1,14 @@
1
+ import localFont from 'next/font/local';
2
+
3
+ /**
4
+ * Onest (OFL, `OFL.txt`): one variable file, weights 100 to 900, subset to Latin, Latin Extended
5
+ * (Uzbek `oʻ gʻ`) and Cyrillic. Self-hosted, so a build needs no network. `app/layout.tsx` puts its
6
+ * class on <html>; `app/styles/tokens.css` reads `--font-onest`.
7
+ */
8
+ export const onest = localFont({
9
+ src: './onest-variable.woff2',
10
+ weight: '100 900',
11
+ display: 'swap',
12
+ variable: '--font-onest',
13
+ adjustFontFallback: 'Arial',
14
+ });