Motion
useSuccessWipe
A band at the slash angle covers a form and leaves the success message behind it.
import { useSuccessWipe } from "@percentsa/motion";Examples
Code
export function SuccessWipeExample() {
const t = useT();
const box = useRef<HTMLDivElement>(null);
const band = useRef<HTMLSpanElement>(null);
const wipe = useSuccessWipe(box, band);
const [sent, setSent] = useState(false);
return (
<div ref={box} className="relative grid w-full max-w-md">
<span ref={band} className="p-wipe" aria-hidden="true" />
{sent ? (
<div role="status" className="grid min-h-48 place-items-center rounded-card border border-line bg-surface p-8">
<p className="display text-3xl">{t("Thanks. We reply within a day.", "شكرًا. نرد خلال يوم.")}</p>
</div>
) : (
<form
className="grid min-h-48 content-center gap-4 rounded-card border border-line bg-surface p-8"
onSubmit={(e) => {
e.preventDefault();
wipe(() => setSent(true));
}}
>
<Text tone="muted">{t("A form that sends.", "نموذج يُرسل.")}</Text>
<Button type="submit" className="w-fit">{t("Send", "أرسل")}</Button>
</form>
)}
</div>
);
}