feat: add initial cinematic loader and global shutter page transitions

Former-commit-id: 641bf3103e29559d7bdff1dc1e034b21a11dbad6
This commit is contained in:
2026-05-07 19:25:10 +02:00
parent cbc90aa872
commit b515e45c0d
9 changed files with 314 additions and 51 deletions

View File

@@ -1,5 +1,5 @@
import React from 'react';
import Link from 'next/link';
import { TransitionLink } from '@/components/ui/TransitionLink';
import { cn } from './utils';
export interface ButtonProps extends React.ButtonHTMLAttributes<HTMLButtonElement> {
@@ -88,9 +88,9 @@ export function Button({
if (href) {
return (
<Link href={href} className={styles}>
<TransitionLink href={href} className={styles}>
{content}
</Link>
</TransitionLink>
);
}

View File

@@ -0,0 +1,37 @@
'use client';
import React from 'react';
import Link, { LinkProps } from 'next/link';
import { useTransition } from '@/components/providers/TransitionProvider';
interface TransitionLinkProps extends Omit<React.AnchorHTMLAttributes<HTMLAnchorElement>, keyof LinkProps>, LinkProps {
children: React.ReactNode;
className?: string;
href: string;
}
export function TransitionLink({ children, href, onClick, ...props }: TransitionLinkProps) {
const { startTransition } = useTransition();
const handleClick = (e: React.MouseEvent<HTMLAnchorElement, MouseEvent>) => {
// Falls ein eigener onClick Handler übergeben wurde
if (onClick) onClick(e);
// Nicht bei neuen Tabs, Command-Klick, etc. intervenieren
if (e.ctrlKey || e.metaKey || e.shiftKey || e.altKey || props.target === '_blank') {
return;
}
// Default Link Navigation blockieren
e.preventDefault();
// Die Transition starten (welche intern pusht)
startTransition(href.toString());
};
return (
<Link href={href} onClick={handleClick} {...props}>
{children}
</Link>
);
}