create-brainerce-store 1.83.0 → 1.85.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +130 -92
- package/dist/index.js +39 -17
- package/messages/en.json +3 -0
- package/messages/he.json +3 -0
- package/package.json +1 -1
- package/templates/nextjs/base/.env.local.ejs +10 -1
- package/templates/nextjs/base/AGENTS.md.ejs +229 -207
- package/templates/nextjs/base/AI-GUIDE.md +4 -0
- package/templates/nextjs/base/CLAUDE.md.ejs +240 -218
- package/templates/nextjs/base/scripts/connect.mjs +115 -18
- package/templates/nextjs/base/scripts/env-file.mjs +93 -0
- package/templates/nextjs/base/scripts/fetch-store-info.mjs +109 -83
- package/templates/nextjs/base/src/app/api/auth/reset-callback/route.ts +2 -1
- package/templates/nextjs/base/src/app/forgot-password/page.tsx +3 -2
- package/templates/nextjs/base/src/app/layout.tsx.ejs +50 -21
- package/templates/nextjs/base/src/app/opengraph-image.tsx +5 -1
- package/templates/nextjs/base/src/app/reset-password/page.tsx +25 -138
- package/templates/nextjs/base/src/app/reset-password/reset-password-form.tsx +138 -0
- package/templates/nextjs/base/src/components/auth/oauth-buttons.tsx +174 -137
- package/templates/nextjs/base/src/components/checkout/payment-step.tsx +847 -761
- package/templates/nextjs/base/src/core/lib/render-mode.ts +49 -0
- package/templates/nextjs/base/src/core/lib/store-name.ts.ejs +56 -0
- package/templates/nextjs/base/src/core/lib/use-store-name.ts +18 -0
- package/templates/nextjs/base/src/ui/home/hero-section.tsx +27 -27
- package/templates/nextjs/base/src/ui/layout/header-search.tsx +2 -2
- package/templates/nextjs/base/src/ui/layout/site-footer.tsx.ejs +160 -160
- package/templates/nextjs/base/src/ui/layout/site-header.tsx.ejs +2 -2
- package/templates/nextjs/designs/atelier/app-overlay/layout.tsx.ejs +374 -345
- package/templates/nextjs/designs/atelier/globals.css +408 -402
- package/templates/nextjs/designs/atelier/messages-patch/en.json +91 -96
- package/templates/nextjs/designs/atelier/messages-patch/he.json +91 -96
- package/templates/nextjs/designs/atelier/ui/cart/cart-bundle-offer.tsx +131 -128
- package/templates/nextjs/designs/atelier/ui/cart/cart-item.tsx +2 -1
- package/templates/nextjs/designs/atelier/ui/cart/cart-upgrade-banner.tsx +222 -219
- package/templates/nextjs/designs/atelier/ui/home/category-tiles.tsx +178 -151
- package/templates/nextjs/designs/atelier/ui/home/hero-section.tsx +61 -31
- package/templates/nextjs/designs/atelier/ui/layout/header-search.tsx +2 -2
- package/templates/nextjs/designs/atelier/ui/layout/site-footer.tsx.ejs +161 -155
- package/templates/nextjs/designs/atelier/ui/product/frequently-bought-together.tsx +232 -227
- package/templates/nextjs/designs/atelier/ui/product/product-card.tsx +271 -268
- package/templates/nextjs/designs/atelier/ui/product/product-client-section.tsx +558 -553
- package/templates/nextjs/designs/atelier/ui/product/recommendation-section.tsx +113 -110
- package/templates/nextjs/designs/atelier/ui/shared/no-photo-tile.tsx +73 -0
|
@@ -1,110 +1,113 @@
|
|
|
1
|
-
'use client';
|
|
2
|
-
|
|
3
|
-
import { Link } from '@/core/lib/navigation';
|
|
4
|
-
import { CdnImage as Image } from '@/ui/shared/cdn-image';
|
|
5
|
-
import
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
const
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
//
|
|
20
|
-
//
|
|
21
|
-
//
|
|
22
|
-
//
|
|
23
|
-
//
|
|
24
|
-
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
//
|
|
29
|
-
//
|
|
30
|
-
//
|
|
31
|
-
//
|
|
32
|
-
//
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { Link } from '@/core/lib/navigation';
|
|
4
|
+
import { CdnImage as Image } from '@/ui/shared/cdn-image';
|
|
5
|
+
import { NoPhotoTile } from '@/ui/shared/no-photo-tile';
|
|
6
|
+
import type { ProductRecommendation } from 'brainerce';
|
|
7
|
+
import { PriceDisplay } from '@/ui/product/price-display';
|
|
8
|
+
import { cn } from '@/core/lib/utils';
|
|
9
|
+
|
|
10
|
+
interface RecommendationCardProps {
|
|
11
|
+
item: ProductRecommendation;
|
|
12
|
+
className?: string;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function RecommendationCard({ item, className }: RecommendationCardProps) {
|
|
16
|
+
const firstImage = item.images?.[0];
|
|
17
|
+
const imageUrl = typeof firstImage === 'string' ? firstImage : firstImage?.url || null;
|
|
18
|
+
const slug = item.slug || item.id;
|
|
19
|
+
// ⛔ NOT region-converted, and it cannot be. `ProductRecommendation` is a
|
|
20
|
+
// trimmed shape that carries `basePrice` / `salePrice` only: the backend
|
|
21
|
+
// attaches no displayPrice/displayCurrency to it, so there is no converted
|
|
22
|
+
// amount to render and converting here would mean inventing an FX rate.
|
|
23
|
+
// These tiles stay in the store currency on a multi-region store. Do not
|
|
24
|
+
// "fix" it with a client-side conversion.
|
|
25
|
+
const basePrice = parseFloat(item.basePrice);
|
|
26
|
+
const salePrice = item.salePrice ? parseFloat(item.salePrice) : undefined;
|
|
27
|
+
const isOnSale = salePrice != null && salePrice < basePrice;
|
|
28
|
+
// ⛔ No price on a KIT tile. The recommendations endpoint does not resolve
|
|
29
|
+
// kits, so `item.basePrice` here is the kit's stored PLACEHOLDER — right only
|
|
30
|
+
// for FIXED pricing and wrong for every SUM / SUM_MINUS_PERCENT kit. Showing
|
|
31
|
+
// it would quote a price the product page then contradicts. The tile still
|
|
32
|
+
// links through, and the product page reads the resolved price from the API.
|
|
33
|
+
// Do NOT recompute a kit price on the client.
|
|
34
|
+
const priceIsUnresolved = item.type === 'KIT';
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<Link
|
|
38
|
+
href={`/products/${slug}`}
|
|
39
|
+
className={cn('group card card-hover block overflow-hidden', className)}
|
|
40
|
+
>
|
|
41
|
+
{/* `relative` + `aspect-square` are layout-critical for next/image fill */}
|
|
42
|
+
<span className="relative block aspect-square overflow-hidden bg-secondary">
|
|
43
|
+
{imageUrl ? (
|
|
44
|
+
<Image
|
|
45
|
+
src={imageUrl}
|
|
46
|
+
alt={item.name}
|
|
47
|
+
fill
|
|
48
|
+
sizes="(max-width: 640px) 50vw, (max-width: 1024px) 33vw, 20vw"
|
|
49
|
+
className="img-zoom object-cover"
|
|
50
|
+
/>
|
|
51
|
+
) : (
|
|
52
|
+
<NoPhotoTile name={item.name} />
|
|
53
|
+
)}
|
|
54
|
+
</span>
|
|
55
|
+
<span className="block space-y-1 p-4">
|
|
56
|
+
<span className="block text-sm font-semibold leading-snug text-foreground group-hover:text-primary">
|
|
57
|
+
{item.name}
|
|
58
|
+
</span>
|
|
59
|
+
{priceIsUnresolved ? null : (
|
|
60
|
+
<PriceDisplay price={basePrice} salePrice={isOnSale ? salePrice : undefined} size="sm" />
|
|
61
|
+
)}
|
|
62
|
+
</span>
|
|
63
|
+
</Link>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
interface RecommendationSectionProps {
|
|
68
|
+
title: string;
|
|
69
|
+
items: ProductRecommendation[];
|
|
70
|
+
className?: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Recommendation strip on the product page (upsells / related). */
|
|
74
|
+
export function RecommendationSection({ title, items, className }: RecommendationSectionProps) {
|
|
75
|
+
if (items.length === 0) return null;
|
|
76
|
+
|
|
77
|
+
return (
|
|
78
|
+
<section className={cn('border-t pt-10', className)}>
|
|
79
|
+
<h2 className="mb-6 text-2xl">{title}</h2>
|
|
80
|
+
<div className="grid grid-cols-2 gap-3 sm:gap-5 lg:grid-cols-4">
|
|
81
|
+
{items.slice(0, 4).map((item) => (
|
|
82
|
+
<RecommendationCard key={item.id} item={item} />
|
|
83
|
+
))}
|
|
84
|
+
</div>
|
|
85
|
+
</section>
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
interface CartRecommendationSectionProps {
|
|
90
|
+
title: string;
|
|
91
|
+
items: ProductRecommendation[];
|
|
92
|
+
className?: string;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** Cross-sell strip on the cart page ("you might also need"). */
|
|
96
|
+
export function CartRecommendationSection({
|
|
97
|
+
title,
|
|
98
|
+
items,
|
|
99
|
+
className,
|
|
100
|
+
}: CartRecommendationSectionProps) {
|
|
101
|
+
if (items.length === 0) return null;
|
|
102
|
+
|
|
103
|
+
return (
|
|
104
|
+
<section className={cn('border-t pt-10', className)}>
|
|
105
|
+
<h2 className="mb-6 text-2xl">{title}</h2>
|
|
106
|
+
<div className="grid grid-cols-2 gap-3 sm:gap-5 lg:grid-cols-4">
|
|
107
|
+
{items.slice(0, 4).map((item) => (
|
|
108
|
+
<RecommendationCard key={item.id} item={item} />
|
|
109
|
+
))}
|
|
110
|
+
</div>
|
|
111
|
+
</section>
|
|
112
|
+
);
|
|
113
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deliberate no-photo state for any image well in the pack.
|
|
3
|
+
*
|
|
4
|
+
* A brand-new store is seeded with names and prices only, so every product
|
|
5
|
+
* opens without a photo. Leaving the well as a bare `bg-secondary` square
|
|
6
|
+
* makes the grid look broken; this fills it with the same atmosphere the rest
|
|
7
|
+
* of the design uses (sand / forest washes, display serif) so the state reads
|
|
8
|
+
* as designed. The first uploaded image replaces it automatically.
|
|
9
|
+
*
|
|
10
|
+
* Fills its `relative` parent like a `fill` image would. Always decorative:
|
|
11
|
+
* every caller already names the product accessibly beside the well (card
|
|
12
|
+
* heading, cart line, page title), so the tile is `aria-hidden`.
|
|
13
|
+
*/
|
|
14
|
+
import { cn } from '@/core/lib/utils';
|
|
15
|
+
|
|
16
|
+
/** First user-perceived character of the name, safe for surrogate pairs. */
|
|
17
|
+
function initialOf(name: string): string {
|
|
18
|
+
return Array.from(name.trim())[0] ?? '';
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const INITIAL_SIZE = {
|
|
22
|
+
sm: 'text-lg',
|
|
23
|
+
md: 'text-4xl sm:text-5xl',
|
|
24
|
+
lg: 'text-6xl sm:text-7xl',
|
|
25
|
+
} as const;
|
|
26
|
+
|
|
27
|
+
export function NoPhotoTile({
|
|
28
|
+
name,
|
|
29
|
+
tone = 'sand',
|
|
30
|
+
size = 'md',
|
|
31
|
+
showName = false,
|
|
32
|
+
className,
|
|
33
|
+
}: {
|
|
34
|
+
name: string;
|
|
35
|
+
/** `sand` on light wells, `forest` for the hero's lead card. */
|
|
36
|
+
tone?: 'sand' | 'forest';
|
|
37
|
+
size?: 'sm' | 'md' | 'lg';
|
|
38
|
+
/** Print the full name under the initial (hero / category tiles). */
|
|
39
|
+
showName?: boolean;
|
|
40
|
+
className?: string;
|
|
41
|
+
}) {
|
|
42
|
+
const forest = tone === 'forest';
|
|
43
|
+
return (
|
|
44
|
+
<span
|
|
45
|
+
aria-hidden="true"
|
|
46
|
+
className={cn(
|
|
47
|
+
'absolute inset-0 flex flex-col items-center justify-center gap-2 overflow-hidden p-4 text-center',
|
|
48
|
+
forest ? 'wash-forest text-primary-foreground' : 'wash-sand text-primary',
|
|
49
|
+
className
|
|
50
|
+
)}
|
|
51
|
+
>
|
|
52
|
+
<span
|
|
53
|
+
className={cn(
|
|
54
|
+
'font-display select-none leading-none',
|
|
55
|
+
INITIAL_SIZE[size],
|
|
56
|
+
forest ? 'text-primary-foreground/70' : 'text-primary/45'
|
|
57
|
+
)}
|
|
58
|
+
>
|
|
59
|
+
{initialOf(name)}
|
|
60
|
+
</span>
|
|
61
|
+
{showName && (
|
|
62
|
+
<span
|
|
63
|
+
className={cn(
|
|
64
|
+
'line-clamp-2 max-w-full text-sm font-semibold leading-snug',
|
|
65
|
+
forest ? 'text-primary-foreground/85' : 'text-foreground/80'
|
|
66
|
+
)}
|
|
67
|
+
>
|
|
68
|
+
{name}
|
|
69
|
+
</span>
|
|
70
|
+
)}
|
|
71
|
+
</span>
|
|
72
|
+
);
|
|
73
|
+
}
|