since3-portal/modules/templates/catalog/shared/demo-form.tsx
2026-10-10 02:38:50 +02:00

45 lines
1.7 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

"use client"
import { AnimatePresence, motion } from "motion/react"
import { useState, type ReactNode } from "react"
import { DemoNote } from "./demo"
import { ease } from "./motion"
// Formulare der Vorlagen senden nichts – nach dem Absenden erscheint eine Bestätigung (im Portal mit Demo-Hinweis).
// Im exportierten Projekt ist hier der Versand anzubinden.
export function DemoForm({ children, success, className }: { children: ReactNode; success: ReactNode; className?: string }) {
const [sent, setSent] = useState(false)
return (
<AnimatePresence mode="wait" initial={false}>
{sent ? (
<motion.div
key="sent"
className={className}
initial={{ opacity: 0, y: 20 }}
animate={{ opacity: 1, y: 0 }}
transition={{ duration: 0.6, ease }}
role="status"
>
{success}
<DemoNote className="mt-4 text-sm opacity-60">
Demo-Hinweis: Auf Ihrer fertigen Webseite landet diese Anfrage direkt in Ihrem Postfach.
</DemoNote>
</motion.div>
) : (
<motion.form
key="form"
className={className}
exit={{ opacity: 0, y: -20 }}
transition={{ duration: 0.4, ease }}
onSubmit={(event) => {
event.preventDefault()
setSent(true)
}}
>
{children}
</motion.form>
)}
</AnimatePresence>
)
}