summaryrefslogtreecommitdiff
path: root/src-migrate/components/ui/image.tsx
diff options
context:
space:
mode:
authorIT Fixcomart <it@fixcomart.co.id>2024-01-19 02:32:43 +0000
committerIT Fixcomart <it@fixcomart.co.id>2024-01-19 02:32:43 +0000
commit8bcadf6d43a44169c422305522784424c30c7b02 (patch)
tree4666802b65784a949db4acad665a81de7297fc74 /src-migrate/components/ui/image.tsx
parent065396828266e2de42cb0182c81ea2d7a5b00e2b (diff)
parent91086d8b1af2e1c0ca9db38d037f6331c9e6131a (diff)
Merged in Feature/perf/product-detail (pull request #127)
Feature/perf/product detail
Diffstat (limited to 'src-migrate/components/ui/image.tsx')
-rw-r--r--src-migrate/components/ui/image.tsx33
1 files changed, 33 insertions, 0 deletions
diff --git a/src-migrate/components/ui/image.tsx b/src-migrate/components/ui/image.tsx
new file mode 100644
index 00000000..c1dde170
--- /dev/null
+++ b/src-migrate/components/ui/image.tsx
@@ -0,0 +1,33 @@
+import NextImage, { ImageProps as NextImageProps } from 'next/image';
+import { useState } from 'react';
+
+import clsxm from '~/libs/clsxm';
+
+type ImageProps = {
+ rounded?: string;
+} & NextImageProps;
+
+const Image = (props: ImageProps) => {
+ const { alt, src, className, rounded, ...rest } = props;
+ const [isLoading, setLoading] = useState(true);
+
+ return (
+ <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}
+ />
+ );
+};
+export default Image; \ No newline at end of file