summaryrefslogtreecommitdiff
path: root/src-migrate
diff options
context:
space:
mode:
authorRafi Zadanly <zadanlyr@gmail.com>2024-01-17 09:54:59 +0700
committerRafi Zadanly <zadanlyr@gmail.com>2024-01-17 09:54:59 +0700
commit7072d220bc86b56e76716d114e28af98219e3f69 (patch)
tree01f3bd7e75c1151f85661e1c47e6901f0e3b954e /src-migrate
parentb3283fd9fff8f8faf7957b79e96dee3c3dc10399 (diff)
Update image for performance
Diffstat (limited to 'src-migrate')
-rw-r--r--src-migrate/components/ui/image.tsx43
-rw-r--r--src-migrate/modules/product-card/components/ProductCard.tsx1
-rw-r--r--src-migrate/modules/product-detail/components/Image.tsx1
3 files changed, 15 insertions, 30 deletions
diff --git a/src-migrate/components/ui/image.tsx b/src-migrate/components/ui/image.tsx
index c7ed0b0e..c1dde170 100644
--- a/src-migrate/components/ui/image.tsx
+++ b/src-migrate/components/ui/image.tsx
@@ -1,4 +1,3 @@
-import clsx from 'clsx';
import NextImage, { ImageProps as NextImageProps } from 'next/image';
import { useState } from 'react';
@@ -6,41 +5,29 @@ import clsxm from '~/libs/clsxm';
type ImageProps = {
rounded?: string;
- classNames?: {
- wrapper: string
- }
} & NextImageProps;
const Image = (props: ImageProps) => {
- const { alt, src, className, classNames, rounded, ...rest } = props;
+ const { alt, src, className, rounded, ...rest } = props;
const [isLoading, setLoading] = useState(true);
return (
- <div
- className={clsx(
- 'overflow-hidden',
- isLoading ? 'animate-pulse' : '',
+ <NextImage
+ className={clsxm(
+ 'duration-500 ease-in-out',
+ isLoading
+ ? 'scale-[1.02] blur-xl grayscale'
+ : 'scale-100 blur-0 grayscale-0',
rounded,
- classNames?.wrapper
+ className
)}
- >
- <NextImage
- className={clsxm(
- 'duration-500 ease-in-out',
- isLoading
- ? 'scale-[1.02] blur-xl grayscale'
- : 'scale-100 blur-0 grayscale-0',
- rounded,
- className
- )}
- src={src}
- alt={alt}
- loading='lazy'
- quality={100}
- onLoadingComplete={() => setLoading(false)}
- {...rest}
- />
- </div>
+ src={src}
+ alt={alt}
+ loading='lazy'
+ quality={100}
+ onLoadingComplete={() => setLoading(false)}
+ {...rest}
+ />
);
};
export default Image; \ No newline at end of file
diff --git a/src-migrate/modules/product-card/components/ProductCard.tsx b/src-migrate/modules/product-card/components/ProductCard.tsx
index 8cd96ce8..c8a0b701 100644
--- a/src-migrate/modules/product-card/components/ProductCard.tsx
+++ b/src-migrate/modules/product-card/components/ProductCard.tsx
@@ -37,7 +37,6 @@ const ProductCard = ({ product, layout = 'vertical' }: Props) => {
width={128}
height={128}
className='object-contain object-center h-full w-full'
- classNames={{ wrapper: 'h-full' }}
/>
</Link>
</div>
diff --git a/src-migrate/modules/product-detail/components/Image.tsx b/src-migrate/modules/product-detail/components/Image.tsx
index 2c5e989b..6ec715d8 100644
--- a/src-migrate/modules/product-detail/components/Image.tsx
+++ b/src-migrate/modules/product-detail/components/Image.tsx
@@ -18,7 +18,6 @@ const Image = ({ product }: Props) => {
width={256}
height={256}
className='object-contain object-center h-full w-full'
- classNames={{ wrapper: 'h-full w-full' }}
loading='eager'
priority
/>