forked from Weaverse/pilot
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'Weaverse:main' into main
- Loading branch information
Showing
31 changed files
with
1,875 additions
and
2,944 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { X } from "@phosphor-icons/react"; | ||
import { | ||
Close, | ||
Content, | ||
type DialogCloseProps, | ||
type DialogContentProps, | ||
type DialogProps, | ||
type DialogTriggerProps, | ||
Overlay, | ||
Portal, | ||
Root, | ||
Trigger, | ||
} from "@radix-ui/react-dialog"; | ||
import type React from "react"; | ||
import { forwardRef } from "react"; | ||
import { cn } from "~/lib/cn"; | ||
|
||
export let Modal: React.FC<DialogProps> = Root; | ||
|
||
export let ModalTrigger = forwardRef<HTMLButtonElement, DialogTriggerProps>( | ||
({ asChild = true, ...rest }, ref) => { | ||
return <Trigger asChild={asChild} {...rest} ref={ref} />; | ||
} | ||
); | ||
|
||
interface ModalContentProps extends DialogContentProps {} | ||
|
||
export let ModalContent = forwardRef<HTMLDivElement, ModalContentProps>( | ||
({ children, className, ...rest }, ref) => { | ||
return ( | ||
<Portal> | ||
<Overlay className="fixed inset-0 z-10" /> | ||
<Content | ||
{...rest} | ||
ref={ref} | ||
className={cn( | ||
"data-[state='open']:animate-slide-down-and-fade", | ||
"fixed inset-0 z-10 flex items-center overflow-x-hidden bg-gray-900/50 px-4" | ||
)} | ||
> | ||
<div | ||
style={{ maxHeight: "90vh" }} | ||
className={cn( | ||
"animate-slide-down-and-fade relative overflow-hidden", | ||
"w-full mx-auto h-auto max-w-screen-xl" | ||
)} | ||
> | ||
<ModalClose /> | ||
<div className={cn("bg-white shadow p-6", className)}> | ||
{children} | ||
</div> | ||
</div> | ||
</Content> | ||
</Portal> | ||
); | ||
} | ||
); | ||
|
||
export let ModalClose = forwardRef<HTMLButtonElement, DialogCloseProps>( | ||
({ asChild, children, ...rest }, ref) => { | ||
return ( | ||
<Close asChild {...rest} ref={ref}> | ||
{asChild ? ( | ||
children | ||
) : ( | ||
<X className="absolute right-3 top-3 cursor-pointer" size={20} /> | ||
)} | ||
</Close> | ||
); | ||
} | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
import clsx from "clsx"; | ||
|
||
export function ProductTag({ | ||
children, | ||
className, | ||
}: { | ||
children: React.ReactNode; | ||
className?: string; | ||
}) { | ||
return ( | ||
<span className={clsx(["py-1.5 px-2 text-sm", className])}>{children}</span> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { Money } from "@shopify/hydrogen"; | ||
import { CompareAtPrice } from "./compare-at-price"; | ||
import { isDiscounted } from "~/lib/utils"; | ||
import type { | ||
MoneyV2, | ||
ProductVariant, | ||
} from "@shopify/hydrogen/storefront-api-types"; | ||
import clsx from "clsx"; | ||
|
||
export function VariantPrices({ | ||
variant, | ||
showCompareAtPrice = true, | ||
className, | ||
}: { | ||
variant: ProductVariant; | ||
showCompareAtPrice?: boolean; | ||
className?: string; | ||
}) { | ||
if (variant) { | ||
let { price, compareAtPrice } = variant; | ||
return ( | ||
<div className={clsx("flex gap-2", className)}> | ||
<Money withoutTrailingZeros data={price} /> | ||
{showCompareAtPrice && | ||
isDiscounted(price as MoneyV2, compareAtPrice as MoneyV2) && ( | ||
<CompareAtPrice data={compareAtPrice as MoneyV2} /> | ||
)} | ||
</div> | ||
); | ||
} | ||
return null; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.