From f62b2345f463695ef0f8f79830cd76b6e0332821 Mon Sep 17 00:00:00 2001
From: Rafi Zadanly <zadanlyr@gmail.com>
Date: Sat, 13 Jan 2024 10:35:22 +0700
Subject: Refactor src migrate folder

---
 src-migrate/components/ui/image.tsx | 46 +++++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 src-migrate/components/ui/image.tsx

(limited to 'src-migrate/components/ui/image.tsx')

diff --git a/src-migrate/components/ui/image.tsx b/src-migrate/components/ui/image.tsx
new file mode 100644
index 00000000..a91b2a9d
--- /dev/null
+++ b/src-migrate/components/ui/image.tsx
@@ -0,0 +1,46 @@
+import clsx from 'clsx';
+import NextImage, { ImageProps as NextImageProps } from 'next/image';
+import { useState } from 'react';
+
+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 [isLoading, setLoading] = useState(true);
+
+  return (
+    <div
+      className={clsx(
+        'overflow-hidden',
+        isLoading ? 'animate-pulse' : '',
+        rounded,
+        classNames?.wrapper
+      )}
+    >
+      <NextImage
+        className={clsxm(
+          'duration-700 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>
+  );
+};
+export default Image;
\ No newline at end of file
-- 
cgit v1.2.3

