create-nymbal-app 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.
- package/dist/index.d.ts +2 -1
- package/dist/index.js +14 -5
- package/dist/index.js.map +1 -1
- package/package.json +5 -4
- package/scaffold/project/astro/src/pages/index.astro +13 -15
- package/scaffold/templates/astro/_dot.node-version +1 -1
- package/scaffold/templates/astro/astro.config.mjs +23 -0
- package/scaffold/templates/astro/package.json +26 -26
- package/scaffold/templates/astro/src/components/SkipNav.astro +3 -1
- package/scaffold/templates/astro/src/elements/index.ts +11 -0
- package/scaffold/templates/astro/src/layouts/BaseLayout.astro +15 -4
- package/scaffold/templates/astro/src/lib/api.ts +162 -38
- package/scaffold/templates/astro/src/lib/chrome.ts +59 -0
- package/scaffold/templates/astro/src/lib/client.ts +4 -4
- package/scaffold/templates/astro/src/lib/fragments.ts +48 -0
- package/scaffold/templates/astro/src/lib/server-elements.ts +5 -0
- package/scaffold/templates/astro/src/middleware.ts +37 -0
- package/scaffold/templates/astro/src/pages/404.astro +3 -0
- package/scaffold/templates/astro/src/pages/account/addresses.astro +5 -97
- package/scaffold/templates/astro/src/pages/account/login.astro +7 -34
- package/scaffold/templates/astro/src/pages/account/orders/[orderNumber].astro +11 -3
- package/scaffold/templates/astro/src/pages/account/profile.astro +6 -56
- package/scaffold/templates/astro/src/pages/account/register.astro +7 -73
- package/scaffold/templates/astro/src/pages/alerts/confirm.astro +59 -0
- package/scaffold/templates/astro/src/pages/alerts/unsubscribe.astro +53 -0
- package/scaffold/templates/astro/src/pages/cart.astro +14 -7
- package/scaffold/templates/astro/src/pages/category/[slug].astro +25 -27
- package/scaffold/templates/astro/src/pages/checkout.astro +30 -94
- package/scaffold/templates/astro/src/pages/fragments/footer.astro +5 -2
- package/scaffold/templates/astro/src/pages/fragments/header.astro +12 -2
- package/scaffold/templates/astro/src/pages/fragments/nav.astro +8 -5
- package/scaffold/templates/astro/src/pages/fragments/product/[slug].astro +9 -10
- package/scaffold/templates/astro/src/pages/index.astro +25 -15
- package/scaffold/templates/astro/src/pages/order/[orderNumber].astro +34 -45
- package/scaffold/templates/astro/src/pages/product/[slug].astro +64 -34
- package/scaffold/templates/astro/src/pages/products/index.astro +16 -21
- package/scaffold/templates/astro/src/pages/search.astro +10 -11
- package/scaffold/templates/astro/src/scripts/init-client.ts +14 -0
- package/scaffold/templates/astro/src/scripts/order-status.ts +3 -1
- package/scaffold/templates/astro/src/scripts/pdp.ts +29 -21
- package/scaffold/templates/astro/src/scripts/plp.ts +15 -93
- package/scaffold/templates/astro/src/scripts/search.ts +7 -132
- package/scaffold/templates/astro/src/scripts/signed-in-redirect.ts +4 -0
- package/scaffold/templates/astro/src/styles/global.css +49 -45
- package/scaffold/templates/astro/src/styles/pages/account.css +4 -90
- package/scaffold/templates/astro/src/styles/pages/confirmation.css +6 -0
- package/scaffold/templates/astro/src/styles/pages/home.css +9 -100
- package/scaffold/templates/astro/src/styles/pages/pdp.css +5 -171
- package/scaffold/templates/astro/src/styles/pages/plp.css +3 -42
- package/scaffold/templates/astro/src/styles/pages/search.css +4 -110
- package/scaffold/templates/astro/src/styles/tokens.css +56 -0
- package/scaffold/templates/nextjs/_dot.node-version +1 -1
- package/scaffold/templates/nextjs/app/(catalog)/category/[slug]/page.tsx +74 -0
- package/scaffold/templates/nextjs/app/(catalog)/home/[key]/page.tsx +85 -0
- package/scaffold/templates/nextjs/app/(catalog)/layout.tsx +13 -0
- package/scaffold/templates/nextjs/app/(catalog)/not-found.tsx +7 -0
- package/scaffold/templates/nextjs/app/(catalog)/product/[slug]/page.tsx +201 -0
- package/scaffold/templates/nextjs/app/(catalog)/products/page.tsx +62 -0
- package/scaffold/templates/nextjs/app/(catalog)/search/SearchView.tsx +90 -0
- package/scaffold/templates/nextjs/app/(catalog)/search/page.tsx +46 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/addresses/AddressesView.tsx +5 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/addresses/page.tsx +17 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/login/LoginView.tsx +28 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/login/page.tsx +23 -0
- package/scaffold/templates/nextjs/app/{account → (shopper)/account}/orders/[orderNumber]/page.tsx +10 -3
- package/scaffold/templates/nextjs/app/(shopper)/account/profile/ProfileView.tsx +5 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/profile/page.tsx +20 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/register/RegisterView.tsx +26 -0
- package/scaffold/templates/nextjs/app/(shopper)/account/register/page.tsx +11 -0
- package/scaffold/templates/nextjs/app/(shopper)/alerts/AlertLinkForm.tsx +90 -0
- package/scaffold/templates/nextjs/app/(shopper)/alerts/LinkInvalid.tsx +19 -0
- package/scaffold/templates/nextjs/app/(shopper)/alerts/actions.ts +33 -0
- package/scaffold/templates/nextjs/app/(shopper)/alerts/confirm/page.tsx +19 -0
- package/scaffold/templates/nextjs/app/(shopper)/alerts/unsubscribe/page.tsx +17 -0
- package/scaffold/templates/nextjs/app/(shopper)/cart/CartView.tsx +5 -0
- package/scaffold/templates/nextjs/app/(shopper)/cart/page.tsx +22 -0
- package/scaffold/templates/nextjs/app/(shopper)/checkout/CheckoutView.tsx +34 -0
- package/scaffold/templates/nextjs/app/(shopper)/checkout/page.tsx +39 -0
- package/scaffold/templates/nextjs/app/(shopper)/layout.tsx +12 -0
- package/scaffold/templates/nextjs/app/(shopper)/not-found.tsx +6 -0
- package/scaffold/templates/nextjs/app/{order → (shopper)/order}/[orderNumber]/page.tsx +44 -9
- package/scaffold/templates/nextjs/app/error.tsx +3 -7
- package/scaffold/templates/nextjs/app/fragments/footer/route.ts +13 -0
- package/scaffold/templates/nextjs/app/fragments/header/[key]/route.ts +18 -0
- package/scaffold/templates/nextjs/app/fragments/nav/[key]/route.ts +23 -0
- package/scaffold/templates/nextjs/app/fragments/product/[slug]/route.ts +22 -0
- package/scaffold/templates/nextjs/app/globals.css +5 -23
- package/scaffold/templates/nextjs/app/layout.tsx +8 -5
- package/scaffold/templates/nextjs/app/not-found.tsx +9 -33
- package/scaffold/templates/nextjs/app/tokens.css +56 -0
- package/scaffold/templates/nextjs/components/client/ListingControls.tsx +87 -0
- package/scaffold/templates/nextjs/components/client/NymbalSetup.tsx +48 -6
- package/scaffold/templates/nextjs/components/client/OrderStatusRefresh.tsx +8 -2
- package/scaffold/templates/nextjs/components/client/ProductInteractive.tsx +47 -15
- package/scaffold/templates/nextjs/components/client/elements.tsx +17 -0
- package/scaffold/templates/nextjs/components/server/Header.tsx +33 -102
- package/scaffold/templates/nextjs/components/server/NotFoundView.tsx +39 -0
- package/scaffold/templates/nextjs/components/server/SkipNav.tsx +7 -3
- package/scaffold/templates/nextjs/elements/index.ts +12 -0
- package/scaffold/templates/nextjs/lib/api.ts +198 -62
- package/scaffold/templates/nextjs/lib/chrome.ts +40 -0
- package/scaffold/templates/nextjs/lib/fragments.ts +16 -0
- package/scaffold/templates/nextjs/lib/header.ts +39 -0
- package/scaffold/templates/nextjs/lib/render.ts +14 -0
- package/scaffold/templates/nextjs/next.config.mjs +41 -0
- package/scaffold/templates/nextjs/package.json +28 -27
- package/scaffold/templates/nextjs/styles/pages/account.module.css +0 -70
- package/scaffold/templates/nextjs/styles/pages/confirmation.module.css +6 -85
- package/scaffold/templates/nextjs/styles/pages/home.module.css +2 -103
- package/scaffold/templates/nextjs/styles/pages/pdp.module.css +3 -183
- package/scaffold/templates/nextjs/styles/pages/plp.module.css +9 -143
- package/scaffold/templates/nextjs/styles/pages/search.module.css +1 -145
- package/scaffold/templates/nextjs/tsconfig.dist.json +5 -0
- package/scaffold/templates/astro/src/components/AddressForm.astro +0 -107
- package/scaffold/templates/astro/src/components/Breadcrumb.astro +0 -20
- package/scaffold/templates/astro/src/components/CategoryNav.astro +0 -27
- package/scaffold/templates/astro/src/components/CheckoutSteps.astro +0 -29
- package/scaffold/templates/astro/src/components/Footer.astro +0 -108
- package/scaffold/templates/astro/src/components/Header.astro +0 -198
- package/scaffold/templates/astro/src/components/ImageGallery.astro +0 -42
- package/scaffold/templates/astro/src/components/OrderSummary.astro +0 -53
- package/scaffold/templates/astro/src/components/Pagination.astro +0 -13
- package/scaffold/templates/astro/src/components/PriceDisplay.astro +0 -25
- package/scaffold/templates/astro/src/components/ProductCard.astro +0 -44
- package/scaffold/templates/astro/src/components/RelatedProducts.astro +0 -28
- package/scaffold/templates/astro/src/components/ReviewForm.astro +0 -74
- package/scaffold/templates/astro/src/components/ReviewList.astro +0 -41
- package/scaffold/templates/astro/src/components/StockBadge.astro +0 -15
- package/scaffold/templates/astro/src/scripts/auth-forms.ts +0 -82
- package/scaffold/templates/astro/src/scripts/cart-page.ts +0 -118
- package/scaffold/templates/astro/src/scripts/checkout.ts +0 -271
- package/scaffold/templates/astro/src/scripts/image-gallery.ts +0 -22
- package/scaffold/templates/astro/src/scripts/profile-form.ts +0 -57
- package/scaffold/templates/astro/src/scripts/review-form.ts +0 -27
- package/scaffold/templates/astro/src/styles/pages/cart.css +0 -215
- package/scaffold/templates/astro/src/styles/pages/checkout.css +0 -270
- package/scaffold/templates/nextjs/app/account/addresses/page.tsx +0 -10
- package/scaffold/templates/nextjs/app/account/login/page.tsx +0 -23
- package/scaffold/templates/nextjs/app/account/profile/page.tsx +0 -10
- package/scaffold/templates/nextjs/app/account/register/page.tsx +0 -10
- package/scaffold/templates/nextjs/app/cart/page.tsx +0 -10
- package/scaffold/templates/nextjs/app/category/[slug]/page.tsx +0 -61
- package/scaffold/templates/nextjs/app/checkout/page.tsx +0 -17
- package/scaffold/templates/nextjs/app/page.tsx +0 -63
- package/scaffold/templates/nextjs/app/product/[slug]/page.tsx +0 -111
- package/scaffold/templates/nextjs/app/products/page.tsx +0 -40
- package/scaffold/templates/nextjs/app/search/page.tsx +0 -24
- package/scaffold/templates/nextjs/components/client/AddressManager.tsx +0 -181
- package/scaffold/templates/nextjs/components/client/CartPage.tsx +0 -121
- package/scaffold/templates/nextjs/components/client/CheckoutForm.tsx +0 -482
- package/scaffold/templates/nextjs/components/client/ImageGallery.tsx +0 -68
- package/scaffold/templates/nextjs/components/client/LoginForm.tsx +0 -89
- package/scaffold/templates/nextjs/components/client/MiniCartWrapper.tsx +0 -12
- package/scaffold/templates/nextjs/components/client/ProductGrid.tsx +0 -137
- package/scaffold/templates/nextjs/components/client/ProfileForm.tsx +0 -112
- package/scaffold/templates/nextjs/components/client/RegisterForm.tsx +0 -131
- package/scaffold/templates/nextjs/components/client/ReviewForm.tsx +0 -116
- package/scaffold/templates/nextjs/components/client/SearchBarWrapper.tsx +0 -27
- package/scaffold/templates/nextjs/components/client/SearchResults.tsx +0 -181
- package/scaffold/templates/nextjs/components/server/Breadcrumb.tsx +0 -36
- package/scaffold/templates/nextjs/components/server/CategoryNav.tsx +0 -29
- package/scaffold/templates/nextjs/components/server/CheckoutSteps.tsx +0 -60
- package/scaffold/templates/nextjs/components/server/Footer.module.css +0 -64
- package/scaffold/templates/nextjs/components/server/Footer.tsx +0 -79
- package/scaffold/templates/nextjs/components/server/Header.module.css +0 -147
- package/scaffold/templates/nextjs/components/server/OrderSummary.tsx +0 -79
- package/scaffold/templates/nextjs/components/server/PriceDisplay.tsx +0 -31
- package/scaffold/templates/nextjs/components/server/ProductCard.tsx +0 -59
- package/scaffold/templates/nextjs/components/server/RelatedProducts.tsx +0 -31
- package/scaffold/templates/nextjs/components/server/ReviewList.tsx +0 -62
- package/scaffold/templates/nextjs/styles/pages/cart.module.css +0 -240
- package/scaffold/templates/nextjs/styles/pages/checkout.module.css +0 -404
- /package/scaffold/templates/nextjs/app/{account → (shopper)/account}/layout.tsx +0 -0
- /package/scaffold/templates/nextjs/app/{account → (shopper)/account}/orders/page.tsx +0 -0
- /package/scaffold/templates/nextjs/app/{account → (shopper)/account}/page.tsx +0 -0
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import '../../styles/pages/account.css'
|
|
3
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
4
|
import AccountLayout from '../../layouts/AccountLayout.astro'
|
|
4
5
|
---
|
|
5
6
|
|
|
@@ -7,63 +8,12 @@ import AccountLayout from '../../layouts/AccountLayout.astro'
|
|
|
7
8
|
<h1 class="account-page-title">Profile</h1>
|
|
8
9
|
<p class="account-page-subtitle">Update your personal information.</p>
|
|
9
10
|
|
|
10
|
-
<
|
|
11
|
-
<div class="account-form-row">
|
|
12
|
-
<div class="form-group">
|
|
13
|
-
<label for="profile-firstName">First Name</label>
|
|
14
|
-
<input
|
|
15
|
-
type="text"
|
|
16
|
-
id="profile-firstName"
|
|
17
|
-
name="firstName"
|
|
18
|
-
autocomplete="given-name"
|
|
19
|
-
data-testid="profile-firstName"
|
|
20
|
-
/>
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div class="form-group">
|
|
24
|
-
<label for="profile-lastName">Last Name</label>
|
|
25
|
-
<input
|
|
26
|
-
type="text"
|
|
27
|
-
id="profile-lastName"
|
|
28
|
-
name="lastName"
|
|
29
|
-
autocomplete="family-name"
|
|
30
|
-
data-testid="profile-lastName"
|
|
31
|
-
/>
|
|
32
|
-
</div>
|
|
33
|
-
</div>
|
|
34
|
-
|
|
35
|
-
<div class="form-group">
|
|
36
|
-
<label for="profile-email">Email</label>
|
|
37
|
-
<input
|
|
38
|
-
type="email"
|
|
39
|
-
id="profile-email"
|
|
40
|
-
name="email"
|
|
41
|
-
disabled
|
|
42
|
-
autocomplete="email"
|
|
43
|
-
data-testid="profile-email"
|
|
44
|
-
style="opacity: 0.6; cursor: not-allowed;"
|
|
45
|
-
/>
|
|
46
|
-
</div>
|
|
47
|
-
|
|
48
|
-
<div class="form-group">
|
|
49
|
-
<label for="profile-phone">Phone</label>
|
|
50
|
-
<input
|
|
51
|
-
type="tel"
|
|
52
|
-
id="profile-phone"
|
|
53
|
-
name="phone"
|
|
54
|
-
autocomplete="tel"
|
|
55
|
-
data-testid="profile-phone"
|
|
56
|
-
/>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<div class="account-form-actions">
|
|
60
|
-
<button type="submit" class="btn btn-primary" data-testid="profile-save">Save Changes</button>
|
|
61
|
-
</div>
|
|
62
|
-
|
|
63
|
-
<p class="form-message" id="profile-message" style="display:none; margin-top: var(--nymbal-spacing-md, 1rem); font-size: var(--nymbal-font-size-sm, 0.875rem);"></p>
|
|
64
|
-
</form>
|
|
11
|
+
<NymbalElement tag="nymbal-profile-form" attributes={{ class: 'account-form' }} />
|
|
65
12
|
</AccountLayout>
|
|
66
13
|
|
|
67
14
|
<script>
|
|
68
|
-
import '../../
|
|
15
|
+
import '../../lib/client.js'
|
|
16
|
+
import { NymbalProfileForm } from '@nymbalhq/web-components/elements/nymbal-profile-form'
|
|
17
|
+
|
|
18
|
+
NymbalProfileForm.define()
|
|
69
19
|
</script>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
import '../../styles/pages/account.css'
|
|
3
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
4
|
import BaseLayout from '../../layouts/BaseLayout.astro'
|
|
4
5
|
---
|
|
5
6
|
|
|
@@ -9,78 +10,7 @@ import BaseLayout from '../../layouts/BaseLayout.astro'
|
|
|
9
10
|
<h1 class="auth-card-title">Create Account</h1>
|
|
10
11
|
<p class="auth-card-subtitle">Join us and start shopping.</p>
|
|
11
12
|
|
|
12
|
-
<
|
|
13
|
-
|
|
14
|
-
<form id="register-form" data-testid="register-form">
|
|
15
|
-
<div class="account-form-row">
|
|
16
|
-
<div class="form-group">
|
|
17
|
-
<label for="register-firstName">First Name</label>
|
|
18
|
-
<input
|
|
19
|
-
type="text"
|
|
20
|
-
id="register-firstName"
|
|
21
|
-
name="firstName"
|
|
22
|
-
autocomplete="given-name"
|
|
23
|
-
placeholder="First name"
|
|
24
|
-
data-testid="register-firstName"
|
|
25
|
-
/>
|
|
26
|
-
</div>
|
|
27
|
-
|
|
28
|
-
<div class="form-group">
|
|
29
|
-
<label for="register-lastName">Last Name</label>
|
|
30
|
-
<input
|
|
31
|
-
type="text"
|
|
32
|
-
id="register-lastName"
|
|
33
|
-
name="lastName"
|
|
34
|
-
autocomplete="family-name"
|
|
35
|
-
placeholder="Last name"
|
|
36
|
-
data-testid="register-lastName"
|
|
37
|
-
/>
|
|
38
|
-
</div>
|
|
39
|
-
</div>
|
|
40
|
-
|
|
41
|
-
<div class="form-group">
|
|
42
|
-
<label for="register-email">Email</label>
|
|
43
|
-
<input
|
|
44
|
-
type="email"
|
|
45
|
-
id="register-email"
|
|
46
|
-
name="email"
|
|
47
|
-
required
|
|
48
|
-
autocomplete="email"
|
|
49
|
-
placeholder="you@example.com"
|
|
50
|
-
data-testid="register-email"
|
|
51
|
-
/>
|
|
52
|
-
</div>
|
|
53
|
-
|
|
54
|
-
<div class="form-group">
|
|
55
|
-
<label for="register-password">Password</label>
|
|
56
|
-
<input
|
|
57
|
-
type="password"
|
|
58
|
-
id="register-password"
|
|
59
|
-
name="password"
|
|
60
|
-
required
|
|
61
|
-
autocomplete="new-password"
|
|
62
|
-
placeholder="Choose a password"
|
|
63
|
-
minlength="8"
|
|
64
|
-
data-testid="register-password"
|
|
65
|
-
/>
|
|
66
|
-
</div>
|
|
67
|
-
|
|
68
|
-
<div class="form-group">
|
|
69
|
-
<label for="register-phone">Phone (optional)</label>
|
|
70
|
-
<input
|
|
71
|
-
type="tel"
|
|
72
|
-
id="register-phone"
|
|
73
|
-
name="phone"
|
|
74
|
-
autocomplete="tel"
|
|
75
|
-
placeholder="+44 7700 900000"
|
|
76
|
-
data-testid="register-phone"
|
|
77
|
-
/>
|
|
78
|
-
</div>
|
|
79
|
-
|
|
80
|
-
<button type="submit" class="btn btn-primary" data-testid="register-submit">
|
|
81
|
-
Create Account
|
|
82
|
-
</button>
|
|
83
|
-
</form>
|
|
13
|
+
<NymbalElement tag="nymbal-register-form" />
|
|
84
14
|
|
|
85
15
|
<p class="auth-footer">
|
|
86
16
|
Already have an account? <a href="/account/login">Sign in</a>
|
|
@@ -90,5 +20,9 @@ import BaseLayout from '../../layouts/BaseLayout.astro'
|
|
|
90
20
|
</BaseLayout>
|
|
91
21
|
|
|
92
22
|
<script>
|
|
93
|
-
import '../../
|
|
23
|
+
import '../../lib/client.js'
|
|
24
|
+
import { NymbalRegisterForm } from '@nymbalhq/web-components/elements/nymbal-register-form'
|
|
25
|
+
import '../../scripts/signed-in-redirect.js'
|
|
26
|
+
|
|
27
|
+
NymbalRegisterForm.define()
|
|
94
28
|
</script>
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
---
|
|
2
|
+
import '../../styles/pages/error.css'
|
|
3
|
+
import BaseLayout from '../../layouts/BaseLayout.astro'
|
|
4
|
+
import { confirmAlert } from '../../lib/api'
|
|
5
|
+
|
|
6
|
+
// Opening the link only shows the button, so a mail scanner that fetches it confirms nothing. The press posts the
|
|
7
|
+
// token back here, and this server posts it on to the API, so the browser needs no CSRF cookie.
|
|
8
|
+
const pressed = Astro.request.method === 'POST'
|
|
9
|
+
const token = pressed
|
|
10
|
+
? String((await Astro.request.formData()).get('token') ?? '')
|
|
11
|
+
: (Astro.url.searchParams.get('token') ?? '')
|
|
12
|
+
const confirmed = pressed && token !== '' ? await confirmAlert(token) : null
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<BaseLayout title="Email alert | Nymbal" description="Confirm your email alert.">
|
|
16
|
+
{!pressed && token !== '' ? (
|
|
17
|
+
<form method="post" class="error-page" data-testid="alert-confirm-form" id="alert-link-form">
|
|
18
|
+
<h1 class="error-title">Confirm your email alert</h1>
|
|
19
|
+
<p class="error-message">Press the button to start the alert this email asked for.</p>
|
|
20
|
+
<input type="hidden" name="token" value={token} />
|
|
21
|
+
<div class="error-actions">
|
|
22
|
+
<button type="submit" class="btn btn-primary" data-testid="alert-confirm-submit">Confirm alert</button>
|
|
23
|
+
</div>
|
|
24
|
+
</form>
|
|
25
|
+
) : confirmed ? (
|
|
26
|
+
<div class="error-page" data-testid="alert-confirmed" data-kind={confirmed.kind}>
|
|
27
|
+
<h1 class="error-title">Your alert is on</h1>
|
|
28
|
+
{confirmed.kind === 'price_drop' ? (
|
|
29
|
+
<p class="error-message">
|
|
30
|
+
We'll email you when the price of <a href={`/product/${confirmed.product.slug}`}>{confirmed.product.name}</a> drops.
|
|
31
|
+
</p>
|
|
32
|
+
) : (
|
|
33
|
+
<p class="error-message">
|
|
34
|
+
We'll email you once when <a href={`/product/${confirmed.product.slug}`}>{confirmed.product.name}</a> is back
|
|
35
|
+
in stock.
|
|
36
|
+
</p>
|
|
37
|
+
)}
|
|
38
|
+
</div>
|
|
39
|
+
) : (
|
|
40
|
+
<div class="error-page" data-testid="alert-link-invalid">
|
|
41
|
+
<h1 class="error-title">This link is not valid</h1>
|
|
42
|
+
<p class="error-message">It may be from an older email, or the alert has been stopped.</p>
|
|
43
|
+
<div class="error-actions">
|
|
44
|
+
<a href="/products" class="btn btn-primary">Browse Products</a>
|
|
45
|
+
</div>
|
|
46
|
+
</div>
|
|
47
|
+
)}
|
|
48
|
+
</BaseLayout>
|
|
49
|
+
|
|
50
|
+
<script>
|
|
51
|
+
import { submitOnce } from '../../lib/submit-once'
|
|
52
|
+
|
|
53
|
+
// The native submit sends the form once; a second click or Enter while it is on its way is ignored.
|
|
54
|
+
const form = document.getElementById('alert-link-form') as HTMLFormElement | null
|
|
55
|
+
submitOnce(form, () => {
|
|
56
|
+
form?.submit()
|
|
57
|
+
return 'leaving'
|
|
58
|
+
})
|
|
59
|
+
</script>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
---
|
|
2
|
+
import '../../styles/pages/error.css'
|
|
3
|
+
import BaseLayout from '../../layouts/BaseLayout.astro'
|
|
4
|
+
import { unsubscribeAlert } from '../../lib/api'
|
|
5
|
+
|
|
6
|
+
// Opening the link only shows the button, so a mail scanner that fetches it stops nothing. The press posts the token
|
|
7
|
+
// back here, and this server posts it on to the API, which holds no CSRF cookie.
|
|
8
|
+
const pressed = Astro.request.method === 'POST'
|
|
9
|
+
const token = pressed
|
|
10
|
+
? String((await Astro.request.formData()).get('token') ?? '')
|
|
11
|
+
: (Astro.url.searchParams.get('token') ?? '')
|
|
12
|
+
const stopped = pressed && token !== '' ? await unsubscribeAlert(token) : false
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
<BaseLayout title="Back-in-stock alert | Nymbal" description="Stop a back-in-stock alert.">
|
|
16
|
+
{!pressed && token !== '' ? (
|
|
17
|
+
<form method="post" class="error-page" data-testid="alert-unsubscribe-form" id="alert-link-form">
|
|
18
|
+
<h1 class="error-title">Stop this email alert</h1>
|
|
19
|
+
<p class="error-message">Press the button and we won't email you about this product again.</p>
|
|
20
|
+
<input type="hidden" name="token" value={token} />
|
|
21
|
+
<div class="error-actions">
|
|
22
|
+
<button type="submit" class="btn btn-primary" data-testid="alert-unsubscribe-submit">Unsubscribe</button>
|
|
23
|
+
</div>
|
|
24
|
+
</form>
|
|
25
|
+
) : stopped ? (
|
|
26
|
+
<div class="error-page" data-testid="alert-unsubscribed">
|
|
27
|
+
<h1 class="error-title">Your alert is off</h1>
|
|
28
|
+
<p class="error-message">We won't email you about this product again.</p>
|
|
29
|
+
<div class="error-actions">
|
|
30
|
+
<a href="/products" class="btn btn-primary">Browse Products</a>
|
|
31
|
+
</div>
|
|
32
|
+
</div>
|
|
33
|
+
) : (
|
|
34
|
+
<div class="error-page" data-testid="alert-link-invalid">
|
|
35
|
+
<h1 class="error-title">This link is not valid</h1>
|
|
36
|
+
<p class="error-message">Check that the whole link from the email was opened.</p>
|
|
37
|
+
<div class="error-actions">
|
|
38
|
+
<a href="/products" class="btn btn-primary">Browse Products</a>
|
|
39
|
+
</div>
|
|
40
|
+
</div>
|
|
41
|
+
)}
|
|
42
|
+
</BaseLayout>
|
|
43
|
+
|
|
44
|
+
<script>
|
|
45
|
+
import { submitOnce } from '../../lib/submit-once'
|
|
46
|
+
|
|
47
|
+
// The native submit sends the form once; a second click or Enter while it is on its way is ignored.
|
|
48
|
+
const form = document.getElementById('alert-link-form') as HTMLFormElement | null
|
|
49
|
+
submitOnce(form, () => {
|
|
50
|
+
form?.submit()
|
|
51
|
+
return 'leaving'
|
|
52
|
+
})
|
|
53
|
+
</script>
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
---
|
|
2
|
-
import '
|
|
2
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
3
|
import BaseLayout from '../layouts/BaseLayout.astro'
|
|
4
|
+
import { fetchCart } from '../lib/api'
|
|
5
|
+
|
|
6
|
+
const cart = await fetchCart(Astro.request.headers.get('cookie'))
|
|
4
7
|
---
|
|
5
8
|
|
|
6
|
-
<BaseLayout title="Your Cart | Nymbal" description="Review the items in your cart.">
|
|
7
|
-
<div class="container section"
|
|
8
|
-
<
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
<BaseLayout title="Your Cart | Nymbal" description="Review the items in your cart." cart={cart}>
|
|
10
|
+
<div class="container section" data-testid="cart-page">
|
|
11
|
+
<NymbalElement
|
|
12
|
+
tag="nymbal-cart-page"
|
|
13
|
+
attributes={cart === null ? {} : { cart: JSON.stringify(cart) }}
|
|
14
|
+
/>
|
|
11
15
|
</div>
|
|
12
16
|
</BaseLayout>
|
|
13
17
|
|
|
14
18
|
<script>
|
|
15
|
-
import '../
|
|
19
|
+
import '../lib/client.js'
|
|
20
|
+
import { NymbalCartPage } from '@nymbalhq/web-components/elements/nymbal-cart-page'
|
|
21
|
+
|
|
22
|
+
NymbalCartPage.define()
|
|
16
23
|
</script>
|
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
---
|
|
2
2
|
import '../../styles/pages/plp.css'
|
|
3
|
-
import '../../styles/pages/home.css'
|
|
4
3
|
import BaseLayout from '../../layouts/BaseLayout.astro'
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import Pagination from '../../components/Pagination.astro'
|
|
4
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
5
|
+
import { cardImageOf, cardProductOf } from '@nymbalhq/web-components/ssr'
|
|
8
6
|
import { PRODUCT_SORT_LABELS } from '@nymbalhq/types'
|
|
9
|
-
import { fetchProducts,
|
|
7
|
+
import { fetchProducts, loadCategories, fetchCapabilities, sortFromUrl } from '../../lib/api'
|
|
10
8
|
|
|
11
9
|
const { slug } = Astro.params
|
|
12
10
|
const capabilities = await fetchCapabilities()
|
|
@@ -15,30 +13,35 @@ const sort = sortFromUrl(Astro.url, capabilities?.catalog)
|
|
|
15
13
|
|
|
16
14
|
const [productResult, categories] = await Promise.all([
|
|
17
15
|
fetchProducts({ limit: 24, category: slug, sort }),
|
|
18
|
-
|
|
16
|
+
// Rejects when the API fails, so a failed read is a 500 and never a 404 for a category the store has.
|
|
17
|
+
loadCategories(),
|
|
19
18
|
])
|
|
20
|
-
|
|
21
|
-
const products = productResult.items
|
|
22
19
|
const category = categories.find((c) => c.slug === slug)
|
|
23
|
-
|
|
20
|
+
if (!category) return Astro.rewrite('/404')
|
|
21
|
+
|
|
22
|
+
const products = productResult.items.map(cardProductOf)
|
|
23
|
+
// The first card's image is the page's LCP, and the preload scanner never reaches it inside the grid's shadow root:
|
|
24
|
+
// the head starts it.
|
|
25
|
+
const firstImage = products[0] === undefined ? null : cardImageOf(products[0]).url
|
|
26
|
+
const categoryName = category.name
|
|
24
27
|
const facets = productResult.facets ?? []
|
|
25
28
|
---
|
|
26
29
|
|
|
27
30
|
<BaseLayout
|
|
28
31
|
title={`${categoryName} | Nymbal`}
|
|
29
|
-
description={category
|
|
32
|
+
description={category.description ?? `Browse ${categoryName} products.`}
|
|
30
33
|
>
|
|
34
|
+
{firstImage && <link slot="head" rel="preload" as="image" href={firstImage} fetchpriority="high" />}
|
|
31
35
|
<div class="container section">
|
|
32
|
-
<
|
|
36
|
+
<NymbalElement tag="nymbal-breadcrumb" attributes={{ items: JSON.stringify([{ label: 'Home', href: '/' }, { label: categoryName }]) }} />
|
|
33
37
|
|
|
34
38
|
<div class="plp-header">
|
|
35
39
|
<h1 class="plp-title">{categoryName}</h1>
|
|
36
|
-
{category
|
|
40
|
+
{category.description && (
|
|
37
41
|
<p style="font-size: var(--nymbal-font-size-sm, 0.875rem); color: var(--nymbal-color-text-muted, #71717a); margin-bottom: var(--nymbal-spacing-sm, 0.5rem);">
|
|
38
42
|
{category.description}
|
|
39
43
|
</p>
|
|
40
44
|
)}
|
|
41
|
-
<p class="plp-count" id="product-count">{products.length} products</p>
|
|
42
45
|
</div>
|
|
43
46
|
|
|
44
47
|
<div class="plp-layout">
|
|
@@ -68,20 +71,15 @@ const facets = productResult.facets ?? []
|
|
|
68
71
|
</div>
|
|
69
72
|
)}
|
|
70
73
|
|
|
71
|
-
<
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
<p class="plp-empty-text">Check back soon for new arrivals.</p>
|
|
81
|
-
</div>
|
|
82
|
-
)}
|
|
83
|
-
|
|
84
|
-
<Pagination />
|
|
74
|
+
<NymbalElement
|
|
75
|
+
tag="nymbal-product-grid"
|
|
76
|
+
attributes={{
|
|
77
|
+
products: JSON.stringify(products),
|
|
78
|
+
source: 'product-list',
|
|
79
|
+
...(productResult.nextCursor !== null && { 'has-more': '' }),
|
|
80
|
+
'data-category': slug!,
|
|
81
|
+
}}
|
|
82
|
+
/>
|
|
85
83
|
</div>
|
|
86
84
|
</div>
|
|
87
85
|
</div>
|
|
@@ -1,108 +1,44 @@
|
|
|
1
1
|
---
|
|
2
|
-
import '
|
|
2
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
3
|
import BaseLayout from '../layouts/BaseLayout.astro'
|
|
4
|
-
import
|
|
5
|
-
import AddressForm from '../components/AddressForm.astro'
|
|
6
|
-
import { fetchCapabilities } from '../lib/api'
|
|
4
|
+
import { fetchCapabilities, fetchCart } from '../lib/api'
|
|
7
5
|
|
|
8
|
-
const capabilities = await
|
|
6
|
+
const [capabilities, cart] = await Promise.all([
|
|
7
|
+
fetchCapabilities(),
|
|
8
|
+
fetchCart(Astro.request.headers.get('cookie')),
|
|
9
|
+
])
|
|
9
10
|
if (capabilities === null) {
|
|
10
11
|
throw new Error('The store did not answer GET /api/capabilities, so checkout cannot tell how to take a payment.')
|
|
11
12
|
}
|
|
12
|
-
const
|
|
13
|
+
const escapeAttribute = (value: string): string =>
|
|
14
|
+
value.replaceAll('&', '&').replaceAll('"', '"').replaceAll('<', '<')
|
|
15
|
+
// The payments adapter's client half, the checkout's light-DOM child in its payment slot; a driver the project
|
|
16
|
+
// registers in src/lib/client.ts renders it. HTML, not markup: Astro would take `slot="payment"` on a component's
|
|
17
|
+
// child as a slot of NymbalElement's own.
|
|
18
|
+
const paymentElement = `<nymbal-payment-element slot="payment" data-testid="payment-element" client="${escapeAttribute(
|
|
19
|
+
JSON.stringify(capabilities.payments.client),
|
|
20
|
+
)}"></nymbal-payment-element>`
|
|
13
21
|
---
|
|
14
22
|
|
|
15
|
-
<BaseLayout title="Checkout | Nymbal" description="Complete your purchase.">
|
|
23
|
+
<BaseLayout title="Checkout | Nymbal" description="Complete your purchase." cart={cart}>
|
|
16
24
|
<div class="container section">
|
|
17
|
-
<
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
<CheckoutSteps currentStep="contact" />
|
|
21
|
-
</div>
|
|
22
|
-
|
|
23
|
-
<div class="checkout-error" id="checkout-error" style="display:none;" data-testid="checkout-error" role="alert"></div>
|
|
24
|
-
|
|
25
|
-
<div class="checkout-layout">
|
|
26
|
-
<div class="checkout-form">
|
|
27
|
-
<!-- Contact Section -->
|
|
28
|
-
<section class="checkout-section" id="checkout-contact" data-testid="checkout-contact">
|
|
29
|
-
<h2 class="checkout-section-title">Contact Information</h2>
|
|
30
|
-
<form id="contact-form">
|
|
31
|
-
<div class="form-group">
|
|
32
|
-
<label for="contact-email">Email Address</label>
|
|
33
|
-
<input
|
|
34
|
-
type="email"
|
|
35
|
-
id="contact-email"
|
|
36
|
-
name="email"
|
|
37
|
-
required
|
|
38
|
-
autocomplete="email"
|
|
39
|
-
placeholder="you@example.com"
|
|
40
|
-
data-testid="contact-email"
|
|
41
|
-
/>
|
|
42
|
-
</div>
|
|
43
|
-
<button type="submit" class="btn btn-primary" data-testid="contact-continue">
|
|
44
|
-
Continue to Shipping
|
|
45
|
-
</button>
|
|
46
|
-
</form>
|
|
47
|
-
</section>
|
|
48
|
-
|
|
49
|
-
<!-- Shipping Section -->
|
|
50
|
-
<section class="checkout-section" id="checkout-shipping" style="display:none;" data-testid="checkout-shipping">
|
|
51
|
-
<h2 class="checkout-section-title">Shipping Address</h2>
|
|
52
|
-
<form id="shipping-form">
|
|
53
|
-
<AddressForm id="shipping" />
|
|
54
|
-
<button type="submit" class="btn btn-primary" style="margin-top: var(--nymbal-spacing-md, 1rem);" data-testid="shipping-continue">
|
|
55
|
-
Continue to Payment
|
|
56
|
-
</button>
|
|
57
|
-
</form>
|
|
58
|
-
</section>
|
|
59
|
-
|
|
60
|
-
<!-- Payment Section -->
|
|
61
|
-
<section class="checkout-section" id="checkout-payment" style="display:none;" data-testid="checkout-payment">
|
|
62
|
-
<h2 class="checkout-section-title">Payment</h2>
|
|
63
|
-
<form id="payment-form" novalidate>
|
|
64
|
-
<div class="form-group">
|
|
65
|
-
<label>
|
|
66
|
-
<input type="checkbox" id="billing-same" checked />
|
|
67
|
-
Billing address same as shipping
|
|
68
|
-
</label>
|
|
69
|
-
</div>
|
|
70
|
-
|
|
71
|
-
<div id="billing-fields" style="display:none;">
|
|
72
|
-
<h3 class="checkout-section-title" style="font-size: 1rem; margin-top: var(--nymbal-spacing-md, 1rem);">Billing Address</h3>
|
|
73
|
-
<div id="billing-form">
|
|
74
|
-
<AddressForm id="billing" />
|
|
75
|
-
</div>
|
|
76
|
-
</div>
|
|
77
|
-
|
|
78
|
-
<div class="payment-section" style="margin-top: var(--nymbal-spacing-md, 1rem);">
|
|
79
|
-
{paymentClient !== null && (
|
|
80
|
-
<p class="checkout-section-title" style="font-size: 1rem; margin-bottom: var(--nymbal-spacing-sm, 0.5rem);">Payment Details</p>
|
|
81
|
-
)}
|
|
82
|
-
<!-- The payments adapter's client half; a driver the project registers in src/lib/client.ts renders it. -->
|
|
83
|
-
<nymbal-payment-element data-testid="payment-element" client={JSON.stringify(paymentClient)}></nymbal-payment-element>
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
<div class="checkout-submit">
|
|
87
|
-
<button type="submit" class="btn btn-primary" data-testid="place-order">
|
|
88
|
-
Place Order
|
|
89
|
-
</button>
|
|
90
|
-
<p class="checkout-terms">
|
|
91
|
-
By placing your order, you agree to our terms and conditions.
|
|
92
|
-
</p>
|
|
93
|
-
</div>
|
|
94
|
-
</form>
|
|
95
|
-
</section>
|
|
96
|
-
</div>
|
|
97
|
-
|
|
98
|
-
<aside class="checkout-summary" id="checkout-summary" data-testid="checkout-summary">
|
|
99
|
-
<h2 class="checkout-summary-title">Order Summary</h2>
|
|
100
|
-
<p style="font-size: var(--nymbal-font-size-sm, 0.875rem); color: var(--nymbal-color-text-muted, #71717a);">Loading cart...</p>
|
|
101
|
-
</aside>
|
|
102
|
-
</div>
|
|
25
|
+
<NymbalElement tag="nymbal-checkout" attributes={cart === null ? {} : { cart: JSON.stringify(cart) }}>
|
|
26
|
+
<Fragment set:html={paymentElement} />
|
|
27
|
+
</NymbalElement>
|
|
103
28
|
</div>
|
|
104
29
|
</BaseLayout>
|
|
105
30
|
|
|
106
31
|
<script>
|
|
107
|
-
import '
|
|
32
|
+
import { NymbalCheckout } from '@nymbalhq/web-components/elements/nymbal-checkout'
|
|
33
|
+
import { NymbalPaymentElement } from '@nymbalhq/web-components/elements/nymbal-payment-element'
|
|
34
|
+
|
|
35
|
+
// The page's own elements; the layout defines the rest.
|
|
36
|
+
NymbalPaymentElement.define()
|
|
37
|
+
NymbalCheckout.define()
|
|
38
|
+
|
|
39
|
+
// The element places the order; the page only goes to it.
|
|
40
|
+
document.addEventListener('nymbal:checkout:placed', (event) => {
|
|
41
|
+
const { orderNumber, orderKey } = (event as CustomEvent<{ orderNumber: string; orderKey?: string }>).detail
|
|
42
|
+
window.location.href = `/order/${encodeURIComponent(orderNumber)}${orderKey ? `?key=${encodeURIComponent(orderKey)}` : ''}`
|
|
43
|
+
})
|
|
108
44
|
</script>
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
|
+
import { FOOTER } from '../../lib/chrome'
|
|
3
4
|
Astro.response.headers.set('Cache-Control', 'public, s-maxage=86400, stale-while-revalidate=300')
|
|
5
|
+
// A fragment has no <meta charset>, so the charset is in the header.
|
|
6
|
+
Astro.response.headers.set('Content-Type', 'text/html; charset=utf-8')
|
|
4
7
|
---
|
|
5
|
-
<
|
|
8
|
+
<NymbalElement tag="nymbal-site-footer" attributes={FOOTER} />
|
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
2
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
|
+
import { HEADER, headerSlots } from '../../lib/chrome'
|
|
4
|
+
import { headerFragment } from '../../lib/fragments'
|
|
5
|
+
|
|
6
|
+
const header = await headerFragment()
|
|
7
|
+
if (header instanceof Response) return header
|
|
8
|
+
|
|
3
9
|
Astro.response.headers.set('Cache-Control', 'public, s-maxage=3600, stale-while-revalidate=300')
|
|
10
|
+
// A fragment has no <meta charset>, so the charset is in the header.
|
|
11
|
+
Astro.response.headers.set('Content-Type', 'text/html; charset=utf-8')
|
|
4
12
|
---
|
|
5
|
-
<
|
|
13
|
+
<NymbalElement tag="nymbal-site-header" attributes={HEADER}>
|
|
14
|
+
<Fragment set:html={headerSlots(header.canSearch)} />
|
|
15
|
+
</NymbalElement>
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
|
+
import { navFragment } from '../../lib/fragments'
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
const nav = await navFragment()
|
|
6
|
+
if (nav instanceof Response) return nav
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
Astro.response.headers.set('Cache-Control', 'public, s-maxage=21600, stale-while-revalidate=300')
|
|
9
|
+
// A fragment has no <meta charset>, so the charset is in the header.
|
|
10
|
+
Astro.response.headers.set('Content-Type', 'text/html; charset=utf-8')
|
|
8
11
|
---
|
|
9
|
-
<
|
|
12
|
+
<NymbalElement tag="nymbal-category-nav" attributes={{ categories: JSON.stringify(nav.categories) }} />
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
---
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
2
|
+
import NymbalElement from '@nymbalhq/web-components/astro'
|
|
3
|
+
import { cardProductOf } from '@nymbalhq/web-components/ssr'
|
|
4
|
+
import { productFragment } from '../../../lib/fragments'
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const { slug } = Astro.params
|
|
8
|
-
const product = await fetchProduct(slug!)
|
|
6
|
+
const card = await productFragment(Astro.params.slug!)
|
|
7
|
+
if (card instanceof Response) return card
|
|
9
8
|
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
Astro.response.headers.set('Cache-Control', 'public, s-maxage=300, stale-while-revalidate=60')
|
|
10
|
+
// A fragment has no <meta charset>, so the charset is in the header.
|
|
11
|
+
Astro.response.headers.set('Content-Type', 'text/html; charset=utf-8')
|
|
13
12
|
---
|
|
14
|
-
<
|
|
13
|
+
<NymbalElement tag="nymbal-product-card" attributes={{ product: JSON.stringify(cardProductOf(card.product)) }} />
|