phation 0.1.0 → 0.1.1
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 +69 -101
- package/package.json +13 -3
- package/server.json +36 -0
- package/animate/testset/eval.mjs +0 -24
- package/animate/testset/expected.json +0 -23
- package/animate/testset/holdout/commerce-delete-item-button.tsx +0 -38
- package/animate/testset/holdout/commerce-gallery.tsx +0 -96
- package/animate/testset/holdout/commerce-tile.tsx +0 -50
- package/animate/testset/holdout/shadcn-button-group-demo.tsx +0 -114
- package/animate/testset/holdout/shadcn-card-demo.tsx +0 -63
- package/animate/testset/holdout/shadcn-command-dialog.tsx +0 -87
- package/animate/testset/holdout/shadcn-drawer-dialog.tsx +0 -90
- package/animate/testset/holdout/shadcn-field-switch.tsx +0 -24
- package/animate/testset/holdout/shadcn-hover-card-demo.tsx +0 -40
- package/animate/testset/holdout/shadcn-mode-toggle.tsx +0 -40
- package/animate/testset/holdout/shadcn-toggle-group-demo.tsx +0 -22
- package/animate/testset/holdout.json +0 -14
- package/animate/testset/holdout2/chatbot-artifact-close-button.tsx +0 -30
- package/animate/testset/holdout2/chatbot-message-actions.tsx +0 -211
- package/animate/testset/holdout2/chatbot-sidebar-history-item.tsx +0 -132
- package/animate/testset/holdout2/chatbot-sidebar-toggle.tsx +0 -35
- package/animate/testset/holdout2/chatbot-suggested-actions.tsx +0 -82
- package/animate/testset/holdout2/chatbot-weather.tsx +0 -434
- package/animate/testset/holdout2/site-code-tabs.tsx +0 -26
- package/animate/testset/holdout2/site-copy-button.tsx +0 -121
- package/animate/testset/holdout2/site-github-link.tsx +0 -38
- package/animate/testset/holdout2/site-mobile-nav.tsx +0 -220
- package/animate/testset/holdout2/site-mode-switcher.tsx +0 -97
- package/animate/testset/holdout2/site-page-nav.tsx +0 -15
- package/animate/testset/holdout2.json +0 -15
- package/animate/testset/screens/commerce-cart-add-to-cart.tsx +0 -94
- package/animate/testset/screens/commerce-cart-modal.tsx +0 -256
- package/animate/testset/screens/commerce-navbar-mobile-menu.tsx +0 -104
- package/animate/testset/screens/commerce-product-variant-selector.tsx +0 -106
- package/animate/testset/screens/shadcn-accordion-demo.tsx +0 -61
- package/animate/testset/screens/shadcn-alert-dialog-demo.tsx +0 -35
- package/animate/testset/screens/shadcn-card-with-form.tsx +0 -59
- package/animate/testset/screens/shadcn-collapsible-demo.tsx +0 -46
- package/animate/testset/screens/shadcn-dialog-demo.tsx +0 -50
- package/animate/testset/screens/shadcn-drawer-demo.tsx +0 -136
- package/animate/testset/screens/shadcn-login-form.tsx +0 -71
- package/animate/testset/screens/shadcn-nav-main.tsx +0 -73
- package/animate/testset/screens/shadcn-section-cards.tsx +0 -102
- package/animate/testset/screens/shadcn-sheet-demo.tsx +0 -47
- package/animate/testset/screens/shadcn-switch-demo.tsx +0 -11
- package/animate/testset/screens/shadcn-tabs-demo.tsx +0 -80
- package/animate/testset/screens/taxonomy-main-nav.tsx +0 -61
- package/animate/testset/screens/taxonomy-post-item.tsx +0 -42
- package/animate/testset/screens/taxonomy-pricing.tsx +0 -69
- package/animate/testset/screens/taxonomy-user-account-nav.tsx +0 -65
|
@@ -1,256 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import { Dialog, Transition } from "@headlessui/react";
|
|
5
|
-
import { ShoppingCartIcon, XMarkIcon } from "@heroicons/react/24/outline";
|
|
6
|
-
import LoadingDots from "components/loading-dots";
|
|
7
|
-
import Price from "components/price";
|
|
8
|
-
import { DEFAULT_OPTION } from "lib/constants";
|
|
9
|
-
import { createUrl } from "lib/utils";
|
|
10
|
-
import Image from "next/image";
|
|
11
|
-
import Link from "next/link";
|
|
12
|
-
import { Fragment, useEffect, useRef, useState } from "react";
|
|
13
|
-
import { useFormStatus } from "react-dom";
|
|
14
|
-
import { createCartAndSetCookie, redirectToCheckout } from "./actions";
|
|
15
|
-
import { useCart } from "./cart-context";
|
|
16
|
-
import { DeleteItemButton } from "./delete-item-button";
|
|
17
|
-
import { EditItemQuantityButton } from "./edit-item-quantity-button";
|
|
18
|
-
import OpenCart from "./open-cart";
|
|
19
|
-
|
|
20
|
-
type MerchandiseSearchParams = {
|
|
21
|
-
[key: string]: string;
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export default function CartModal() {
|
|
25
|
-
const { cart, updateCartItem } = useCart();
|
|
26
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
27
|
-
const quantityRef = useRef(cart?.totalQuantity);
|
|
28
|
-
const openCart = () => setIsOpen(true);
|
|
29
|
-
const closeCart = () => setIsOpen(false);
|
|
30
|
-
|
|
31
|
-
useEffect(() => {
|
|
32
|
-
if (!cart) {
|
|
33
|
-
createCartAndSetCookie();
|
|
34
|
-
}
|
|
35
|
-
}, [cart]);
|
|
36
|
-
|
|
37
|
-
useEffect(() => {
|
|
38
|
-
if (
|
|
39
|
-
cart?.totalQuantity &&
|
|
40
|
-
cart?.totalQuantity !== quantityRef.current &&
|
|
41
|
-
cart?.totalQuantity > 0
|
|
42
|
-
) {
|
|
43
|
-
if (!isOpen) {
|
|
44
|
-
setIsOpen(true);
|
|
45
|
-
}
|
|
46
|
-
quantityRef.current = cart?.totalQuantity;
|
|
47
|
-
}
|
|
48
|
-
}, [isOpen, cart?.totalQuantity, quantityRef]);
|
|
49
|
-
|
|
50
|
-
return (
|
|
51
|
-
<>
|
|
52
|
-
<button aria-label="Open cart" onClick={openCart}>
|
|
53
|
-
<OpenCart quantity={cart?.totalQuantity} />
|
|
54
|
-
</button>
|
|
55
|
-
<Transition show={isOpen}>
|
|
56
|
-
<Dialog onClose={closeCart} className="relative z-50">
|
|
57
|
-
<Transition.Child
|
|
58
|
-
as={Fragment}
|
|
59
|
-
enter="transition-all ease-in-out duration-300"
|
|
60
|
-
enterFrom="opacity-0 backdrop-blur-none"
|
|
61
|
-
enterTo="opacity-100 backdrop-blur-[.5px]"
|
|
62
|
-
leave="transition-all ease-in-out duration-200"
|
|
63
|
-
leaveFrom="opacity-100 backdrop-blur-[.5px]"
|
|
64
|
-
leaveTo="opacity-0 backdrop-blur-none"
|
|
65
|
-
>
|
|
66
|
-
<div className="fixed inset-0 bg-black/30" aria-hidden="true" />
|
|
67
|
-
</Transition.Child>
|
|
68
|
-
<Transition.Child
|
|
69
|
-
as={Fragment}
|
|
70
|
-
enter="transition-all ease-in-out duration-300"
|
|
71
|
-
enterFrom="translate-x-full"
|
|
72
|
-
enterTo="translate-x-0"
|
|
73
|
-
leave="transition-all ease-in-out duration-200"
|
|
74
|
-
leaveFrom="translate-x-0"
|
|
75
|
-
leaveTo="translate-x-full"
|
|
76
|
-
>
|
|
77
|
-
<Dialog.Panel className="fixed bottom-0 right-0 top-0 flex h-full w-full flex-col border-l border-neutral-200 bg-white/80 p-6 text-black backdrop-blur-xl md:w-[390px] dark:border-neutral-700 dark:bg-black/80 dark:text-white">
|
|
78
|
-
<div className="flex items-center justify-between">
|
|
79
|
-
<p className="text-lg font-semibold">My Cart</p>
|
|
80
|
-
<button aria-label="Close cart" onClick={closeCart}>
|
|
81
|
-
<CloseCart />
|
|
82
|
-
</button>
|
|
83
|
-
</div>
|
|
84
|
-
|
|
85
|
-
{!cart || cart.lines.length === 0 ? (
|
|
86
|
-
<div className="mt-20 flex w-full flex-col items-center justify-center overflow-hidden">
|
|
87
|
-
<ShoppingCartIcon className="h-16" />
|
|
88
|
-
<p className="mt-6 text-center text-2xl font-bold">
|
|
89
|
-
Your cart is empty.
|
|
90
|
-
</p>
|
|
91
|
-
</div>
|
|
92
|
-
) : (
|
|
93
|
-
<div className="flex h-full flex-col justify-between overflow-hidden p-1">
|
|
94
|
-
<ul className="grow overflow-auto py-4">
|
|
95
|
-
{cart.lines
|
|
96
|
-
.sort((a, b) =>
|
|
97
|
-
a.merchandise.product.title.localeCompare(
|
|
98
|
-
b.merchandise.product.title,
|
|
99
|
-
),
|
|
100
|
-
)
|
|
101
|
-
.map((item, i) => {
|
|
102
|
-
const merchandiseSearchParams =
|
|
103
|
-
{} as MerchandiseSearchParams;
|
|
104
|
-
|
|
105
|
-
item.merchandise.selectedOptions.forEach(
|
|
106
|
-
({ name, value }) => {
|
|
107
|
-
if (value !== DEFAULT_OPTION) {
|
|
108
|
-
merchandiseSearchParams[name.toLowerCase()] =
|
|
109
|
-
value;
|
|
110
|
-
}
|
|
111
|
-
},
|
|
112
|
-
);
|
|
113
|
-
|
|
114
|
-
const merchandiseUrl = createUrl(
|
|
115
|
-
`/product/${item.merchandise.product.handle}`,
|
|
116
|
-
new URLSearchParams(merchandiseSearchParams),
|
|
117
|
-
);
|
|
118
|
-
|
|
119
|
-
return (
|
|
120
|
-
<li
|
|
121
|
-
key={i}
|
|
122
|
-
className="flex w-full flex-col border-b border-neutral-300 dark:border-neutral-700"
|
|
123
|
-
>
|
|
124
|
-
<div className="relative flex w-full flex-row justify-between px-1 py-4">
|
|
125
|
-
<div className="absolute z-40 -ml-1 -mt-2">
|
|
126
|
-
<DeleteItemButton
|
|
127
|
-
item={item}
|
|
128
|
-
optimisticUpdate={updateCartItem}
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
<div className="flex flex-row">
|
|
132
|
-
<div className="relative h-16 w-16 overflow-hidden rounded-md border border-neutral-300 bg-neutral-300 dark:border-neutral-700 dark:bg-neutral-900 dark:hover:bg-neutral-800">
|
|
133
|
-
<Image
|
|
134
|
-
className="h-full w-full object-cover"
|
|
135
|
-
width={64}
|
|
136
|
-
height={64}
|
|
137
|
-
alt={
|
|
138
|
-
item.merchandise.product.featuredImage
|
|
139
|
-
.altText ||
|
|
140
|
-
item.merchandise.product.title
|
|
141
|
-
}
|
|
142
|
-
src={
|
|
143
|
-
item.merchandise.product.featuredImage.url
|
|
144
|
-
}
|
|
145
|
-
/>
|
|
146
|
-
</div>
|
|
147
|
-
<Link
|
|
148
|
-
href={merchandiseUrl}
|
|
149
|
-
onClick={closeCart}
|
|
150
|
-
className="z-30 ml-2 flex flex-row space-x-4"
|
|
151
|
-
>
|
|
152
|
-
<div className="flex flex-1 flex-col text-base">
|
|
153
|
-
<span className="leading-tight">
|
|
154
|
-
{item.merchandise.product.title}
|
|
155
|
-
</span>
|
|
156
|
-
{item.merchandise.title !==
|
|
157
|
-
DEFAULT_OPTION ? (
|
|
158
|
-
<p className="text-sm text-neutral-500 dark:text-neutral-400">
|
|
159
|
-
{item.merchandise.title}
|
|
160
|
-
</p>
|
|
161
|
-
) : null}
|
|
162
|
-
</div>
|
|
163
|
-
</Link>
|
|
164
|
-
</div>
|
|
165
|
-
<div className="flex h-16 flex-col justify-between">
|
|
166
|
-
<Price
|
|
167
|
-
className="flex justify-end space-y-2 text-right text-sm"
|
|
168
|
-
amount={item.cost.totalAmount.amount}
|
|
169
|
-
currencyCode={
|
|
170
|
-
item.cost.totalAmount.currencyCode
|
|
171
|
-
}
|
|
172
|
-
/>
|
|
173
|
-
<div className="ml-auto flex h-9 flex-row items-center rounded-full border border-neutral-200 dark:border-neutral-700">
|
|
174
|
-
<EditItemQuantityButton
|
|
175
|
-
item={item}
|
|
176
|
-
type="minus"
|
|
177
|
-
optimisticUpdate={updateCartItem}
|
|
178
|
-
/>
|
|
179
|
-
<p className="w-6 text-center">
|
|
180
|
-
<span className="w-full text-sm">
|
|
181
|
-
{item.quantity}
|
|
182
|
-
</span>
|
|
183
|
-
</p>
|
|
184
|
-
<EditItemQuantityButton
|
|
185
|
-
item={item}
|
|
186
|
-
type="plus"
|
|
187
|
-
optimisticUpdate={updateCartItem}
|
|
188
|
-
/>
|
|
189
|
-
</div>
|
|
190
|
-
</div>
|
|
191
|
-
</div>
|
|
192
|
-
</li>
|
|
193
|
-
);
|
|
194
|
-
})}
|
|
195
|
-
</ul>
|
|
196
|
-
<div className="py-4 text-sm text-neutral-500 dark:text-neutral-400">
|
|
197
|
-
<div className="mb-3 flex items-center justify-between border-b border-neutral-200 pb-1 dark:border-neutral-700">
|
|
198
|
-
<p>Taxes</p>
|
|
199
|
-
<Price
|
|
200
|
-
className="text-right text-base text-black dark:text-white"
|
|
201
|
-
amount={cart.cost.totalTaxAmount.amount}
|
|
202
|
-
currencyCode={cart.cost.totalTaxAmount.currencyCode}
|
|
203
|
-
/>
|
|
204
|
-
</div>
|
|
205
|
-
<div className="mb-3 flex items-center justify-between border-b border-neutral-200 pb-1 pt-1 dark:border-neutral-700">
|
|
206
|
-
<p>Shipping</p>
|
|
207
|
-
<p className="text-right">Calculated at checkout</p>
|
|
208
|
-
</div>
|
|
209
|
-
<div className="mb-3 flex items-center justify-between border-b border-neutral-200 pb-1 pt-1 dark:border-neutral-700">
|
|
210
|
-
<p>Total</p>
|
|
211
|
-
<Price
|
|
212
|
-
className="text-right text-base text-black dark:text-white"
|
|
213
|
-
amount={cart.cost.totalAmount.amount}
|
|
214
|
-
currencyCode={cart.cost.totalAmount.currencyCode}
|
|
215
|
-
/>
|
|
216
|
-
</div>
|
|
217
|
-
</div>
|
|
218
|
-
<form action={redirectToCheckout}>
|
|
219
|
-
<CheckoutButton />
|
|
220
|
-
</form>
|
|
221
|
-
</div>
|
|
222
|
-
)}
|
|
223
|
-
</Dialog.Panel>
|
|
224
|
-
</Transition.Child>
|
|
225
|
-
</Dialog>
|
|
226
|
-
</Transition>
|
|
227
|
-
</>
|
|
228
|
-
);
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
function CloseCart({ className }: { className?: string }) {
|
|
232
|
-
return (
|
|
233
|
-
<div className="relative flex h-11 w-11 items-center justify-center rounded-md border border-neutral-200 text-black transition-colors dark:border-neutral-700 dark:text-white">
|
|
234
|
-
<XMarkIcon
|
|
235
|
-
className={clsx(
|
|
236
|
-
"h-6 transition-all ease-in-out hover:scale-110",
|
|
237
|
-
className,
|
|
238
|
-
)}
|
|
239
|
-
/>
|
|
240
|
-
</div>
|
|
241
|
-
);
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function CheckoutButton() {
|
|
245
|
-
const { pending } = useFormStatus();
|
|
246
|
-
|
|
247
|
-
return (
|
|
248
|
-
<button
|
|
249
|
-
className="block w-full rounded-full bg-blue-600 p-3 text-center text-sm font-medium text-white opacity-90 hover:opacity-100"
|
|
250
|
-
type="submit"
|
|
251
|
-
disabled={pending}
|
|
252
|
-
>
|
|
253
|
-
{pending ? <LoadingDots className="bg-white" /> : "Proceed to Checkout"}
|
|
254
|
-
</button>
|
|
255
|
-
);
|
|
256
|
-
}
|
|
@@ -1,104 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import { Dialog, Transition } from "@headlessui/react";
|
|
4
|
-
import Link from "next/link";
|
|
5
|
-
import { usePathname, useSearchParams } from "next/navigation";
|
|
6
|
-
import { Fragment, Suspense, useEffect, useState } from "react";
|
|
7
|
-
|
|
8
|
-
import { Bars3Icon, XMarkIcon } from "@heroicons/react/24/outline";
|
|
9
|
-
import { Menu } from "lib/shopify/types";
|
|
10
|
-
import Search, { SearchSkeleton } from "./search";
|
|
11
|
-
|
|
12
|
-
export default function MobileMenu({ menu }: { menu: Menu[] }) {
|
|
13
|
-
const pathname = usePathname();
|
|
14
|
-
const searchParams = useSearchParams();
|
|
15
|
-
const [isOpen, setIsOpen] = useState(false);
|
|
16
|
-
const openMobileMenu = () => setIsOpen(true);
|
|
17
|
-
const closeMobileMenu = () => setIsOpen(false);
|
|
18
|
-
|
|
19
|
-
useEffect(() => {
|
|
20
|
-
const handleResize = () => {
|
|
21
|
-
if (window.innerWidth > 768) {
|
|
22
|
-
setIsOpen(false);
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
window.addEventListener("resize", handleResize);
|
|
26
|
-
return () => window.removeEventListener("resize", handleResize);
|
|
27
|
-
}, [isOpen]);
|
|
28
|
-
|
|
29
|
-
useEffect(() => {
|
|
30
|
-
setIsOpen(false);
|
|
31
|
-
}, [pathname, searchParams]);
|
|
32
|
-
|
|
33
|
-
return (
|
|
34
|
-
<>
|
|
35
|
-
<button
|
|
36
|
-
onClick={openMobileMenu}
|
|
37
|
-
aria-label="Open mobile menu"
|
|
38
|
-
className="flex h-11 w-11 items-center justify-center rounded-md border border-neutral-200 text-black transition-colors md:hidden dark:border-neutral-700 dark:text-white"
|
|
39
|
-
>
|
|
40
|
-
<Bars3Icon className="h-4" />
|
|
41
|
-
</button>
|
|
42
|
-
<Transition show={isOpen}>
|
|
43
|
-
<Dialog onClose={closeMobileMenu} className="relative z-50">
|
|
44
|
-
<Transition.Child
|
|
45
|
-
as={Fragment}
|
|
46
|
-
enter="transition-all ease-in-out duration-300"
|
|
47
|
-
enterFrom="opacity-0 backdrop-blur-none"
|
|
48
|
-
enterTo="opacity-100 backdrop-blur-[.5px]"
|
|
49
|
-
leave="transition-all ease-in-out duration-200"
|
|
50
|
-
leaveFrom="opacity-100 backdrop-blur-[.5px]"
|
|
51
|
-
leaveTo="opacity-0 backdrop-blur-none"
|
|
52
|
-
>
|
|
53
|
-
<div className="fixed inset-0 bg-black/30" aria-hidden="true" />
|
|
54
|
-
</Transition.Child>
|
|
55
|
-
<Transition.Child
|
|
56
|
-
as={Fragment}
|
|
57
|
-
enter="transition-all ease-in-out duration-300"
|
|
58
|
-
enterFrom="translate-x-[-100%]"
|
|
59
|
-
enterTo="translate-x-0"
|
|
60
|
-
leave="transition-all ease-in-out duration-200"
|
|
61
|
-
leaveFrom="translate-x-0"
|
|
62
|
-
leaveTo="translate-x-[-100%]"
|
|
63
|
-
>
|
|
64
|
-
<Dialog.Panel className="fixed bottom-0 left-0 right-0 top-0 flex h-full w-full flex-col bg-white pb-6 dark:bg-black">
|
|
65
|
-
<div className="p-4">
|
|
66
|
-
<button
|
|
67
|
-
className="mb-4 flex h-11 w-11 items-center justify-center rounded-md border border-neutral-200 text-black transition-colors dark:border-neutral-700 dark:text-white"
|
|
68
|
-
onClick={closeMobileMenu}
|
|
69
|
-
aria-label="Close mobile menu"
|
|
70
|
-
>
|
|
71
|
-
<XMarkIcon className="h-6" />
|
|
72
|
-
</button>
|
|
73
|
-
|
|
74
|
-
<div className="mb-4 w-full">
|
|
75
|
-
<Suspense fallback={<SearchSkeleton />}>
|
|
76
|
-
<Search />
|
|
77
|
-
</Suspense>
|
|
78
|
-
</div>
|
|
79
|
-
{menu.length ? (
|
|
80
|
-
<ul className="flex w-full flex-col">
|
|
81
|
-
{menu.map((item: Menu) => (
|
|
82
|
-
<li
|
|
83
|
-
className="py-2 text-xl text-black transition-colors hover:text-neutral-500 dark:text-white"
|
|
84
|
-
key={item.title}
|
|
85
|
-
>
|
|
86
|
-
<Link
|
|
87
|
-
href={item.path}
|
|
88
|
-
prefetch={true}
|
|
89
|
-
onClick={closeMobileMenu}
|
|
90
|
-
>
|
|
91
|
-
{item.title}
|
|
92
|
-
</Link>
|
|
93
|
-
</li>
|
|
94
|
-
))}
|
|
95
|
-
</ul>
|
|
96
|
-
) : null}
|
|
97
|
-
</div>
|
|
98
|
-
</Dialog.Panel>
|
|
99
|
-
</Transition.Child>
|
|
100
|
-
</Dialog>
|
|
101
|
-
</Transition>
|
|
102
|
-
</>
|
|
103
|
-
);
|
|
104
|
-
}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
"use client";
|
|
2
|
-
|
|
3
|
-
import clsx from "clsx";
|
|
4
|
-
import { ProductOption, ProductVariant } from "lib/shopify/types";
|
|
5
|
-
import { useRouter, useSearchParams } from "next/navigation";
|
|
6
|
-
|
|
7
|
-
type Combination = {
|
|
8
|
-
id: string;
|
|
9
|
-
availableForSale: boolean;
|
|
10
|
-
[key: string]: string | boolean;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
export function VariantSelector({
|
|
14
|
-
options,
|
|
15
|
-
variants,
|
|
16
|
-
}: {
|
|
17
|
-
options: ProductOption[];
|
|
18
|
-
variants: ProductVariant[];
|
|
19
|
-
}) {
|
|
20
|
-
const router = useRouter();
|
|
21
|
-
const searchParams = useSearchParams();
|
|
22
|
-
const hasNoOptionsOrJustOneOption =
|
|
23
|
-
!options.length ||
|
|
24
|
-
(options.length === 1 && options[0]?.values.length === 1);
|
|
25
|
-
|
|
26
|
-
if (hasNoOptionsOrJustOneOption) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
const combinations: Combination[] = variants.map((variant) => ({
|
|
31
|
-
id: variant.id,
|
|
32
|
-
availableForSale: variant.availableForSale,
|
|
33
|
-
...variant.selectedOptions.reduce(
|
|
34
|
-
(accumulator, option) => ({
|
|
35
|
-
...accumulator,
|
|
36
|
-
[option.name.toLowerCase()]: option.value,
|
|
37
|
-
}),
|
|
38
|
-
{},
|
|
39
|
-
),
|
|
40
|
-
}));
|
|
41
|
-
|
|
42
|
-
const updateOption = (name: string, value: string) => {
|
|
43
|
-
const params = new URLSearchParams(searchParams.toString());
|
|
44
|
-
params.set(name, value);
|
|
45
|
-
router.replace(`?${params.toString()}`, { scroll: false });
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
return options.map((option) => (
|
|
49
|
-
<form key={option.id}>
|
|
50
|
-
<dl className="mb-8">
|
|
51
|
-
<dt className="mb-4 text-sm uppercase tracking-wide">{option.name}</dt>
|
|
52
|
-
<dd className="flex flex-wrap gap-3">
|
|
53
|
-
{option.values.map((value) => {
|
|
54
|
-
const optionNameLowerCase = option.name.toLowerCase();
|
|
55
|
-
|
|
56
|
-
// Base option params on current searchParams so we can preserve any other param state.
|
|
57
|
-
const optionParams: Record<string, string> = {};
|
|
58
|
-
searchParams.forEach((v, k) => (optionParams[k] = v));
|
|
59
|
-
optionParams[optionNameLowerCase] = value;
|
|
60
|
-
|
|
61
|
-
// Filter out invalid options and check if the option combination is available for sale.
|
|
62
|
-
const filtered = Object.entries(optionParams).filter(
|
|
63
|
-
([key, value]) =>
|
|
64
|
-
options.find(
|
|
65
|
-
(option) =>
|
|
66
|
-
option.name.toLowerCase() === key &&
|
|
67
|
-
option.values.includes(value),
|
|
68
|
-
),
|
|
69
|
-
);
|
|
70
|
-
const isAvailableForSale = combinations.find((combination) =>
|
|
71
|
-
filtered.every(
|
|
72
|
-
([key, value]) =>
|
|
73
|
-
combination[key] === value && combination.availableForSale,
|
|
74
|
-
),
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
// The option is active if it's in the selected options.
|
|
78
|
-
const isActive = searchParams.get(optionNameLowerCase) === value;
|
|
79
|
-
|
|
80
|
-
return (
|
|
81
|
-
<button
|
|
82
|
-
formAction={() => updateOption(optionNameLowerCase, value)}
|
|
83
|
-
key={value}
|
|
84
|
-
aria-disabled={!isAvailableForSale}
|
|
85
|
-
disabled={!isAvailableForSale}
|
|
86
|
-
title={`${option.name} ${value}${!isAvailableForSale ? " (Out of Stock)" : ""}`}
|
|
87
|
-
className={clsx(
|
|
88
|
-
"flex min-w-[48px] items-center justify-center rounded-full border bg-neutral-100 px-2 py-1 text-sm dark:border-neutral-800 dark:bg-neutral-900",
|
|
89
|
-
{
|
|
90
|
-
"cursor-default ring-2 ring-blue-600": isActive,
|
|
91
|
-
"ring-1 ring-transparent transition duration-300 ease-in-out hover:ring-blue-600":
|
|
92
|
-
!isActive && isAvailableForSale,
|
|
93
|
-
"relative z-10 cursor-not-allowed overflow-hidden bg-neutral-100 text-neutral-500 ring-1 ring-neutral-300 before:absolute before:inset-x-0 before:-z-10 before:h-px before:-rotate-45 before:bg-neutral-300 before:transition-transform dark:bg-neutral-900 dark:text-neutral-400 dark:ring-neutral-700 dark:before:bg-neutral-700":
|
|
94
|
-
!isAvailableForSale,
|
|
95
|
-
},
|
|
96
|
-
)}
|
|
97
|
-
>
|
|
98
|
-
{value}
|
|
99
|
-
</button>
|
|
100
|
-
);
|
|
101
|
-
})}
|
|
102
|
-
</dd>
|
|
103
|
-
</dl>
|
|
104
|
-
</form>
|
|
105
|
-
));
|
|
106
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
Accordion,
|
|
3
|
-
AccordionContent,
|
|
4
|
-
AccordionItem,
|
|
5
|
-
AccordionTrigger,
|
|
6
|
-
} from "@/registry/new-york-v4/ui/accordion"
|
|
7
|
-
|
|
8
|
-
export default function AccordionDemo() {
|
|
9
|
-
return (
|
|
10
|
-
<Accordion
|
|
11
|
-
type="single"
|
|
12
|
-
collapsible
|
|
13
|
-
className="w-full"
|
|
14
|
-
defaultValue="item-1"
|
|
15
|
-
>
|
|
16
|
-
<AccordionItem value="item-1">
|
|
17
|
-
<AccordionTrigger>Product Information</AccordionTrigger>
|
|
18
|
-
<AccordionContent className="flex flex-col gap-4 text-balance">
|
|
19
|
-
<p>
|
|
20
|
-
Our flagship product combines cutting-edge technology with sleek
|
|
21
|
-
design. Built with premium materials, it offers unparalleled
|
|
22
|
-
performance and reliability.
|
|
23
|
-
</p>
|
|
24
|
-
<p>
|
|
25
|
-
Key features include advanced processing capabilities, and an
|
|
26
|
-
intuitive user interface designed for both beginners and experts.
|
|
27
|
-
</p>
|
|
28
|
-
</AccordionContent>
|
|
29
|
-
</AccordionItem>
|
|
30
|
-
<AccordionItem value="item-2">
|
|
31
|
-
<AccordionTrigger>Shipping Details</AccordionTrigger>
|
|
32
|
-
<AccordionContent className="flex flex-col gap-4 text-balance">
|
|
33
|
-
<p>
|
|
34
|
-
We offer worldwide shipping through trusted courier partners.
|
|
35
|
-
Standard delivery takes 3-5 business days, while express shipping
|
|
36
|
-
ensures delivery within 1-2 business days.
|
|
37
|
-
</p>
|
|
38
|
-
<p>
|
|
39
|
-
All orders are carefully packaged and fully insured. Track your
|
|
40
|
-
shipment in real-time through our dedicated tracking portal.
|
|
41
|
-
</p>
|
|
42
|
-
</AccordionContent>
|
|
43
|
-
</AccordionItem>
|
|
44
|
-
<AccordionItem value="item-3">
|
|
45
|
-
<AccordionTrigger>Return Policy</AccordionTrigger>
|
|
46
|
-
<AccordionContent className="flex flex-col gap-4 text-balance">
|
|
47
|
-
<p>
|
|
48
|
-
We stand behind our products with a comprehensive 30-day return
|
|
49
|
-
policy. If you're not completely satisfied, simply return the
|
|
50
|
-
item in its original condition.
|
|
51
|
-
</p>
|
|
52
|
-
<p>
|
|
53
|
-
Our hassle-free return process includes free return shipping and
|
|
54
|
-
full refunds processed within 48 hours of receiving the returned
|
|
55
|
-
item.
|
|
56
|
-
</p>
|
|
57
|
-
</AccordionContent>
|
|
58
|
-
</AccordionItem>
|
|
59
|
-
</Accordion>
|
|
60
|
-
)
|
|
61
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AlertDialog,
|
|
3
|
-
AlertDialogAction,
|
|
4
|
-
AlertDialogCancel,
|
|
5
|
-
AlertDialogContent,
|
|
6
|
-
AlertDialogDescription,
|
|
7
|
-
AlertDialogFooter,
|
|
8
|
-
AlertDialogHeader,
|
|
9
|
-
AlertDialogTitle,
|
|
10
|
-
AlertDialogTrigger,
|
|
11
|
-
} from "@/registry/new-york-v4/ui/alert-dialog"
|
|
12
|
-
import { Button } from "@/registry/new-york-v4/ui/button"
|
|
13
|
-
|
|
14
|
-
export default function AlertDialogDemo() {
|
|
15
|
-
return (
|
|
16
|
-
<AlertDialog>
|
|
17
|
-
<AlertDialogTrigger asChild>
|
|
18
|
-
<Button variant="outline">Show Dialog</Button>
|
|
19
|
-
</AlertDialogTrigger>
|
|
20
|
-
<AlertDialogContent>
|
|
21
|
-
<AlertDialogHeader>
|
|
22
|
-
<AlertDialogTitle>Are you absolutely sure?</AlertDialogTitle>
|
|
23
|
-
<AlertDialogDescription>
|
|
24
|
-
This action cannot be undone. This will permanently delete your
|
|
25
|
-
account and remove your data from our servers.
|
|
26
|
-
</AlertDialogDescription>
|
|
27
|
-
</AlertDialogHeader>
|
|
28
|
-
<AlertDialogFooter>
|
|
29
|
-
<AlertDialogCancel>Cancel</AlertDialogCancel>
|
|
30
|
-
<AlertDialogAction>Continue</AlertDialogAction>
|
|
31
|
-
</AlertDialogFooter>
|
|
32
|
-
</AlertDialogContent>
|
|
33
|
-
</AlertDialog>
|
|
34
|
-
)
|
|
35
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
|
|
3
|
-
import { Button } from "@/registry/new-york-v4/ui/button"
|
|
4
|
-
import {
|
|
5
|
-
Card,
|
|
6
|
-
CardContent,
|
|
7
|
-
CardDescription,
|
|
8
|
-
CardFooter,
|
|
9
|
-
CardHeader,
|
|
10
|
-
CardTitle,
|
|
11
|
-
} from "@/registry/new-york-v4/ui/card"
|
|
12
|
-
import { Input } from "@/registry/new-york-v4/ui/input"
|
|
13
|
-
import { Label } from "@/registry/new-york-v4/ui/label"
|
|
14
|
-
import {
|
|
15
|
-
Select,
|
|
16
|
-
SelectContent,
|
|
17
|
-
SelectItem,
|
|
18
|
-
SelectTrigger,
|
|
19
|
-
SelectValue,
|
|
20
|
-
} from "@/registry/new-york-v4/ui/select"
|
|
21
|
-
|
|
22
|
-
export default function CardWithForm() {
|
|
23
|
-
return (
|
|
24
|
-
<Card className="w-[350px]">
|
|
25
|
-
<CardHeader>
|
|
26
|
-
<CardTitle>Create project</CardTitle>
|
|
27
|
-
<CardDescription>Deploy your new project in one-click.</CardDescription>
|
|
28
|
-
</CardHeader>
|
|
29
|
-
<CardContent>
|
|
30
|
-
<form>
|
|
31
|
-
<div className="grid w-full items-center gap-6">
|
|
32
|
-
<div className="flex flex-col gap-3">
|
|
33
|
-
<Label htmlFor="name">Name</Label>
|
|
34
|
-
<Input id="name" placeholder="Name of your project" />
|
|
35
|
-
</div>
|
|
36
|
-
<div className="flex flex-col gap-3">
|
|
37
|
-
<Label htmlFor="framework">Framework</Label>
|
|
38
|
-
<Select>
|
|
39
|
-
<SelectTrigger id="framework" className="w-full">
|
|
40
|
-
<SelectValue placeholder="Select" />
|
|
41
|
-
</SelectTrigger>
|
|
42
|
-
<SelectContent position="popper">
|
|
43
|
-
<SelectItem value="next">Next.js</SelectItem>
|
|
44
|
-
<SelectItem value="sveltekit">SvelteKit</SelectItem>
|
|
45
|
-
<SelectItem value="astro">Astro</SelectItem>
|
|
46
|
-
<SelectItem value="nuxt">Nuxt.js</SelectItem>
|
|
47
|
-
</SelectContent>
|
|
48
|
-
</Select>
|
|
49
|
-
</div>
|
|
50
|
-
</div>
|
|
51
|
-
</form>
|
|
52
|
-
</CardContent>
|
|
53
|
-
<CardFooter className="flex justify-between">
|
|
54
|
-
<Button variant="outline">Cancel</Button>
|
|
55
|
-
<Button>Deploy</Button>
|
|
56
|
-
</CardFooter>
|
|
57
|
-
</Card>
|
|
58
|
-
)
|
|
59
|
-
}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use client"
|
|
2
|
-
|
|
3
|
-
import * as React from "react"
|
|
4
|
-
import { ChevronsUpDown } from "lucide-react"
|
|
5
|
-
|
|
6
|
-
import { Button } from "@/registry/new-york-v4/ui/button"
|
|
7
|
-
import {
|
|
8
|
-
Collapsible,
|
|
9
|
-
CollapsibleContent,
|
|
10
|
-
CollapsibleTrigger,
|
|
11
|
-
} from "@/registry/new-york-v4/ui/collapsible"
|
|
12
|
-
|
|
13
|
-
export default function CollapsibleDemo() {
|
|
14
|
-
const [isOpen, setIsOpen] = React.useState(false)
|
|
15
|
-
|
|
16
|
-
return (
|
|
17
|
-
<Collapsible
|
|
18
|
-
open={isOpen}
|
|
19
|
-
onOpenChange={setIsOpen}
|
|
20
|
-
className="flex w-[350px] flex-col gap-2"
|
|
21
|
-
>
|
|
22
|
-
<div className="flex items-center justify-between gap-4 px-4">
|
|
23
|
-
<h4 className="text-sm font-semibold">
|
|
24
|
-
@peduarte starred 3 repositories
|
|
25
|
-
</h4>
|
|
26
|
-
<CollapsibleTrigger asChild>
|
|
27
|
-
<Button variant="ghost" size="icon" className="size-8">
|
|
28
|
-
<ChevronsUpDown />
|
|
29
|
-
<span className="sr-only">Toggle</span>
|
|
30
|
-
</Button>
|
|
31
|
-
</CollapsibleTrigger>
|
|
32
|
-
</div>
|
|
33
|
-
<div className="rounded-md border px-4 py-2 font-mono text-sm">
|
|
34
|
-
@radix-ui/primitives
|
|
35
|
-
</div>
|
|
36
|
-
<CollapsibleContent className="flex flex-col gap-2">
|
|
37
|
-
<div className="rounded-md border px-4 py-2 font-mono text-sm">
|
|
38
|
-
@radix-ui/colors
|
|
39
|
-
</div>
|
|
40
|
-
<div className="rounded-md border px-4 py-2 font-mono text-sm">
|
|
41
|
-
@stitches/react
|
|
42
|
-
</div>
|
|
43
|
-
</CollapsibleContent>
|
|
44
|
-
</Collapsible>
|
|
45
|
-
)
|
|
46
|
-
}
|