|
|
|
|
@ -1,12 +1,14 @@
|
|
|
|
|
// https://www.joshwcomeau.com/snippets/react-components/fade-in/
|
|
|
|
|
import React from "react"
|
|
|
|
|
import styles from "./fade.module.css"
|
|
|
|
|
import { cn } from "@lib/cn"
|
|
|
|
|
|
|
|
|
|
function FadeIn({
|
|
|
|
|
duration = 300,
|
|
|
|
|
delay = 0,
|
|
|
|
|
children,
|
|
|
|
|
as,
|
|
|
|
|
className,
|
|
|
|
|
...delegated
|
|
|
|
|
}: {
|
|
|
|
|
duration?: number
|
|
|
|
|
@ -16,7 +18,7 @@ function FadeIn({
|
|
|
|
|
} & React.HTMLAttributes<HTMLElement>) {
|
|
|
|
|
if (as !== null && typeof as === "object") {
|
|
|
|
|
return React.cloneElement(as, {
|
|
|
|
|
className: styles.fadeIn,
|
|
|
|
|
className: cn(as.props.className, styles.fadeIn, className),
|
|
|
|
|
style: {
|
|
|
|
|
...(as.props.style || {}),
|
|
|
|
|
animationDuration: duration + "ms",
|
|
|
|
|
@ -28,7 +30,7 @@ function FadeIn({
|
|
|
|
|
return (
|
|
|
|
|
<Element
|
|
|
|
|
{...delegated}
|
|
|
|
|
className={styles.fadeIn}
|
|
|
|
|
className={cn(styles.fadeIn, className)}
|
|
|
|
|
style={{
|
|
|
|
|
...(delegated.style || {}),
|
|
|
|
|
animationDuration: duration + "ms",
|
|
|
|
|
|