summaryrefslogtreecommitdiff
path: root/src-migrate/components
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/components')
-rw-r--r--src-migrate/components/seo.tsx32
-rw-r--r--src-migrate/components/ui/image.tsx46
-rw-r--r--src-migrate/components/ui/modal.tsx87
-rw-r--r--src-migrate/components/ui/re-captcha.tsx15
4 files changed, 180 insertions, 0 deletions
diff --git a/src-migrate/components/seo.tsx b/src-migrate/components/seo.tsx
new file mode 100644
index 00000000..1e78ed4d
--- /dev/null
+++ b/src-migrate/components/seo.tsx
@@ -0,0 +1,32 @@
+import { useRouter } from 'next/router'
+import React from 'react'
+import { NextSeo } from "next-seo"
+import { MetaTag, NextSeoProps } from 'next-seo/lib/types';
+
+export const Seo = (props: NextSeoProps) => {
+ const router = useRouter()
+
+ const additionalMetaTags: MetaTag[] = [
+ {
+ property: 'fb:app_id',
+ content: '270830718811'
+ },
+ {
+ property: 'fb:page_id',
+ content: '101759953569'
+ },
+ ]
+
+ if (!!props.additionalMetaTags) additionalMetaTags.push(...props.additionalMetaTags)
+
+ return (
+ <NextSeo
+ defaultTitle='Indoteknik.com: B2B Industrial Supply & Solution'
+ canonical={process.env.NEXT_PUBLIC_SELF_HOST + router.asPath}
+ description={props.title}
+ {...props}
+ openGraph={{ siteName: 'Indoteknik.com', ...props.openGraph }}
+ additionalMetaTags={additionalMetaTags}
+ />
+ )
+} \ No newline at end of file
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
diff --git a/src-migrate/components/ui/modal.tsx b/src-migrate/components/ui/modal.tsx
new file mode 100644
index 00000000..34e1d1c3
--- /dev/null
+++ b/src-migrate/components/ui/modal.tsx
@@ -0,0 +1,87 @@
+import { useEffect, useState } from "react";
+import ReactDOM from "react-dom";
+import { useRouter } from "next/router";
+import { AnimatePresence, motion } from "framer-motion"
+import { useWindowSize } from "usehooks-ts";
+import { XMarkIcon } from "@heroicons/react/24/outline";
+import clsxm from "~/libs/clsxm";
+
+export interface ModalProps {
+ children: React.ReactNode
+ active: boolean
+ title?: string
+ close?: () => void,
+ className?: string,
+ mode?: "mobile" | "desktop"
+}
+
+export const Modal = ({
+ children,
+ active = false,
+ title,
+ close,
+ className,
+ mode
+}: ModalProps) => {
+ const router = useRouter()
+ const { width } = useWindowSize()
+ const [rendered, setRendered] = useState<boolean>(false)
+
+ mode = mode || width >= 768 ? "desktop" : "mobile"
+
+ useEffect(() => {
+ setRendered(true)
+ }, [])
+
+ const modalClassNames = clsxm(
+ "fixed bg-white max-h-[80vh] overflow-auto p-4 pt-0 z-[60] border-gray_r-6",
+ {
+ "left-1/2 -translate-x-1/2 translate-y-1/2 bottom-1/2 w-11/12 md:w-[500px] border rounded-xl": mode === 'desktop',
+ "left-0 w-full border-t bottom-0 rounded-t-xl": mode === 'mobile'
+ },
+ className
+ )
+
+ const variant = {
+ initial: { bottom: mode === 'desktop' ? '45%' : '-100%', opacity: 0 },
+ animate: { bottom: mode === 'desktop' ? '50%' : 0, opacity: 1 },
+ exit: { bottom: mode === 'desktop' ? '55%' : '-100%', opacity: 0 },
+ transition: { ease: 'linear', duration: 0.25 }
+ }
+
+ return rendered && ReactDOM.createPortal(
+ <AnimatePresence key={router.asPath}>
+ {active && (
+ <motion.div
+ className="overlay"
+ initial={{ opacity: 0 }}
+ animate={{ opacity: 1 }}
+ exit={{ opacity: 0 }}
+ onClick={close}
+ />
+ )}
+
+ {active && (
+ <motion.div
+ {...variant}
+ className={modalClassNames}
+ >
+ <div className='flex justify-between py-5 sticky top-0 '>
+ <div className='font-semibold text-h-sm md:text-title-sm'>
+ {title}
+ </div>
+ {close && (
+ <button className="rounded-full h-10 w-10 flex justify-center items-center bg-white" type='button' onClick={close}>
+ <XMarkIcon className='w-5 h-5 ' />
+ </button>
+ )}
+ </div>
+
+ {children}
+ </motion.div>
+ )}
+
+ </AnimatePresence>,
+ document.querySelector('body')!
+ )
+} \ No newline at end of file
diff --git a/src-migrate/components/ui/re-captcha.tsx b/src-migrate/components/ui/re-captcha.tsx
new file mode 100644
index 00000000..e31aa1e3
--- /dev/null
+++ b/src-migrate/components/ui/re-captcha.tsx
@@ -0,0 +1,15 @@
+import ReCAPTCHA, { ReCAPTCHAProps } from "react-google-recaptcha"
+
+const GOOGLE_RECAPTCHA_KEY = process.env.NEXT_PUBLIC_RECAPTCHA_GOOGLE || ''
+
+export interface ReCaptchaProps extends Omit<ReCAPTCHAProps, 'sitekey'> {
+ sitekey?: string;
+}
+
+export const ReCaptcha = (props: ReCaptchaProps) => {
+ const { sitekey, ...rest } = props
+
+ return (
+ <ReCAPTCHA sitekey={sitekey || GOOGLE_RECAPTCHA_KEY} {...rest} />
+ )
+}