Refactor Card component to use 'hoverable' prop instead of 'hover'; simplify class handling in Badge, Button, and Card components for cleaner code; update Home page cards for consistency and improved styling.
This commit is contained in:
parent
97061f2353
commit
0beb20635f
4 changed files with 19 additions and 48 deletions
|
|
@ -4,14 +4,12 @@ interface BadgeProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
variant?: 'gray' | 'green' | 'yellow' | 'red' | 'blue' | 'glass';
|
variant?: 'gray' | 'green' | 'yellow' | 'red' | 'blue' | 'glass';
|
||||||
border?: boolean;
|
border?: boolean;
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Badge({
|
export default function Badge({
|
||||||
children,
|
children,
|
||||||
variant = 'gray',
|
variant = 'gray',
|
||||||
border = false,
|
border = false,
|
||||||
className = ''
|
|
||||||
}: BadgeProps) {
|
}: BadgeProps) {
|
||||||
const baseClasses = "rounded-full px-2 py-0.5 text-sm";
|
const baseClasses = "rounded-full px-2 py-0.5 text-sm";
|
||||||
|
|
||||||
|
|
@ -26,7 +24,7 @@ export default function Badge({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<span
|
<span
|
||||||
className={` ${border?"border":""} ${baseClasses} ${variantClasses[variant]} ${className}`}
|
className={` ${border?"border":""} ${baseClasses} ${variantClasses[variant]}`}
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -4,15 +4,12 @@ interface ButtonProps extends ButtonHTMLAttributes<HTMLButtonElement> {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
variant?: 'primary' | 'secondary' | 'ghost' | 'outline' | 'glass';
|
variant?: 'primary' | 'secondary' | 'ghost' | 'outline' | 'glass';
|
||||||
size?: 'sm' | 'md' | 'lg';
|
size?: 'sm' | 'md' | 'lg';
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Button({
|
export default function Button({
|
||||||
children,
|
children,
|
||||||
variant = 'primary',
|
variant = 'primary',
|
||||||
size = 'md',
|
size = 'md',
|
||||||
className = '',
|
|
||||||
...props
|
|
||||||
}: ButtonProps) {
|
}: ButtonProps) {
|
||||||
const baseClasses = "cursor-pointer font-medium rounded-lg transition-all duration-300 ease-out focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 disabled:opacity-50 disabled:cursor-not-allowed";
|
const baseClasses = "cursor-pointer font-medium rounded-lg transition-all duration-300 ease-out focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-offset-gray-900 disabled:opacity-50 disabled:cursor-not-allowed";
|
||||||
|
|
||||||
|
|
@ -32,8 +29,7 @@ export default function Button({
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<button
|
<button
|
||||||
className={`${baseClasses} ${sizeClasses[size]} ${variantClasses[variant]} ${className}`}
|
className={`${baseClasses} ${sizeClasses[size]} ${variantClasses[variant]}`}
|
||||||
{...props}
|
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</button>
|
</button>
|
||||||
|
|
|
||||||
|
|
@ -2,18 +2,13 @@ import { ReactNode } from 'react';
|
||||||
|
|
||||||
interface CardProps {
|
interface CardProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
className?: string;
|
|
||||||
variant?: 'default' | 'glass' | 'outlined';
|
variant?: 'default' | 'glass' | 'outlined';
|
||||||
hover?: boolean;
|
hoverable?: boolean;
|
||||||
style?: React.CSSProperties;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function Card({
|
export default function Card({
|
||||||
children,
|
children,
|
||||||
className = '',
|
|
||||||
variant = 'default',
|
variant = 'default',
|
||||||
hover = false,
|
|
||||||
style
|
|
||||||
}: CardProps) {
|
}: CardProps) {
|
||||||
const baseClasses = "relative overflow-hidden rounded-xl transition-all duration-300 ease-out";
|
const baseClasses = "relative overflow-hidden rounded-xl transition-all duration-300 ease-out";
|
||||||
|
|
||||||
|
|
@ -23,17 +18,9 @@ export default function Card({
|
||||||
outlined: "bg-transparent border-2 border-gray-700/50"
|
outlined: "bg-transparent border-2 border-gray-700/50"
|
||||||
};
|
};
|
||||||
|
|
||||||
const hoverClasses = hover
|
|
||||||
? "hover:scale-[1.02] hover:shadow-2xl hover:shadow-blue-500/10 hover:border-blue-500/30"
|
|
||||||
: "";
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div
|
<div
|
||||||
className={`${baseClasses} ${variantClasses[variant]} ${hoverClasses} ${className}`}
|
className={`${baseClasses} ${variantClasses[variant]}`}
|
||||||
style={{
|
|
||||||
willChange: 'transform',
|
|
||||||
...style
|
|
||||||
}}
|
|
||||||
>
|
>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
|
|
@ -42,12 +29,11 @@ export default function Card({
|
||||||
|
|
||||||
interface CardHeaderProps {
|
interface CardHeaderProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CardHeader({ children, className = '' }: CardHeaderProps) {
|
export function CardHeader({ children }: CardHeaderProps) {
|
||||||
return (
|
return (
|
||||||
<div className={`p-6 pb-0 ${className}`}>
|
<div className={`p-6 pb-0`}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -55,12 +41,11 @@ export function CardHeader({ children, className = '' }: CardHeaderProps) {
|
||||||
|
|
||||||
interface CardContentProps {
|
interface CardContentProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CardContent({ children, className = '' }: CardContentProps) {
|
export function CardContent({ children }: CardContentProps) {
|
||||||
return (
|
return (
|
||||||
<div className={`p-6 pb-4 ${className}`}>
|
<div className={`p-6 pb-4`}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
@ -68,12 +53,11 @@ export function CardContent({ children, className = '' }: CardContentProps) {
|
||||||
|
|
||||||
interface CardFooterProps {
|
interface CardFooterProps {
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
className?: string;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export function CardFooter({ children, className = '' }: CardFooterProps) {
|
export function CardFooter({ children }: CardFooterProps) {
|
||||||
return (
|
return (
|
||||||
<div className={`p-6 pt-8 ${className}`}>
|
<div className={`p-6 pt-8`}>
|
||||||
{children}
|
{children}
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
13
app/page.tsx
13
app/page.tsx
|
|
@ -8,8 +8,7 @@ export default function Home() {
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-6">
|
||||||
<Card
|
<Card
|
||||||
variant="glass"
|
variant="glass"
|
||||||
className="float"
|
hoverable
|
||||||
hover
|
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<h3 className="text-xl font-semibold text-white mb-2">Über mich</h3>
|
<h3 className="text-xl font-semibold text-white mb-2">Über mich</h3>
|
||||||
|
|
@ -23,9 +22,7 @@ export default function Home() {
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
variant="default"
|
variant="default"
|
||||||
className="float"
|
hoverable
|
||||||
hover
|
|
||||||
style={{ animationDelay: '1s' }}
|
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<h3 className="text-xl font-semibold text-white mb-2">Aktuelle Beschäftigung</h3>
|
<h3 className="text-xl font-semibold text-white mb-2">Aktuelle Beschäftigung</h3>
|
||||||
|
|
@ -38,9 +35,7 @@ export default function Home() {
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
className="float"
|
hoverable
|
||||||
hover
|
|
||||||
style={{ animationDelay: '2s' }}
|
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<h3 className="text-xl font-semibold text-white mb-2">Erfahrung</h3>
|
<h3 className="text-xl font-semibold text-white mb-2">Erfahrung</h3>
|
||||||
|
|
@ -150,7 +145,6 @@ export default function Home() {
|
||||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
<div className="grid grid-cols-1 md:grid-cols-2 gap-6">
|
||||||
<Card
|
<Card
|
||||||
variant="glass"
|
variant="glass"
|
||||||
className="hover:neon-glow"
|
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<h3 className="text-lg font-semibold text-white">Raytracing in a Weekend</h3>
|
<h3 className="text-lg font-semibold text-white">Raytracing in a Weekend</h3>
|
||||||
|
|
@ -173,7 +167,6 @@ export default function Home() {
|
||||||
|
|
||||||
<Card
|
<Card
|
||||||
variant="glass"
|
variant="glass"
|
||||||
className="hover:neon-glow"
|
|
||||||
>
|
>
|
||||||
<CardHeader>
|
<CardHeader>
|
||||||
<h3 className="text-lg font-semibold text-white">6502 Emulator</h3>
|
<h3 className="text-lg font-semibold text-white">6502 Emulator</h3>
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue