mirror of
https://github.com/vercel/commerce.git
synced 2025-07-22 20:26:49 +00:00
fix conflicts
This commit is contained in:
@@ -1,8 +1,9 @@
|
||||
import { ChangeEvent, useEffect, useState } from 'react'
|
||||
import Image from 'next/image'
|
||||
import { Trash, Plus, Minus } from '@components/icon'
|
||||
import usePrice from '@lib/bigcommerce/use-price'
|
||||
import useUpdateItem from '@lib/bigcommerce/cart/use-update-item'
|
||||
import useRemoveItem from '@lib/bigcommerce/cart/use-remove-item'
|
||||
import { ChangeEvent, useEffect, useState } from 'react'
|
||||
import s from './CartItem.module.css'
|
||||
|
||||
const CartItem = ({
|
||||
@@ -56,7 +57,13 @@ const CartItem = ({
|
||||
return (
|
||||
<li className="flex flex-row space-x-8 py-6">
|
||||
<div className="w-12 h-12 bg-violet relative overflow-hidden">
|
||||
<img className={s.productImage} src={item.image_url} />
|
||||
<Image
|
||||
src={item.image_url}
|
||||
width={60}
|
||||
height={60}
|
||||
// The cart item image is already optimized and very small in size
|
||||
unoptimized
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1 flex flex-col justify-between text-base">
|
||||
<span className="font-bold mb-3">{item.name}</span>
|
||||
|
3
components/core/Featurebar/Featurebar.module.css
Normal file
3
components/core/Featurebar/Featurebar.module.css
Normal file
@@ -0,0 +1,3 @@
|
||||
.root {
|
||||
@apply text-center p-6 bg-primary text-base text-sm md:flex md:text-left flex-row justify-center items-center font-medium fixed bottom-0 w-full z-30;
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
import cn from 'classnames'
|
||||
import { FC } from 'react'
|
||||
|
||||
import s from './Featurebar.module.css'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
title: string
|
||||
@@ -17,8 +19,10 @@ const Featurebar: FC<Props> = ({
|
||||
hide,
|
||||
}) => {
|
||||
const rootClassName = cn(
|
||||
'transition-transform transform duration-500 text-center ease-out p-6 bg-primary text-base text-sm md:flex md:text-left flex-row justify-center items-center font-medium fixed bottom-0 w-full z-10',
|
||||
{ 'translate-y-full': hide },
|
||||
s.root,
|
||||
{
|
||||
'transition-transform transform duration-500 ease-out translate-y-full': hide,
|
||||
},
|
||||
className
|
||||
)
|
||||
return (
|
||||
|
@@ -1,11 +1,11 @@
|
||||
import { FC } from 'react'
|
||||
import cn from 'classnames'
|
||||
import Link from 'next/link'
|
||||
import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages'
|
||||
import getSlug from '@utils/get-slug'
|
||||
import { Github } from '@components/icon'
|
||||
import { Logo, Container } from '@components/ui'
|
||||
import { Github, DoubleChevron } from '@components/icon'
|
||||
|
||||
import type { Page } from '@lib/bigcommerce/api/operations/get-all-pages'
|
||||
import { I18nWidget } from '@components/core'
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: any
|
||||
@@ -82,13 +82,7 @@ const Footer: FC<Props> = ({ className, pages }) => {
|
||||
<div className="col-span-1 lg:col-span-6 flex items-start lg:justify-end text-primary">
|
||||
<div className="flex space-x-6 items-center h-10">
|
||||
<Github />
|
||||
<div className="h-10 px-2 rounded-md border border-accents-2 flex items-center space-x-2 justify-center">
|
||||
<img className="" src="/flag-us.png" />
|
||||
<span>English</span>
|
||||
<span className="">
|
||||
<DoubleChevron />
|
||||
</span>
|
||||
</div>
|
||||
<I18nWidget />
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
23
components/core/I18nWidget/I18nWidget.module.css
Normal file
23
components/core/I18nWidget/I18nWidget.module.css
Normal file
@@ -0,0 +1,23 @@
|
||||
.root {
|
||||
@apply relative;
|
||||
}
|
||||
|
||||
.button {
|
||||
@apply h-10 px-2 rounded-md border border-accents-2 flex items-center space-x-2 justify-center;
|
||||
}
|
||||
|
||||
.dropdownMenu {
|
||||
@apply fixed right-0 top-12 mt-2 origin-top-right outline-none bg-primary z-40 w-full h-full;
|
||||
|
||||
@screen lg {
|
||||
@apply absolute border border-accents-1 shadow-lg w-56 h-auto;
|
||||
}
|
||||
}
|
||||
|
||||
.item {
|
||||
@apply flex cursor-pointer px-6 py-3 block hover:bg-accents-1 transition ease-in-out duration-150 text-base leading-6 font-medium text-gray-900 items-center;
|
||||
text-transform: capitalize;
|
||||
}
|
||||
|
||||
.item.active {
|
||||
}
|
38
components/core/I18nWidget/I18nWidget.tsx
Normal file
38
components/core/I18nWidget/I18nWidget.tsx
Normal file
@@ -0,0 +1,38 @@
|
||||
import { FC } from 'react'
|
||||
import s from './I18nWidget.module.css'
|
||||
import { Menu } from '@headlessui/react'
|
||||
import { DoubleChevron } from '@components/icon'
|
||||
import cn from 'classnames'
|
||||
|
||||
const I18nWidget: FC = () => {
|
||||
return (
|
||||
<nav className={s.root}>
|
||||
<Menu>
|
||||
<Menu.Button className={s.button}>
|
||||
<img className="" src="/flag-us.png" />
|
||||
<span>English</span>
|
||||
<span className="">
|
||||
<DoubleChevron />
|
||||
</span>
|
||||
</Menu.Button>
|
||||
<Menu.Items className={s.dropdownMenu}>
|
||||
<Menu.Item>
|
||||
{({ active }) => (
|
||||
<a
|
||||
className={cn(s.item, { [s.active]: active })}
|
||||
href="#"
|
||||
onClick={(e) => {
|
||||
e.preventDefault()
|
||||
}}
|
||||
>
|
||||
Español
|
||||
</a>
|
||||
)}
|
||||
</Menu.Item>
|
||||
</Menu.Items>
|
||||
</Menu>
|
||||
</nav>
|
||||
)
|
||||
}
|
||||
|
||||
export default I18nWidget
|
1
components/core/I18nWidget/index.ts
Normal file
1
components/core/I18nWidget/index.ts
Normal file
@@ -0,0 +1 @@
|
||||
export { default } from './I18nWidget'
|
@@ -8,7 +8,7 @@ import Button from '@components/ui/Button'
|
||||
import { CartSidebarView } from '@components/cart'
|
||||
import { useUI } from '@components/ui/context'
|
||||
import s from './Layout.module.css'
|
||||
|
||||
import { usePreventScroll } from '@react-aria/overlays'
|
||||
interface Props {
|
||||
pageProps: {
|
||||
pages?: Page[]
|
||||
@@ -16,10 +16,11 @@ interface Props {
|
||||
}
|
||||
|
||||
const Layout: FC<Props> = ({ children, pageProps }) => {
|
||||
const { displaySidebar, closeSidebar } = useUI()
|
||||
const { displaySidebar, displayDropdown, closeSidebar } = useUI()
|
||||
const [acceptedCookies, setAcceptedCookies] = useState(false)
|
||||
const [hasScrolled, setHasScrolled] = useState(false)
|
||||
|
||||
// TODO: Update code, add throttle and more.
|
||||
useEffect(() => {
|
||||
const offset = 0
|
||||
function handleScroll() {
|
||||
@@ -34,6 +35,11 @@ const Layout: FC<Props> = ({ children, pageProps }) => {
|
||||
}
|
||||
}, [])
|
||||
|
||||
console.log(displaySidebar, displayDropdown)
|
||||
usePreventScroll({
|
||||
isDisabled: !displaySidebar,
|
||||
})
|
||||
|
||||
return (
|
||||
<CommerceProvider locale="en-us">
|
||||
<div className={cn(s.root)}>
|
||||
@@ -49,9 +55,11 @@ const Layout: FC<Props> = ({ children, pageProps }) => {
|
||||
</header>
|
||||
<main className="fit">{children}</main>
|
||||
<Footer pages={pageProps.pages} />
|
||||
<Sidebar show={displaySidebar} close={closeSidebar}>
|
||||
|
||||
<Sidebar open={displaySidebar} onClose={closeSidebar}>
|
||||
<CartSidebarView />
|
||||
</Sidebar>
|
||||
|
||||
<Featurebar
|
||||
title="This site uses cookies to improve your experience."
|
||||
description="By clicking, you agree to our Privacy Policy."
|
||||
|
@@ -5,24 +5,14 @@ import cn from 'classnames'
|
||||
import s from './DropdownMenu.module.css'
|
||||
import { Moon, Sun } from '@components/icon'
|
||||
import { Menu, Transition } from '@headlessui/react'
|
||||
import { usePreventScroll } from '@react-aria/overlays'
|
||||
|
||||
interface DropdownMenuProps {
|
||||
onClose: () => void
|
||||
open: boolean
|
||||
}
|
||||
|
||||
const DropdownMenu: FC<DropdownMenuProps> = ({
|
||||
onClose,
|
||||
children,
|
||||
open = false,
|
||||
...props
|
||||
}) => {
|
||||
const DropdownMenu: FC<DropdownMenuProps> = ({ open = false }) => {
|
||||
const { theme, setTheme } = useTheme()
|
||||
|
||||
usePreventScroll({
|
||||
isDisabled: !open,
|
||||
})
|
||||
|
||||
return (
|
||||
<Transition
|
||||
show={open}
|
||||
|
@@ -19,14 +19,7 @@ const countItems = (count: number, items: any[]) =>
|
||||
|
||||
const UserNav: FC<Props> = ({ className, children, ...props }) => {
|
||||
const { data } = useCart()
|
||||
const {
|
||||
openSidebar,
|
||||
closeSidebar,
|
||||
displaySidebar,
|
||||
displayDropdown,
|
||||
openDropdown,
|
||||
closeDropdown,
|
||||
} = useUI()
|
||||
const { openSidebar, closeSidebar, displaySidebar } = useUI()
|
||||
|
||||
const itemsCount = Object.values(data?.line_items ?? {}).reduce(countItems, 0)
|
||||
let ref = useRef() as React.MutableRefObject<HTMLInputElement>
|
||||
@@ -53,14 +46,16 @@ const UserNav: FC<Props> = ({ className, children, ...props }) => {
|
||||
</Link>
|
||||
<li className={s.item}>
|
||||
<Menu>
|
||||
{({ open }) => (
|
||||
<>
|
||||
<Menu.Button className="inline-flex justify-center rounded-full">
|
||||
<Avatar />
|
||||
</Menu.Button>
|
||||
<DropdownMenu onClose={closeDropdown} open={open} />
|
||||
</>
|
||||
)}
|
||||
{({ open }) => {
|
||||
return (
|
||||
<>
|
||||
<Menu.Button className="inline-flex justify-center rounded-full">
|
||||
<Avatar />
|
||||
</Menu.Button>
|
||||
<DropdownMenu open={open} />
|
||||
</>
|
||||
)
|
||||
}}
|
||||
</Menu>
|
||||
</li>
|
||||
</ul>
|
||||
|
@@ -8,3 +8,4 @@ export { default as UserNav } from './UserNav'
|
||||
export { default as Toggle } from './Toggle'
|
||||
export { default as Head } from './Head'
|
||||
export { default as HTMLContent } from './HTMLContent'
|
||||
export { default as I18nWidget } from './I18nWidget'
|
||||
|
@@ -11,9 +11,9 @@ const DoubleChevron = ({ ...props }) => {
|
||||
<path
|
||||
d="M16 8.90482L12 4L8 8.90482M8 15.0952L12 20L16 15.0952"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
|
@@ -5,11 +5,11 @@ const Moon = ({ ...props }) => {
|
||||
width="24"
|
||||
height="24"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
fill="none"
|
||||
shape-rendering="geometricPrecision"
|
||||
shapeRendering="geometricPrecision"
|
||||
{...props}
|
||||
>
|
||||
<path d="M21 12.79A9 9 0 1111.21 3 7 7 0 0021 12.79z" />
|
||||
|
@@ -11,16 +11,16 @@ const RightArrow = ({ ...props }) => {
|
||||
<path
|
||||
d="M5 12H19"
|
||||
stroke="white"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
<path
|
||||
d="M12 5L19 12L12 19"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
)
|
||||
|
@@ -5,11 +5,11 @@ const Sun = ({ ...props }) => {
|
||||
width="24"
|
||||
height="24"
|
||||
stroke="currentColor"
|
||||
stroke-width="1.5"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
strokeWidth="1.5"
|
||||
strokeLinecap="round"
|
||||
strokeLinejoin="round"
|
||||
fill="none"
|
||||
shape-rendering="geometricPrecision"
|
||||
shapeRendering="geometricPrecision"
|
||||
{...props}
|
||||
>
|
||||
<circle cx="12" cy="12" r="5" />
|
||||
|
@@ -87,9 +87,11 @@
|
||||
}
|
||||
|
||||
& .productTitle {
|
||||
width: 18vw;
|
||||
margin-top: -7px;
|
||||
font-size: 1rem;
|
||||
& span {
|
||||
line-height: 3;
|
||||
}
|
||||
}
|
||||
|
||||
& .productPrice {
|
||||
@@ -98,13 +100,12 @@
|
||||
}
|
||||
|
||||
.productTitle {
|
||||
@apply pt-4 leading-8;
|
||||
width: 400px;
|
||||
@apply pt-2 max-w-full w-full;
|
||||
font-size: 2rem;
|
||||
letter-spacing: 0.4px;
|
||||
|
||||
& span {
|
||||
@apply inline p-4 bg-primary text-primary font-bold;
|
||||
@apply py-4 px-6 bg-primary text-primary font-bold;
|
||||
font-size: inherit;
|
||||
letter-spacing: inherit;
|
||||
box-decoration-break: clone;
|
||||
@@ -113,10 +114,22 @@
|
||||
}
|
||||
|
||||
.productPrice {
|
||||
@apply py-4 px-4 bg-primary text-base font-semibold inline-block text-sm leading-6;
|
||||
@apply py-4 px-6 bg-primary text-base font-semibold inline-block text-sm leading-6;
|
||||
letter-spacing: 0.4px;
|
||||
}
|
||||
|
||||
.wishlistButton {
|
||||
@apply w-10 h-10 flex ml-auto items-center justify-center bg-primary text-base font-semibold inline-block text-xs leading-6 cursor-pointer;
|
||||
}
|
||||
|
||||
.imageContainer {
|
||||
@apply absolute z-10 inset-0 flex items-center justify-center;
|
||||
|
||||
& > div {
|
||||
@apply h-full;
|
||||
& > div {
|
||||
@apply h-full;
|
||||
padding-bottom: 0 !important;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,30 +1,46 @@
|
||||
import cn from 'classnames'
|
||||
import s from './ProductCard.module.css'
|
||||
import { FC, ReactNode, Component } from 'react'
|
||||
import cn from 'classnames'
|
||||
import Image from 'next/image'
|
||||
import Link from 'next/link'
|
||||
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-all-products'
|
||||
import { Heart } from '@components/icon'
|
||||
import Link from 'next/link'
|
||||
import s from './ProductCard.module.css'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: ReactNode[] | Component[] | any[]
|
||||
product: ProductNode
|
||||
variant?: 'slim' | 'simple'
|
||||
imgWidth: number
|
||||
imgHeight: number
|
||||
priority?: boolean
|
||||
}
|
||||
|
||||
const ProductCard: FC<Props> = ({ className, product: p, variant }) => {
|
||||
const ProductCard: FC<Props> = ({
|
||||
className,
|
||||
product: p,
|
||||
variant,
|
||||
imgWidth,
|
||||
imgHeight,
|
||||
priority,
|
||||
}) => {
|
||||
const src = p.images.edges?.[0]?.node.urlOriginal!
|
||||
|
||||
if (variant === 'slim') {
|
||||
return (
|
||||
<div className="relative overflow-hidden box-border">
|
||||
<img
|
||||
className="object-scale-down h-48"
|
||||
src={p.images.edges?.[0]?.node.urlSmall}
|
||||
/>
|
||||
<div className="absolute inset-0 flex items-center justify-end mr-8">
|
||||
<div className="absolute inset-0 flex items-center justify-end mr-8 z-20">
|
||||
<span className="bg-black text-white inline-block p-3 font-bold text-xl break-words">
|
||||
{p.name}
|
||||
</span>
|
||||
</div>
|
||||
<Image
|
||||
src={src}
|
||||
width={imgWidth}
|
||||
height={imgHeight}
|
||||
priority={priority}
|
||||
quality="90"
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
@@ -34,15 +50,9 @@ const ProductCard: FC<Props> = ({ className, product: p, variant }) => {
|
||||
<a
|
||||
className={cn(s.root, { [s.simple]: variant === 'simple' }, className)}
|
||||
>
|
||||
<div className="absolute z-10 inset-0 flex items-center justify-center">
|
||||
<img
|
||||
className={cn('w-full object-cover', s['product-image'])}
|
||||
src={p.images.edges?.[0]?.node.urlXL}
|
||||
/>
|
||||
</div>
|
||||
<div className={s.squareBg} />
|
||||
<div className="flex flex-row justify-between box-border w-full z-10 relative">
|
||||
<div className="absolute top-0 left-0">
|
||||
<div className="flex flex-row justify-between box-border w-full z-20 absolute">
|
||||
<div className="absolute top-0 left-0 pr-16 max-w-full">
|
||||
<h3 className={s.productTitle}>
|
||||
<span>{p.name}</span>
|
||||
</h3>
|
||||
@@ -52,6 +62,16 @@ const ProductCard: FC<Props> = ({ className, product: p, variant }) => {
|
||||
<Heart />
|
||||
</div>
|
||||
</div>
|
||||
<div className={cn(s.imageContainer)}>
|
||||
<Image
|
||||
className={cn('w-full object-cover', s['product-image'])}
|
||||
src={src}
|
||||
width={imgWidth}
|
||||
height={imgHeight}
|
||||
priority={priority}
|
||||
quality="90"
|
||||
/>
|
||||
</div>
|
||||
</a>
|
||||
</Link>
|
||||
)
|
||||
|
@@ -28,6 +28,7 @@
|
||||
|
||||
.positionIndicatorsContainer {
|
||||
@apply hidden;
|
||||
|
||||
@screen sm {
|
||||
@apply block absolute bottom-6 left-1/2 -translate-x-1/2 transform;
|
||||
}
|
||||
@@ -35,14 +36,6 @@
|
||||
|
||||
.positionIndicator {
|
||||
@apply rounded-full p-2;
|
||||
|
||||
/* :hover .dot {
|
||||
@apply bg-hover-2;
|
||||
}
|
||||
|
||||
:focus .dot {
|
||||
@apply outline-none;
|
||||
} */
|
||||
}
|
||||
|
||||
.dot {
|
||||
|
@@ -1,5 +1,4 @@
|
||||
import { useKeenSlider } from 'keen-slider/react'
|
||||
import Image from 'next/image'
|
||||
import React, { Children, FC, isValidElement, useState } from 'react'
|
||||
import cn from 'classnames'
|
||||
|
||||
|
@@ -8,15 +8,15 @@
|
||||
|
||||
.productDisplay {
|
||||
@apply relative flex px-0 pb-0 relative box-border col-span-1 bg-violet;
|
||||
margin-right: -2rem;
|
||||
margin-left: -2rem;
|
||||
min-height: 400px;
|
||||
min-height: 600px;
|
||||
|
||||
@screen md {
|
||||
min-height: 700px;
|
||||
}
|
||||
|
||||
@screen lg {
|
||||
margin-right: -2rem;
|
||||
margin-left: -2rem;
|
||||
@apply mx-0 col-span-6;
|
||||
min-height: 100%;
|
||||
height: 100%;
|
||||
@@ -28,7 +28,11 @@
|
||||
}
|
||||
|
||||
.nameBox {
|
||||
@apply absolute top-6 left-6 z-20;
|
||||
@apply absolute top-6 left-0 z-20 pr-16;
|
||||
|
||||
@screen lg {
|
||||
@apply left-6 pr-16;
|
||||
}
|
||||
|
||||
& .name {
|
||||
@apply px-6 py-2 bg-primary text-primary font-bold;
|
||||
@@ -43,16 +47,16 @@
|
||||
@screen lg {
|
||||
& .name,
|
||||
& .price {
|
||||
@apply bg-hover-1 text-white;
|
||||
@apply bg-violet-light text-white;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.sidebar {
|
||||
@apply flex flex-col col-span-1 mx-auto max-w-8xl px-12 w-full;
|
||||
@apply flex flex-col col-span-1 mx-auto max-w-8xl px-6 w-full;
|
||||
|
||||
@screen lg {
|
||||
@apply col-span-5 pl-12 pt-20;
|
||||
@apply col-span-6 pt-20;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -60,6 +64,15 @@
|
||||
@apply absolute z-10 inset-0 flex items-center justify-center overflow-x-hidden;
|
||||
}
|
||||
|
||||
.imageContainer {
|
||||
& > div {
|
||||
@apply h-full;
|
||||
& > div {
|
||||
@apply h-full;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.img {
|
||||
@apply w-full h-auto max-h-full object-cover;
|
||||
}
|
||||
|
@@ -1,14 +1,17 @@
|
||||
import cn from 'classnames'
|
||||
import { NextSeo } from 'next-seo'
|
||||
import s from './ProductView.module.css'
|
||||
import { FC, useState } from 'react'
|
||||
import cn from 'classnames'
|
||||
import Image from 'next/image'
|
||||
import { NextSeo } from 'next-seo'
|
||||
|
||||
import s from './ProductView.module.css'
|
||||
import { Heart } from '@components/icon'
|
||||
import { useUI } from '@components/ui/context'
|
||||
import { Button, Container } from '@components/ui'
|
||||
import { Swatch, ProductSlider } from '@components/product'
|
||||
|
||||
import useAddItem from '@lib/bigcommerce/cart/use-add-item'
|
||||
import type { ProductNode } from '@lib/bigcommerce/api/operations/get-product'
|
||||
import { getProductOptions } from '../helpers'
|
||||
import { Heart } from '@components/icon'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
@@ -52,7 +55,7 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
description: product.description,
|
||||
images: [
|
||||
{
|
||||
url: product.images.edges?.[0]?.node.urlXL || '',
|
||||
url: product.images.edges?.[0]?.node.urlOriginal!,
|
||||
width: 800,
|
||||
height: 600,
|
||||
alt: product.name,
|
||||
@@ -73,14 +76,17 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
|
||||
<div className={s.sliderContainer}>
|
||||
<ProductSlider>
|
||||
{/** TODO: Change with Image Component **/}
|
||||
{product.images.edges?.map((image, i) => (
|
||||
<img
|
||||
key={image?.node.urlSmall}
|
||||
className={s.img}
|
||||
src={image?.node.urlXL}
|
||||
loading={i === 0 ? 'eager' : 'lazy'}
|
||||
/>
|
||||
<div key={image?.node.urlXL} className={s.imageContainer}>
|
||||
<Image
|
||||
className={s.img}
|
||||
src={image?.node.urlXL!}
|
||||
width={1050}
|
||||
height={1050}
|
||||
priority={i === 0}
|
||||
quality="90"
|
||||
/>
|
||||
</div>
|
||||
))}
|
||||
</ProductSlider>
|
||||
</div>
|
||||
@@ -92,12 +98,12 @@ const ProductView: FC<Props> = ({ product, className }) => {
|
||||
<div className="pb-4" key={opt.displayName}>
|
||||
<h2 className="uppercase font-medium">{opt.displayName}</h2>
|
||||
<div className="flex flex-row py-4">
|
||||
{opt.values.map((v: any) => {
|
||||
{opt.values.map((v: any, i: number) => {
|
||||
const active = choices[opt.displayName]
|
||||
|
||||
return (
|
||||
<Swatch
|
||||
key={v.entityId}
|
||||
key={`${v.entityId}-${i}`}
|
||||
active={v.label === active}
|
||||
variant={opt.displayName}
|
||||
color={v.hexColors ? v.hexColors[0] : ''}
|
||||
|
@@ -9,7 +9,9 @@ interface Props {
|
||||
}
|
||||
|
||||
const Container: FC<Props> = ({ children, className, el = 'div', clean }) => {
|
||||
const rootClassName = cn(className, { 'mx-auto max-w-8xl px-12': !clean })
|
||||
const rootClassName = cn(className, {
|
||||
'mx-auto max-w-8xl px-6': !clean,
|
||||
})
|
||||
|
||||
let Component: React.ComponentType<React.HTMLAttributes<
|
||||
HTMLDivElement
|
||||
|
6
components/ui/Hero/Hero.module.css
Normal file
6
components/ui/Hero/Hero.module.css
Normal file
@@ -0,0 +1,6 @@
|
||||
.root {
|
||||
@apply mx-auto grid grid-cols-1 py-32 gap-4;
|
||||
@screen md {
|
||||
@apply grid-cols-2;
|
||||
}
|
||||
}
|
@@ -1,6 +1,8 @@
|
||||
import React, { FC } from 'react'
|
||||
import { Container } from '@components/ui'
|
||||
import { RightArrow } from '@components/icon'
|
||||
import s from './Hero.module.css'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
headline: string
|
||||
@@ -9,17 +11,21 @@ interface Props {
|
||||
|
||||
const Hero: FC<Props> = ({ headline, description }) => {
|
||||
return (
|
||||
<div className="mx-auto grid grid-cols-2 bg-black py-32">
|
||||
<div className="bg-black">
|
||||
<Container>
|
||||
<h2 className="text-4xl leading-10 font-extrabold text-white sm:text-5xl sm:leading-none sm:tracking-tight lg:text-6xl">
|
||||
{headline}
|
||||
</h2>
|
||||
<div className="flex flex-col justify-between">
|
||||
<p className="mt-5 text-xl leading-7 text-accent-2">{description}</p>
|
||||
<a className="text-white pt-3 font-bold hover:underline flex flex-row cursor-pointer">
|
||||
<span>Read it here</span>
|
||||
<RightArrow width="20" heigh="20" className="ml-1" />
|
||||
</a>
|
||||
<div className={s.root}>
|
||||
<h2 className="text-4xl leading-10 font-extrabold text-white sm:text-5xl sm:leading-none sm:tracking-tight lg:text-6xl">
|
||||
{headline}
|
||||
</h2>
|
||||
<div className="flex flex-col justify-between">
|
||||
<p className="mt-5 text-xl leading-7 text-accent-2 text-white">
|
||||
{description}
|
||||
</p>
|
||||
<a className="text-white pt-3 font-bold hover:underline flex flex-row cursor-pointer w-max-content">
|
||||
<span>Read it here</span>
|
||||
<RightArrow width="20" heigh="20" className="ml-1" />
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</Container>
|
||||
</div>
|
||||
|
@@ -2,7 +2,7 @@ import cn from 'classnames'
|
||||
import { FC, useRef } from 'react'
|
||||
import s from './Modal.module.css'
|
||||
import { useDialog } from '@react-aria/dialog'
|
||||
import { useOverlay, usePreventScroll, useModal } from '@react-aria/overlays'
|
||||
import { useOverlay, useModal } from '@react-aria/overlays'
|
||||
import { FocusScope } from '@react-aria/focus'
|
||||
|
||||
interface Props {
|
||||
@@ -25,10 +25,6 @@ const Modal: FC<Props> = ({
|
||||
let { overlayProps } = useOverlay(props, ref)
|
||||
let { dialogProps } = useDialog(props, ref)
|
||||
|
||||
usePreventScroll({
|
||||
isDisabled: !show,
|
||||
})
|
||||
|
||||
return (
|
||||
<div className={rootClassName}>
|
||||
<FocusScope contain restoreFocus autoFocus>
|
||||
|
@@ -2,43 +2,33 @@ import cn from 'classnames'
|
||||
import { FC, useRef } from 'react'
|
||||
import s from './Sidebar.module.css'
|
||||
import { Transition } from '@headlessui/react'
|
||||
import {
|
||||
useOverlay,
|
||||
usePreventScroll,
|
||||
useModal,
|
||||
OverlayContainer,
|
||||
} from '@react-aria/overlays'
|
||||
import { useOverlay, useModal, OverlayContainer } from '@react-aria/overlays'
|
||||
import { useDialog } from '@react-aria/dialog'
|
||||
import { FocusScope } from '@react-aria/focus'
|
||||
|
||||
interface Props {
|
||||
className?: string
|
||||
children?: any
|
||||
show?: boolean
|
||||
close: () => void
|
||||
open?: boolean
|
||||
onClose: () => void
|
||||
}
|
||||
|
||||
const Sidebar: FC<Props> = ({ className, children, show = true, close }) => {
|
||||
const Sidebar: FC<Props> = ({ className, children, open = false, onClose }) => {
|
||||
const rootClassName = cn(s.root, className)
|
||||
|
||||
const ref = useRef<HTMLDivElement>(null)
|
||||
const { modalProps } = useModal()
|
||||
const { overlayProps } = useOverlay(
|
||||
{
|
||||
isOpen: show,
|
||||
onClose: close,
|
||||
isOpen: open,
|
||||
isDismissable: true,
|
||||
onClose: onClose,
|
||||
},
|
||||
ref
|
||||
)
|
||||
const { dialogProps } = useDialog({}, ref)
|
||||
|
||||
usePreventScroll({
|
||||
isDisabled: !show,
|
||||
})
|
||||
|
||||
return (
|
||||
<Transition show={show}>
|
||||
<Transition show={open}>
|
||||
<OverlayContainer>
|
||||
<FocusScope contain restoreFocus autoFocus>
|
||||
<div className={rootClassName}>
|
||||
@@ -54,7 +44,7 @@ const Sidebar: FC<Props> = ({ className, children, show = true, close }) => {
|
||||
<div
|
||||
className="absolute inset-0 bg-black bg-opacity-50 transition-opacity"
|
||||
// Close the sidebar when clicking on the backdrop
|
||||
onClick={close}
|
||||
onClick={onClose}
|
||||
/>
|
||||
</Transition.Child>
|
||||
<section
|
||||
|
Reference in New Issue
Block a user