Skip to content

Commit 4889d4d

Browse files
authored
Merge branch 'Weaverse:main' into main
2 parents 1fedcce + b939cd7 commit 4889d4d

File tree

120 files changed

+889
-1254
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

120 files changed

+889
-1254
lines changed

README.md

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ _Pilot is an innovative Shopify theme, powered by Hydrogen, Remix, and Weaverse,
1313
## Demo
1414

1515
- Live store: https://pilot.weaverse.dev
16-
- Try customizing Pilot on Weaverse Playground: https://studio.weaverse.io/demo
17-
![demo](https://cdn.shopify.com/s/files/1/0693/8201/3220/files/Home.png?v=1695816170)
16+
- Customizing Pilot on Weaverse Studio: https://studio.weaverse.io/demo
17+
![pilot.weaverse.dev](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/pilot.weavverse.dev.png?v=1735017659)
1818

1919
## What's included
2020

@@ -26,9 +26,10 @@ _Pilot is an innovative Shopify theme, powered by Hydrogen, Remix, and Weaverse,
2626
- GraphQL generator
2727
- TypeScript and JavaScript flavors
2828
- Tailwind CSS (via PostCSS)
29+
- Radix UI
2930
- New Shopify customer account API
3031
- Full-featured setup of components and routes
31-
- Fully customizable inside [Weaverse](https://weaverse.io)
32+
- Fully customizable inside [Weaverse Studio](https://weaverse.io)
3233

3334
## Deployment
3435

@@ -45,9 +46,9 @@ _Pilot is an innovative Shopify theme, powered by Hydrogen, Remix, and Weaverse,
4546

4647
1. Install [Weaverse Hydrogen Customizer](https://apps.shopify.com/weaverse) from Shopify App Store.
4748
2. Create new Hydrogen storefront inside Weaverse.
48-
3. Initialize the project and start a local dev server with `@weaverse/cli` tool as instructed in the Weaverse editor.
49-
![Init Weaverse Storefront](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/New_storefront.png?v=1699244454)
50-
4. Open the Weaverse editor to start customizing and tailoring your storefront according to your preferences.
49+
3. Initialize the project and start a local dev server with `@weaverse/cli` tool as instructed in the Weaverse Studio.
50+
![Create new Weaverse Shopify Hydrogen project](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/new_hydrogen_project.png?v=1735008500)
51+
4. Open **Weaverse Studio** to start customizing and tailoring your storefront according to your preferences.
5152

5253
## Features overview
5354

@@ -217,7 +218,7 @@ let Video = forwardRef<HTMLElement, VideoProps>((props, ref) => {
217218
export default Video;
218219
```
219220

220-
Export a `schema` object from the file to define the component's schema with default data and settings to be used in the Weaverse editor.
221+
Export a `schema` object from the file to define the component's schema with default data and settings to be used in the **Weaverse Studio**.
221222

222223
```tsx:app/weaverse/sections/Video.tsx
223224
export let schema: HydrogenComponentSchema = {
@@ -276,11 +277,11 @@ export let loader = async ({weaverse, data}: ComponentLoaderArgs) => {
276277

277278
And then you can use the data in your component with `Component.props.loaderData` 🤗
278279

279-
### Customizing the theme inside Weaverse Editor
280+
### Manage content and style your pages within Weaverse Studio
280281

281-
Weaverse provides a convenient way to customize your theme inside the **Weaverse editor**. You can add new sections, customize existing ones, and change the theme settings.
282+
Weaverse provides a convenient way to customize your theme inside the **Weaverse Studio**. You can add new sections, customize existing ones, and change the theme settings.
282283

283-
![Weaverse Editor](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/playground.jpg?v=1699244445)
284+
![Weaverse Studio](https://cdn.shopify.com/s/files/1/0838/0052/3057/files/weaverse_studio.png?v=1735017805)
284285

285286
### Local development inspects
286287

app/components/account/order-details.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ import { Image, Money } from "@shopify/hydrogen";
44
import clsx from "clsx";
55
import { Link } from "~/components/link";
66
import { Section } from "~/components/section";
7-
import { statusMessage } from "~/lib/utils";
87
import type { loader as orderDetailsLoader } from "~/routes/($locale).account.orders.$id";
8+
import { ORDER_STATUS } from "./orders";
99

1010
export function OrderDetails() {
1111
let { order, lineItems, fulfillmentStatus } =
@@ -15,7 +15,7 @@ export function OrderDetails() {
1515
for (let lineItem of lineItems) {
1616
totalDiscount += lineItem.discountAllocations.reduce(
1717
(acc, curr) => acc + Number.parseFloat(curr.allocatedAmount.amount),
18-
0,
18+
0
1919
);
2020
}
2121

@@ -167,10 +167,10 @@ export function OrderDetails() {
167167
<div
168168
className={clsx(
169169
"mt-3 px-2.5 py-1 text-sm inline-block w-auto",
170-
"text-body-inverse bg-body-subtle",
170+
"text-body-inverse bg-body-subtle"
171171
)}
172172
>
173-
{statusMessage(fulfillmentStatus)}
173+
{ORDER_STATUS[fulfillmentStatus] || fulfillmentStatus}
174174
</div>
175175
)}
176176
</div>

app/components/account/orders.tsx

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,16 @@
11
import { Image, flattenConnection } from "@shopify/hydrogen";
2+
import type { FulfillmentStatus } from "@shopify/hydrogen/customer-account-api-types";
23
import type { OrderCardFragment } from "customer-accountapi.generated";
34
import Link from "~/components/link";
4-
import { statusMessage } from "~/lib/utils";
5+
6+
export const ORDER_STATUS: Record<FulfillmentStatus, string> = {
7+
SUCCESS: "Success",
8+
PENDING: "Pending",
9+
OPEN: "Open",
10+
FAILURE: "Failure",
11+
ERROR: "Error",
12+
CANCELLED: "Cancelled",
13+
};
514

615
type OrderCardsProps = {
716
orders: OrderCardFragment[];
@@ -79,7 +88,7 @@ function OrderCard({ order }: { order: OrderCardFragment }) {
7988
<dt className="sr-only">Fulfillment Status</dt>
8089
<dd className="mt-3">
8190
<span className="px-2.5 py-1 text-xs font-medium border bg-gray-100">
82-
{statusMessage(fulfillmentStatus)}
91+
{ORDER_STATUS[fulfillmentStatus] || fulfillmentStatus}
8392
</span>
8493
</dd>
8594
</>

app/components/breadcrumb.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1-
import { cn } from "~/lib/cn";
1+
import { cn } from "~/utils/cn";
22
import { Link } from "./link";
33

44
export function BreadCrumb({
55
homeLabel = "Home",
66
page,
77
className,
8-
}: { homeLabel?: string; page: string; className?: string }) {
8+
}: {
9+
homeLabel?: string;
10+
page: string;
11+
className?: string;
12+
}) {
913
return (
1014
<div className={cn("flex items-center gap-2 text-body-subtle", className)}>
1115
<Link to="/" className="hover:underline underline-offset-4">

app/components/button.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import type { VariantProps } from "class-variance-authority";
33
import { cva } from "class-variance-authority";
44
import type { HTMLAttributes } from "react";
55
import { forwardRef } from "react";
6-
import { cn } from "~/lib/cn";
6+
import { cn } from "~/utils/cn";
77

88
export let variants = cva(
99
[
@@ -62,7 +62,7 @@ export let variants = cva(
6262
defaultVariants: {
6363
variant: "primary",
6464
},
65-
},
65+
}
6666
);
6767

6868
export interface ButtonStyleProps {

app/modules/cart-best-sellers.tsx renamed to app/components/cart/cart-best-sellers.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import clsx from "clsx";
77
import { useEffect, useId, useMemo } from "react";
88
import { ProductCard } from "~/components/product/product-card";
99
import { Skeleton } from "~/components/skeleton";
10-
import { usePrefixPathWithLocale } from "~/lib/utils";
10+
import { usePrefixPathWithLocale } from "~/hooks/use-prefix-path-with-locale";
1111

1212
interface CartBestSellersProps {
1313
count: number;

app/modules/cart.tsx renamed to app/components/cart/cart.tsx

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import useScroll from "react-use/esm/useScroll";
1818
import type { CartApiQueryFragment } from "storefrontapi.generated";
1919
import { Button } from "~/components/button";
2020
import { Link } from "~/components/link";
21-
import { getImageAspectRatio } from "~/lib/utils";
21+
import { getImageAspectRatio } from "~/utils/image";
2222
import { CartBestSellers } from "./cart-best-sellers";
2323

2424
type CartLine = OptimisticCart<CartApiQueryFragment>["lines"]["nodes"][0];
@@ -43,7 +43,7 @@ export function Cart({
4343
return <CartEmpty hidden={linesCount} onClose={onClose} layout={layout} />;
4444
}
4545

46-
export function CartDetails({
46+
function CartDetails({
4747
layout,
4848
cart,
4949
}: {
@@ -59,7 +59,7 @@ export function CartDetails({
5959
"pb-12 w-full max-w-page mx-auto",
6060
"grid md:grid-cols-2 lg:grid-cols-3 md:items-start",
6161
"gap-8 md:gap-8 lg:gap-12",
62-
],
62+
]
6363
)}
6464
>
6565
<CartLines lines={cart?.lines?.nodes} layout={layout} />
@@ -166,7 +166,7 @@ function CartLines({
166166
className={clsx(
167167
"grid",
168168
layout === "page" && "gap-9",
169-
layout === "drawer" && "gap-5",
169+
layout === "drawer" && "gap-5"
170170
)}
171171
>
172172
{currentLines.map((line) => (
@@ -180,7 +180,10 @@ function CartLines({
180180
function CartCheckoutActions({
181181
checkoutUrl,
182182
layout,
183-
}: { checkoutUrl: string; layout: Layouts }) {
183+
}: {
184+
checkoutUrl: string;
185+
layout: Layouts;
186+
}) {
184187
if (!checkoutUrl) return null;
185188

186189
return (
@@ -213,7 +216,7 @@ function CartSummary({
213216
className={clsx(
214217
layout === "drawer" && "grid gap-4 border-t border-line-subtle pt-4",
215218
layout === "page" &&
216-
"sticky top-nav grid gap-6 p-4 md:px-6 md:translate-y-4 rounded w-full",
219+
"sticky top-nav grid gap-6 p-4 md:px-6 md:translate-y-4 rounded w-full"
217220
)}
218221
>
219222
<h2 id="summary-heading" className="sr-only">
@@ -305,7 +308,7 @@ function CartLineItem({ line, layout }: { line: CartLine; layout: Layouts }) {
305308
<div
306309
className={clsx(
307310
"flex items-center gap-2",
308-
layout === "drawer" && "justify-between",
311+
layout === "drawer" && "justify-between"
309312
)}
310313
>
311314
<CartLineQuantityAdjust line={line} />
@@ -320,7 +323,10 @@ function CartLineItem({ line, layout }: { line: CartLine; layout: Layouts }) {
320323
function ItemRemoveButton({
321324
lineId,
322325
className,
323-
}: { lineId: CartLine["id"]; className?: string }) {
326+
}: {
327+
lineId: CartLine["id"];
328+
className?: string;
329+
}) {
324330
return (
325331
<CartForm
326332
route="/cart"
@@ -330,7 +336,7 @@ function ItemRemoveButton({
330336
<button
331337
className={clsx(
332338
"flex items-center justify-center w-8 h-8 border-none",
333-
className,
339+
className
334340
)}
335341
type="submit"
336342
>
@@ -452,7 +458,7 @@ function CartLinePrice({
452458
);
453459
}
454460

455-
export function CartEmpty({
461+
function CartEmpty({
456462
hidden = false,
457463
layout = "drawer",
458464
onClose,
@@ -474,7 +480,7 @@ export function CartEmpty({
474480
layout === "page" && [
475481
hidden ? "" : "grid",
476482
"pb-12 w-full md:items-start gap-4 md:gap-8 lg:gap-12",
477-
],
483+
]
478484
)}
479485
hidden={hidden}
480486
>

app/components/compare-at-price.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { useMoney } from "@shopify/hydrogen";
22
import type { MoneyV2 } from "@shopify/hydrogen/storefront-api-types";
3-
import { cn } from "~/lib/cn";
3+
import { cn } from "~/utils/cn";
44

55
export function CompareAtPrice({
66
data,

app/components/heading.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import type { VariantProps } from "class-variance-authority";
77
import { cva } from "class-variance-authority";
88
import type { CSSProperties } from "react";
99
import { forwardRef } from "react";
10-
import { cn } from "~/lib/cn";
10+
import { cn } from "~/utils/cn";
1111

1212
let fontSizeVariants = cva("", {
1313
variants: {
@@ -132,7 +132,7 @@ let Heading = forwardRef<
132132
style={style}
133133
className={cn(
134134
size === "custom" && fontSizeVariants({ mobileSize, desktopSize }),
135-
variants({ size, weight, letterSpacing, alignment, className }),
135+
variants({ size, weight, letterSpacing, alignment, className })
136136
)}
137137
>
138138
{content}

app/components/layout/cart-drawer.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import clsx from "clsx";
66
import { Suspense, useState } from "react";
77
import Link from "~/components/link";
88
import { ScrollArea } from "~/components/scroll-area";
9-
import { Cart } from "~/modules/cart";
9+
import { Cart } from "~/components/cart/cart";
1010
import type { RootLoader } from "~/root";
1111

1212
export let openCartDrawer = () => {};
@@ -53,7 +53,7 @@ export function CartDrawer() {
5353
"text-sm leading-none text-center font-medium",
5454
"transition-colors duration-300",
5555
"group-hover/header:bg-[--color-header-text]",
56-
"group-hover/header:text-[--color-header-bg]",
56+
"group-hover/header:text-[--color-header-bg]"
5757
)}
5858
>
5959
<span className="-mr-px">{cart?.totalQuantity}</span>

app/components/layout/country-selector.tsx

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,9 @@ import type { CartBuyerIdentityInput } from "@shopify/hydrogen/storefront-api-ty
1111
import { useEffect, useRef } from "react";
1212
import ReactCountryFlag from "react-country-flag";
1313
import { useInView } from "react-intersection-observer";
14-
import { getCountryUrlPath } from "~/lib/locale";
15-
import type { Localizations } from "~/lib/type";
16-
import { DEFAULT_LOCALE } from "~/lib/utils";
14+
import { DEFAULT_LOCALE } from "~/utils/const";
1715
import type { RootLoader } from "~/root";
16+
import type { Locale, Localizations } from "~/types/locale";
1817

1918
export function CountrySelector() {
2019
let fetcher = useFetcher();
@@ -24,7 +23,7 @@ export function CountrySelector() {
2423
let { pathname, search } = useLocation();
2524
let pathWithoutLocale = `${pathname.replace(
2625
selectedLocale.pathPrefix,
27-
"",
26+
""
2827
)}${search}`;
2928

3029
let countries = (fetcher.data ?? {}) as Localizations;
@@ -139,3 +138,20 @@ export function CountrySelector() {
139138
</div>
140139
);
141140
}
141+
142+
function getCountryUrlPath({
143+
countryLocale,
144+
defaultLocalePrefix,
145+
pathWithoutLocale,
146+
}: {
147+
countryLocale: Locale;
148+
pathWithoutLocale: string;
149+
defaultLocalePrefix: string;
150+
}) {
151+
let countryPrefixPath = "";
152+
let countryLocalePrefix = `${countryLocale.language}-${countryLocale.country}`;
153+
if (countryLocalePrefix !== defaultLocalePrefix) {
154+
countryPrefixPath = `/${countryLocalePrefix.toLowerCase()}`;
155+
}
156+
return `${countryPrefixPath}${pathWithoutLocale}`;
157+
}

app/components/layout/desktop-menu.tsx

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,8 @@ import clsx from "clsx";
66
import { useState } from "react";
77
import Link from "~/components/link";
88
import { useShopMenu } from "~/hooks/use-shop-menu";
9-
import { cn } from "~/lib/cn";
10-
import { getMaxDepth } from "~/lib/menu";
11-
import type { SingleMenuItem } from "~/lib/type";
9+
import { cn } from "~/utils/cn";
10+
import type { SingleMenuItem } from "~/types/menu";
1211

1312
export function DesktopMenu() {
1413
let { headerMenu } = useShopMenu();
@@ -155,7 +154,7 @@ function MegaMenu({ items }: { items: SingleMenuItem[] }) {
155154
))}
156155
</div>
157156
</SlideIn>
158-
),
157+
)
159158
)}
160159
</div>
161160
);
@@ -171,7 +170,7 @@ function SlideIn(props: {
171170
<div
172171
className={cn(
173172
"opacity-0 animate-slide-left [animation-delay:calc(var(--idx)*0.1s+0.1s)]",
174-
className,
173+
className
175174
)}
176175
style={
177176
{
@@ -185,3 +184,10 @@ function SlideIn(props: {
185184
</div>
186185
);
187186
}
187+
188+
function getMaxDepth(item: { items: any[] }): number {
189+
if (item.items?.length > 0) {
190+
return Math.max(...item.items.map(getMaxDepth)) + 1;
191+
}
192+
return 1;
193+
}

0 commit comments

Comments
 (0)