feat: upgrade UI with premium industrial aesthetics, purely visual language switch, and resilient error pages
Former-commit-id: e4d801c24e64c41816f86de9767b47894abb6806
This commit is contained in:
@@ -5,16 +5,18 @@ import { useRouter } from 'next/navigation';
|
||||
|
||||
interface TransitionContextType {
|
||||
isTransitioning: boolean;
|
||||
startTransition: (href: string) => void;
|
||||
transitionMessage: string | null;
|
||||
startTransition: (href: string, message?: string | null) => void;
|
||||
}
|
||||
|
||||
const TransitionContext = createContext<TransitionContextType | undefined>(undefined);
|
||||
|
||||
export function TransitionProvider({ children }: { children: ReactNode }) {
|
||||
const [isTransitioning, setIsTransitioning] = useState(false);
|
||||
const [transitionMessage, setTransitionMessage] = useState<string | null>(null);
|
||||
const router = useRouter();
|
||||
|
||||
const startTransition = useCallback((href: string) => {
|
||||
const startTransition = useCallback((href: string, message: string | null = null) => {
|
||||
// Wenn wir bereits navigieren, nichts tun
|
||||
if (isTransitioning) return;
|
||||
|
||||
@@ -25,6 +27,7 @@ export function TransitionProvider({ children }: { children: ReactNode }) {
|
||||
return;
|
||||
}
|
||||
|
||||
setTransitionMessage(message);
|
||||
setIsTransitioning(true);
|
||||
|
||||
// Die Animation des Shutters abwarten (ca. 700ms), dann pushen
|
||||
@@ -35,12 +38,14 @@ export function TransitionProvider({ children }: { children: ReactNode }) {
|
||||
// Next.js Route-Changes sind fast sofort da, aber wir geben dem Cache kurz Zeit
|
||||
setTimeout(() => {
|
||||
setIsTransitioning(false);
|
||||
// Message etwas verzögert zurücksetzen, damit es während dem Ausblenden nicht verschwindet
|
||||
setTimeout(() => setTransitionMessage(null), 300);
|
||||
}, 300);
|
||||
}, 700);
|
||||
}, [isTransitioning, router]);
|
||||
|
||||
return (
|
||||
<TransitionContext.Provider value={{ isTransitioning, startTransition }}>
|
||||
<TransitionContext.Provider value={{ isTransitioning, transitionMessage, startTransition }}>
|
||||
{children}
|
||||
</TransitionContext.Provider>
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user