summaryrefslogtreecommitdiff
path: root/src-migrate/components/ui/smooth-render.tsx
diff options
context:
space:
mode:
Diffstat (limited to 'src-migrate/components/ui/smooth-render.tsx')
-rw-r--r--src-migrate/components/ui/smooth-render.tsx41
1 files changed, 41 insertions, 0 deletions
diff --git a/src-migrate/components/ui/smooth-render.tsx b/src-migrate/components/ui/smooth-render.tsx
new file mode 100644
index 00000000..0e9a4096
--- /dev/null
+++ b/src-migrate/components/ui/smooth-render.tsx
@@ -0,0 +1,41 @@
+import React from 'react'
+import clsxm from '~/libs/clsxm'
+
+type Props = {
+ children: React.ReactNode,
+ isLoaded: boolean,
+ height: number,
+ duration?: number
+ delay?: number
+} & React.HTMLProps<HTMLDivElement>
+
+const SmoothRender = (props: Props) => {
+ const {
+ children,
+ isLoaded,
+ height,
+ duration = 0,
+ delay = 0,
+ style,
+ className,
+ ...rest
+ } = props
+
+ return (
+ <div
+ className={clsxm('overflow-y-hidden transition-all', className)}
+ style={{
+ opacity: isLoaded ? 1 : 0,
+ height: isLoaded ? `${height}px` : 0,
+ transitionDuration: `${duration}ms`,
+ transitionDelay: `${delay}ms`,
+ ...style
+ }}
+ {...rest}
+ >
+ {isLoaded && children}
+ </div>
+ )
+}
+
+export default SmoothRender \ No newline at end of file