mirror of
https://github.com/vercel/commerce.git
synced 2025-05-18 07:26:59 +00:00
General UI Improvements
This commit is contained in:
parent
177a9cb510
commit
fee79b47cf
@ -1,8 +1,16 @@
|
|||||||
.root {
|
.root {
|
||||||
@apply relative h-full flex flex-col w-full;
|
@apply relative h-full flex flex-col w-full;
|
||||||
|
min-height: 100vh;
|
||||||
}
|
}
|
||||||
|
|
||||||
.header {
|
.header {
|
||||||
@apply pl-4 pr-6 pt-4 pb-4 lg:pt-5 flex items-center justify-between space-x-3;
|
@apply sticky top-0 pl-4 pr-6 pt-4 pb-4 lg:pt-5
|
||||||
|
flex items-center justify-between space-x-3
|
||||||
|
bg-accent-0 border-b border-accent-2 z-50;
|
||||||
margin-top: 1px;
|
margin-top: 1px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.container,
|
||||||
|
.container > *:first-child {
|
||||||
|
min-height: calc(100vh - 70px);
|
||||||
|
}
|
||||||
|
@ -24,10 +24,8 @@ const SidebarLayout: FC<ComponentProps> = ({
|
|||||||
aria-label="Close"
|
aria-label="Close"
|
||||||
className="hover:text-gray-500 transition ease-in-out duration-150 flex items-center focus:outline-none"
|
className="hover:text-gray-500 transition ease-in-out duration-150 flex items-center focus:outline-none"
|
||||||
>
|
>
|
||||||
<Cross className="h-6 w-6" />
|
<Cross className="h-6 w-6 hover:text-accent-3" />
|
||||||
<span className="ml-2 text-accent-7 text-sm hover:text-gray-500">
|
<span className="ml-2 text-accent-7 text-sm ">Close</span>
|
||||||
Close
|
|
||||||
</span>
|
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
@ -37,15 +35,13 @@ const SidebarLayout: FC<ComponentProps> = ({
|
|||||||
aria-label="Go back"
|
aria-label="Go back"
|
||||||
className="hover:text-gray-500 transition ease-in-out duration-150 flex items-center focus:outline-none"
|
className="hover:text-gray-500 transition ease-in-out duration-150 flex items-center focus:outline-none"
|
||||||
>
|
>
|
||||||
<ChevronLeft className="h-6 w-6" />
|
<ChevronLeft className="h-6 w-6 hover:text-accent-3" />
|
||||||
<span className="ml-2 text-accent-7 text-xs hover:text-gray-500">
|
<span className="ml-2 text-accent-7 text-xs ">Back</span>
|
||||||
Back
|
|
||||||
</span>
|
|
||||||
</button>
|
</button>
|
||||||
)}
|
)}
|
||||||
<UserNav />
|
<UserNav />
|
||||||
</header>
|
</header>
|
||||||
{children}
|
<div className={s.container}>{children}</div>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -3,108 +3,109 @@
|
|||||||
bg-no-repeat bg-center bg-cover transition-transform
|
bg-no-repeat bg-center bg-cover transition-transform
|
||||||
ease-linear cursor-pointer inline-block bg-accent-1;
|
ease-linear cursor-pointer inline-block bg-accent-1;
|
||||||
height: 100% !important;
|
height: 100% !important;
|
||||||
|
}
|
||||||
|
|
||||||
&:hover {
|
.root:hover {
|
||||||
& .productImage {
|
& .productImage {
|
||||||
transform: scale(1.2625);
|
transform: scale(1.2625);
|
||||||
}
|
}
|
||||||
|
|
||||||
& .productTitle > span,
|
& .header .name span,
|
||||||
& .productPrice,
|
& .header .price,
|
||||||
& .wishlistButton {
|
& .wishlistButton {
|
||||||
@apply bg-secondary text-secondary;
|
@apply bg-secondary text-secondary;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:nth-child(6n + 1) .productTitle > span,
|
&:nth-child(6n + 1) .header .name span,
|
||||||
&:nth-child(6n + 1) .productPrice,
|
&:nth-child(6n + 1) .header .price,
|
||||||
&:nth-child(6n + 1) .wishlistButton {
|
&:nth-child(6n + 1) .wishlistButton {
|
||||||
@apply bg-violet text-white;
|
@apply bg-violet text-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:nth-child(6n + 5) .productTitle > span,
|
&:nth-child(6n + 5) .header .name span,
|
||||||
&:nth-child(6n + 5) .productPrice,
|
&:nth-child(6n + 5) .header .price,
|
||||||
&:nth-child(6n + 5) .wishlistButton {
|
&:nth-child(6n + 5) .wishlistButton {
|
||||||
@apply bg-blue text-white;
|
@apply bg-blue text-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:nth-child(6n + 3) .productTitle > span,
|
&:nth-child(6n + 3) .header .name span,
|
||||||
&:nth-child(6n + 3) .productPrice,
|
&:nth-child(6n + 3) .header .price,
|
||||||
&:nth-child(6n + 3) .wishlistButton {
|
&:nth-child(6n + 3) .wishlistButton {
|
||||||
@apply bg-pink text-white;
|
@apply bg-pink text-white;
|
||||||
}
|
}
|
||||||
|
|
||||||
&:nth-child(6n + 6) .productTitle > span,
|
&:nth-child(6n + 6) .header .name span,
|
||||||
&:nth-child(6n + 6) .productPrice,
|
&:nth-child(6n + 6) .header .price,
|
||||||
&:nth-child(6n + 6) .wishlistButton {
|
&:nth-child(6n + 6) .wishlistButton {
|
||||||
@apply bg-cyan text-white;
|
@apply bg-cyan text-white;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.header {
|
||||||
|
@apply transition-colors ease-in-out duration-500
|
||||||
|
absolute top-0 left-0 z-20 pr-16;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .name {
|
||||||
|
@apply pt-0 max-w-full w-full leading-extra-loose;
|
||||||
|
font-size: 2rem;
|
||||||
|
letter-spacing: 0.4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .name span {
|
||||||
|
@apply py-4 px-6 bg-primary text-primary font-bold;
|
||||||
|
font-size: inherit;
|
||||||
|
letter-spacing: inherit;
|
||||||
|
box-decoration-break: clone;
|
||||||
|
-webkit-box-decoration-break: clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .price {
|
||||||
|
@apply pt-2 px-6 pb-4 text-sm bg-primary text-accent-9
|
||||||
|
font-semibold inline-block tracking-wide;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imageContainer {
|
||||||
|
@apply flex items-center justify-center overflow-hidden;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imageContainer > div {
|
||||||
|
min-width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.imageContainer .productImage {
|
||||||
|
@apply transform transition-transform duration-500
|
||||||
|
object-cover scale-120;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root .wishlistButton {
|
.root .wishlistButton {
|
||||||
@apply top-0 right-0 z-30 absolute;
|
@apply top-0 right-0 z-30 absolute;
|
||||||
}
|
}
|
||||||
|
|
||||||
.productTitle > span,
|
/* Variant Simple */
|
||||||
.productPrice {
|
.simple .header .name {
|
||||||
@apply transition-colors ease-in-out duration-500;
|
@apply pt-2 text-lg leading-10 -mt-1;
|
||||||
}
|
}
|
||||||
|
|
||||||
.simple {
|
.simple .header .price {
|
||||||
& .productTitle {
|
|
||||||
@apply pt-2;
|
|
||||||
font-size: 1rem;
|
|
||||||
|
|
||||||
& span {
|
|
||||||
@apply leading-extra-loose;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
& .productPrice {
|
|
||||||
@apply text-sm;
|
@apply text-sm;
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.productTitle {
|
|
||||||
@apply pt-0 max-w-full w-full leading-extra-loose;
|
|
||||||
font-size: 2rem;
|
|
||||||
letter-spacing: 0.4px;
|
|
||||||
|
|
||||||
& span {
|
|
||||||
@apply py-4 px-6 bg-primary text-primary font-bold;
|
|
||||||
font-size: inherit;
|
|
||||||
letter-spacing: inherit;
|
|
||||||
box-decoration-break: clone;
|
|
||||||
-webkit-box-decoration-break: clone;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.productPrice {
|
|
||||||
@apply py-4 px-6 bg-primary text-primary font-semibold inline-block text-sm leading-6;
|
|
||||||
letter-spacing: 0.4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.imageContainer {
|
|
||||||
@apply flex items-center justify-center;
|
|
||||||
overflow: hidden;
|
|
||||||
|
|
||||||
& > div {
|
|
||||||
min-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
.productImage {
|
|
||||||
@apply transform transition-transform duration-500 object-cover scale-120;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Variant Slim */
|
||||||
.slim {
|
.slim {
|
||||||
@apply bg-transparent relative overflow-hidden box-border;
|
@apply bg-transparent relative overflow-hidden
|
||||||
|
box-border;
|
||||||
}
|
}
|
||||||
|
|
||||||
.slim .tag {
|
.slim .header {
|
||||||
@apply bg-accent-9 text-accent-0 inline-block p-3 font-bold text-xl break-words;
|
@apply absolute inset-0 flex items-center justify-end mr-8 z-20;
|
||||||
}
|
}
|
||||||
|
|
||||||
.root:global(.secondary) .tag {
|
.slim span {
|
||||||
|
@apply bg-accent-9 text-accent-0 inline-block p-3
|
||||||
|
font-bold text-xl break-words;
|
||||||
|
}
|
||||||
|
|
||||||
|
.root:global(.secondary) .header span {
|
||||||
@apply bg-accent-0 text-accent-9;
|
@apply bg-accent-0 text-accent-9;
|
||||||
}
|
}
|
||||||
|
@ -5,37 +5,45 @@ import type { Product } from '@commerce/types/product'
|
|||||||
import s from './ProductCard.module.css'
|
import s from './ProductCard.module.css'
|
||||||
import Image, { ImageProps } from 'next/image'
|
import Image, { ImageProps } from 'next/image'
|
||||||
import WishlistButton from '@components/wishlist/WishlistButton'
|
import WishlistButton from '@components/wishlist/WishlistButton'
|
||||||
|
import usePrice from '@framework/product/use-price'
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
className?: string
|
className?: string
|
||||||
product: Product
|
product: Product
|
||||||
variant?: 'default' | 'slim' | 'simple'
|
|
||||||
imgProps?: Omit<ImageProps, 'src'>
|
|
||||||
noNameTag?: boolean
|
noNameTag?: boolean
|
||||||
|
imgProps?: Omit<ImageProps, 'src'>
|
||||||
|
variant?: 'default' | 'slim' | 'simple'
|
||||||
}
|
}
|
||||||
|
|
||||||
const placeholderImg = '/product-img-placeholder.svg'
|
const placeholderImg = '/product-img-placeholder.svg'
|
||||||
|
|
||||||
const ProductCard: FC<Props> = ({
|
const ProductCard: FC<Props> = ({
|
||||||
className,
|
|
||||||
product,
|
product,
|
||||||
imgProps,
|
imgProps,
|
||||||
variant = 'default',
|
className,
|
||||||
noNameTag = false,
|
noNameTag = false,
|
||||||
|
variant = 'default',
|
||||||
...props
|
...props
|
||||||
}) => (
|
}) => {
|
||||||
<Link href={`/product/${product.slug}`} {...props}>
|
const { price } = usePrice({
|
||||||
<a
|
amount: product.price.value,
|
||||||
className={cn(
|
baseAmount: product.price.retailPrice,
|
||||||
|
currencyCode: product.price.currencyCode!,
|
||||||
|
})
|
||||||
|
|
||||||
|
const rootClassName = cn(
|
||||||
s.root,
|
s.root,
|
||||||
{ [s.slim]: variant === 'slim', [s.simple]: variant === 'simple' },
|
{ [s.slim]: variant === 'slim', [s.simple]: variant === 'simple' },
|
||||||
className
|
className
|
||||||
)}
|
)
|
||||||
>
|
|
||||||
|
return (
|
||||||
|
<Link href={`/product/${product.slug}`} {...props}>
|
||||||
|
<a className={rootClassName}>
|
||||||
{variant === 'slim' && (
|
{variant === 'slim' && (
|
||||||
<>
|
<>
|
||||||
<div className="absolute inset-0 flex items-center justify-end mr-8 z-20">
|
<div className={s.header}>
|
||||||
<span className={s.tag}>{product.name}</span>
|
<span>{product.name}</span>
|
||||||
</div>
|
</div>
|
||||||
{product?.images && (
|
{product?.images && (
|
||||||
<Image
|
<Image
|
||||||
@ -57,24 +65,19 @@ const ProductCard: FC<Props> = ({
|
|||||||
<WishlistButton
|
<WishlistButton
|
||||||
className={s.wishlistButton}
|
className={s.wishlistButton}
|
||||||
productId={product.id}
|
productId={product.id}
|
||||||
variant={product.variants[0] as any}
|
variant={product.variants[0]}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
|
||||||
<div className="flex flex-row justify-between box-border w-full z-20 absolute ">
|
|
||||||
{!noNameTag && (
|
{!noNameTag && (
|
||||||
<div className="absolute top-0 left-0 pr-16 max-w-full">
|
<div className={s.header}>
|
||||||
<h3 className={s.productTitle}>
|
<h3 className={s.name}>
|
||||||
<span>{product.name}</span>
|
<span>{product.name}</span>
|
||||||
</h3>
|
</h3>
|
||||||
<span className={s.productPrice}>
|
<div className={s.price}>
|
||||||
{product.price.value}
|
{`${price} ${product.price?.currencyCode}`}
|
||||||
|
</div>
|
||||||
{product.price.currencyCode}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
)}
|
)}
|
||||||
</div>
|
|
||||||
<div className={s.imageContainer}>
|
<div className={s.imageContainer}>
|
||||||
{product?.images && (
|
{product?.images && (
|
||||||
<Image
|
<Image
|
||||||
@ -101,16 +104,12 @@ const ProductCard: FC<Props> = ({
|
|||||||
variant={product.variants[0] as any}
|
variant={product.variants[0] as any}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
<div className="flex flex-row justify-between box-border w-full z-20 absolute ">
|
<div className={s.header}>
|
||||||
<div className="absolute top-0 left-0 pr-16 max-w-full">
|
<h3 className={s.name}>
|
||||||
<h3 className={s.productTitle}>
|
|
||||||
<span>{product.name}</span>
|
<span>{product.name}</span>
|
||||||
</h3>
|
</h3>
|
||||||
<span className={s.productPrice}>
|
<div className={s.price}>
|
||||||
{product.price.value}
|
{`${price} ${product.price?.currencyCode}`}
|
||||||
|
|
||||||
{product.price.currencyCode}
|
|
||||||
</span>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className={s.imageContainer}>
|
<div className={s.imageContainer}>
|
||||||
@ -131,6 +130,7 @@ const ProductCard: FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
</a>
|
</a>
|
||||||
</Link>
|
</Link>
|
||||||
)
|
)
|
||||||
|
}
|
||||||
|
|
||||||
export default ProductCard
|
export default ProductCard
|
||||||
|
@ -7,18 +7,28 @@
|
|||||||
min-height: 500px;
|
min-height: 500px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameBox {
|
.header {
|
||||||
@apply absolute top-0 left-0 z-20 pr-16;
|
@apply transition-colors ease-in-out duration-500
|
||||||
|
absolute top-0 left-0 z-20 pr-16;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameBox .name {
|
.header .name {
|
||||||
@apply px-6 py-2 bg-primary text-primary font-bold;
|
@apply pt-0 max-w-full w-full leading-extra-loose;
|
||||||
font-size: 1.8rem;
|
font-size: 2rem;
|
||||||
letter-spacing: 0.4px;
|
letter-spacing: 0.4px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameBox .price {
|
.header .name span {
|
||||||
@apply px-6 py-2 pb-4 bg-primary text-primary font-bold inline-block tracking-wide;
|
@apply py-4 px-6 bg-primary text-primary font-bold;
|
||||||
|
font-size: inherit;
|
||||||
|
letter-spacing: inherit;
|
||||||
|
box-decoration-break: clone;
|
||||||
|
-webkit-box-decoration-break: clone;
|
||||||
|
}
|
||||||
|
|
||||||
|
.header .price {
|
||||||
|
@apply pt-2 px-6 pb-4 text-sm bg-primary text-accent-9
|
||||||
|
font-semibold inline-block tracking-wide;
|
||||||
}
|
}
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
@ -60,15 +70,6 @@
|
|||||||
@apply mx-0 col-span-8;
|
@apply mx-0 col-span-8;
|
||||||
}
|
}
|
||||||
|
|
||||||
.nameBox {
|
|
||||||
@apply left-0 pr-16;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nameBox .name,
|
|
||||||
.nameBox .price {
|
|
||||||
@apply bg-accent-0 text-accent-9;
|
|
||||||
}
|
|
||||||
|
|
||||||
.sidebar {
|
.sidebar {
|
||||||
@apply col-span-4 py-6;
|
@apply col-span-4 py-6;
|
||||||
}
|
}
|
||||||
|
@ -80,8 +80,10 @@ const ProductView: FC<ProductViewProps> = ({ product, relatedProducts }) => {
|
|||||||
/>
|
/>
|
||||||
<div className={cn(s.root, 'fit')}>
|
<div className={cn(s.root, 'fit')}>
|
||||||
<div className={cn(s.main, 'fit')}>
|
<div className={cn(s.main, 'fit')}>
|
||||||
<div className={s.nameBox}>
|
<div className={s.header}>
|
||||||
<h1 className={s.name}>{product.name}</h1>
|
<h3 className={s.name}>
|
||||||
|
<span>{product.name}</span>
|
||||||
|
</h3>
|
||||||
<div className={s.price}>
|
<div className={s.price}>
|
||||||
{`${price} ${product.price?.currencyCode}`}
|
{`${price} ${product.price?.currencyCode}`}
|
||||||
</div>
|
</div>
|
||||||
|
@ -11,3 +11,7 @@
|
|||||||
.modal:focus {
|
.modal:focus {
|
||||||
@apply outline-none;
|
@apply outline-none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.close {
|
||||||
|
@apply hover:text-gray-500 transition ease-in-out duration-150 focus:outline-none absolute right-0 top-0 m-6;
|
||||||
|
}
|
||||||
|
@ -39,7 +39,7 @@ const Modal: FC<ModalProps> = ({ children, onClose }) => {
|
|||||||
<button
|
<button
|
||||||
onClick={() => onClose()}
|
onClick={() => onClose()}
|
||||||
aria-label="Close panel"
|
aria-label="Close panel"
|
||||||
className="hover:text-gray-500 transition ease-in-out duration-150 focus:outline-none absolute right-0 top-0 m-6"
|
className={s.close}
|
||||||
>
|
>
|
||||||
<Cross className="h-6 w-6" />
|
<Cross className="h-6 w-6" />
|
||||||
</button>
|
</button>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user