"use client"; import React from "react"; import { FeatherCheck, FeatherInfo } from "@subframe/core"; /** * Minimale Rückmeldung für Demo-Aktionen (Export, Speichern, Teilen). * * Im Prototyp passiert dahinter nichts, der Toast macht aber sichtbar, * dass der Klick registriert wurde, statt dass der Button "tot" wirkt. * In der echten Software durch die vorhandene Toast-Komponente ersetzen. */ interface ToastContextValue { zeigeToast: (text: string, detail?: string) => void; } const ToastContext = React.createContext(null); export function ToastProvider({ children }: { children: React.ReactNode }) { const [toast, setToast] = React.useState<{ text: string; detail?: string } | null>(null); const timer = React.useRef | null>(null); const zeigeToast = React.useCallback((text: string, detail?: string) => { setToast({ text, detail }); if (timer.current) clearTimeout(timer.current); timer.current = setTimeout(() => setToast(null), 2600); }, []); React.useEffect(() => () => { if (timer.current) clearTimeout(timer.current); }, []); return ( {children} {toast ? (
{toast.text} {toast.detail ? ( {toast.detail} ) : null}
) : null}
); } export function useToast(): ToastContextValue { const ctx = React.useContext(ToastContext); if (!ctx) throw new Error("useToast muss innerhalb von verwendet werden"); return ctx; }