mirror of
https://github.com/vercel/commerce.git
synced 2025-05-17 15:06:59 +00:00
Use next/image & fixes
This commit is contained in:
parent
1ef5f14a0a
commit
7b6db0a6f0
@ -1,6 +1,6 @@
|
|||||||
import { ChangeEvent, FocusEventHandler, useEffect, useState } from 'react'
|
import { ChangeEvent, useEffect, useState } from 'react'
|
||||||
import cn from 'clsx'
|
import cn from 'clsx'
|
||||||
import Image from 'next/legacy/image'
|
import Image from 'next/image'
|
||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import s from './CartItem.module.css'
|
import s from './CartItem.module.css'
|
||||||
import { useUI } from '@components/ui/context'
|
import { useUI } from '@components/ui/context'
|
||||||
|
@ -5,7 +5,7 @@ import { useRouter } from 'next/router'
|
|||||||
import s from './I18nWidget.module.css'
|
import s from './I18nWidget.module.css'
|
||||||
import { Cross, ChevronUp } from '@components/icons'
|
import { Cross, ChevronUp } from '@components/icons'
|
||||||
import ClickOutside from '@lib/click-outside'
|
import ClickOutside from '@lib/click-outside'
|
||||||
import Image from 'next/legacy/image'
|
import Image from 'next/image'
|
||||||
interface LOCALE_DATA {
|
interface LOCALE_DATA {
|
||||||
name: string
|
name: string
|
||||||
img: {
|
img: {
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
|
|
||||||
.root:hover {
|
.root:hover {
|
||||||
& .productImage {
|
& .productImage {
|
||||||
transform: scale(1.2625);
|
transform: scale(1.1);
|
||||||
}
|
}
|
||||||
|
|
||||||
& .header .name span,
|
& .header .name span,
|
||||||
@ -69,16 +69,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.imageContainer {
|
.imageContainer {
|
||||||
@apply flex items-center justify-center overflow-hidden;
|
@apply flex items-center justify-center overflow-hidden w-full h-full;
|
||||||
}
|
|
||||||
|
|
||||||
.imageContainer > div {
|
|
||||||
min-width: 100%;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.imageContainer .productImage {
|
.imageContainer .productImage {
|
||||||
@apply transform transition-transform duration-500
|
@apply transform transition-transform duration-500 object-cover w-auto h-full;
|
||||||
object-cover scale-120;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.root .wishlistButton {
|
.root .wishlistButton {
|
||||||
|
@ -3,7 +3,7 @@ import cn from 'clsx'
|
|||||||
import Link from 'next/link'
|
import Link from 'next/link'
|
||||||
import type { Product } from '@commerce/types/product'
|
import type { Product } from '@commerce/types/product'
|
||||||
import s from './ProductCard.module.css'
|
import s from './ProductCard.module.css'
|
||||||
import Image, { ImageProps } from 'next/legacy/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'
|
import usePrice from '@framework/product/use-price'
|
||||||
import ProductTag from '../ProductTag'
|
import ProductTag from '../ProductTag'
|
||||||
@ -49,17 +49,14 @@ const ProductCard: FC<Props> = ({
|
|||||||
<span>{product.name}</span>
|
<span>{product.name}</span>
|
||||||
</div>
|
</div>
|
||||||
{product?.images && (
|
{product?.images && (
|
||||||
<div>
|
|
||||||
<Image
|
<Image
|
||||||
quality="85"
|
quality="85"
|
||||||
src={product.images[0]?.url || placeholderImg}
|
src={product.images[0]?.url || placeholderImg}
|
||||||
alt={product.name || 'Product Image'}
|
alt={product.name || 'Product Image'}
|
||||||
height={320}
|
height={320}
|
||||||
width={320}
|
width={320}
|
||||||
layout="fixed"
|
|
||||||
{...imgProps}
|
{...imgProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</>
|
</>
|
||||||
)}
|
)}
|
||||||
@ -85,7 +82,6 @@ const ProductCard: FC<Props> = ({
|
|||||||
)}
|
)}
|
||||||
<div className={s.imageContainer}>
|
<div className={s.imageContainer}>
|
||||||
{product?.images && (
|
{product?.images && (
|
||||||
<div>
|
|
||||||
<Image
|
<Image
|
||||||
alt={product.name || 'Product Image'}
|
alt={product.name || 'Product Image'}
|
||||||
className={s.productImage}
|
className={s.productImage}
|
||||||
@ -93,10 +89,8 @@ const ProductCard: FC<Props> = ({
|
|||||||
height={540}
|
height={540}
|
||||||
width={540}
|
width={540}
|
||||||
quality="85"
|
quality="85"
|
||||||
layout="responsive"
|
|
||||||
{...imgProps}
|
{...imgProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
@ -117,7 +111,6 @@ const ProductCard: FC<Props> = ({
|
|||||||
/>
|
/>
|
||||||
<div className={s.imageContainer}>
|
<div className={s.imageContainer}>
|
||||||
{product?.images && (
|
{product?.images && (
|
||||||
<div>
|
|
||||||
<Image
|
<Image
|
||||||
alt={product.name || 'Product Image'}
|
alt={product.name || 'Product Image'}
|
||||||
className={s.productImage}
|
className={s.productImage}
|
||||||
@ -125,10 +118,8 @@ const ProductCard: FC<Props> = ({
|
|||||||
height={540}
|
height={540}
|
||||||
width={540}
|
width={540}
|
||||||
quality="85"
|
quality="85"
|
||||||
layout="responsive"
|
|
||||||
{...imgProps}
|
{...imgProps}
|
||||||
/>
|
/>
|
||||||
</div>
|
|
||||||
)}
|
)}
|
||||||
</div>
|
</div>
|
||||||
</>
|
</>
|
||||||
|
@ -50,7 +50,7 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.sliderContainer .img {
|
.sliderContainer .img {
|
||||||
@apply w-full h-auto max-h-full object-cover;
|
@apply w-auto h-full max-h-full object-cover;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
@ -19,11 +19,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.thumb.selected {
|
.thumb.selected {
|
||||||
@apply bg-white;
|
@apply bg-white/30;
|
||||||
}
|
}
|
||||||
|
|
||||||
.thumb img {
|
.thumb img {
|
||||||
height: 85% !important;
|
@apply h-full w-full object-cover transition duration-500;
|
||||||
}
|
}
|
||||||
|
|
||||||
.album {
|
.album {
|
||||||
@ -44,10 +44,9 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
@screen md {
|
@screen md {
|
||||||
.thumb:hover {
|
.thumb:hover img {
|
||||||
transform: scale(1.02);
|
@apply scale-110;
|
||||||
}
|
}
|
||||||
|
|
||||||
.album {
|
.album {
|
||||||
height: 182px;
|
height: 182px;
|
||||||
}
|
}
|
||||||
|
@ -17,15 +17,11 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
.imageContainer {
|
.imageContainer {
|
||||||
@apply text-center h-full relative;
|
@apply flex items-center justify-center w-full h-full relative;
|
||||||
}
|
|
||||||
|
|
||||||
.imageContainer > span {
|
|
||||||
height: 100% !important;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
.sliderContainer .img {
|
.sliderContainer .img {
|
||||||
@apply w-full h-full max-h-full object-cover;
|
@apply object-cover h-full;
|
||||||
}
|
}
|
||||||
|
|
||||||
.button {
|
.button {
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import cn from 'clsx'
|
import cn from 'clsx'
|
||||||
import Image from 'next/legacy/image'
|
import Image from 'next/image'
|
||||||
import s from './ProductView.module.css'
|
import s from './ProductView.module.css'
|
||||||
import { FC } from 'react'
|
import { FC } from 'react'
|
||||||
import type { Product } from '@commerce/types/product'
|
import type { Product } from '@commerce/types/product'
|
||||||
@ -80,6 +80,7 @@ const ProductView: FC<ProductViewProps> = ({ product, relatedProducts }) => {
|
|||||||
variant="simple"
|
variant="simple"
|
||||||
className="animated fadeIn"
|
className="animated fadeIn"
|
||||||
imgProps={{
|
imgProps={{
|
||||||
|
alt: p.name,
|
||||||
width: 300,
|
width: 300,
|
||||||
height: 300,
|
height: 300,
|
||||||
}}
|
}}
|
||||||
|
@ -125,6 +125,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
>
|
>
|
||||||
<Link
|
<Link
|
||||||
href={{ pathname: getCategoryPath('', brand), query }}
|
href={{ pathname: getCategoryPath('', brand), query }}
|
||||||
|
legacyBehavior
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => handleClick(e, 'categories')}
|
onClick={(e) => handleClick(e, 'categories')}
|
||||||
@ -151,6 +152,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
pathname: getCategoryPath(cat.path, brand),
|
pathname: getCategoryPath(cat.path, brand),
|
||||||
query,
|
query,
|
||||||
}}
|
}}
|
||||||
|
legacyBehavior
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => handleClick(e, 'categories')}
|
onClick={(e) => handleClick(e, 'categories')}
|
||||||
@ -226,6 +228,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
pathname: getDesignerPath('', category),
|
pathname: getDesignerPath('', category),
|
||||||
query,
|
query,
|
||||||
}}
|
}}
|
||||||
|
legacyBehavior
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => handleClick(e, 'brands')}
|
onClick={(e) => handleClick(e, 'brands')}
|
||||||
@ -252,6 +255,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
pathname: getDesignerPath(path, category),
|
pathname: getDesignerPath(path, category),
|
||||||
query,
|
query,
|
||||||
}}
|
}}
|
||||||
|
legacyBehavior
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => handleClick(e, 'brands')}
|
onClick={(e) => handleClick(e, 'brands')}
|
||||||
@ -326,6 +330,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
imgProps={{
|
imgProps={{
|
||||||
width: 480,
|
width: 480,
|
||||||
height: 480,
|
height: 480,
|
||||||
|
alt: product.name,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
))}
|
))}
|
||||||
@ -390,7 +395,10 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
}
|
}
|
||||||
)}
|
)}
|
||||||
>
|
>
|
||||||
<Link href={{ pathname, query: filterQuery({ q }) }}>
|
<Link
|
||||||
|
href={{ pathname, query: filterQuery({ q }) }}
|
||||||
|
legacyBehavior
|
||||||
|
>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => handleClick(e, 'sort')}
|
onClick={(e) => handleClick(e, 'sort')}
|
||||||
className={
|
className={
|
||||||
@ -416,6 +424,7 @@ export default function Search({ categories, brands }: SearchPropsType) {
|
|||||||
pathname,
|
pathname,
|
||||||
query: filterQuery({ q, sort: key }),
|
query: filterQuery({ q, sort: key }),
|
||||||
}}
|
}}
|
||||||
|
legacyBehavior
|
||||||
>
|
>
|
||||||
<a
|
<a
|
||||||
onClick={(e) => handleClick(e, 'sort')}
|
onClick={(e) => handleClick(e, 'sort')}
|
||||||
|
@ -46,6 +46,7 @@ export default function Home({
|
|||||||
key={product.id}
|
key={product.id}
|
||||||
product={product}
|
product={product}
|
||||||
imgProps={{
|
imgProps={{
|
||||||
|
alt: product.name,
|
||||||
width: i === 0 ? 1080 : 540,
|
width: i === 0 ? 1080 : 540,
|
||||||
height: i === 0 ? 1080 : 540,
|
height: i === 0 ? 1080 : 540,
|
||||||
priority: true,
|
priority: true,
|
||||||
@ -68,6 +69,7 @@ export default function Home({
|
|||||||
key={product.id}
|
key={product.id}
|
||||||
product={product}
|
product={product}
|
||||||
imgProps={{
|
imgProps={{
|
||||||
|
alt: product.name,
|
||||||
width: i === 0 ? 1080 : 540,
|
width: i === 0 ? 1080 : 540,
|
||||||
height: i === 0 ? 1080 : 540,
|
height: i === 0 ? 1080 : 540,
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user