优化代码,拆分组件

This commit is contained in:
2025-10-28 11:58:02 +08:00
parent 4529c58aad
commit 00d7aee32a
22 changed files with 2745 additions and 3064 deletions

12
src/components/Window.tsx Normal file
View File

@@ -0,0 +1,12 @@
"use client";
interface WindowProps {
children?: React.ReactNode;
className?: string;
}
export default function Window({ children }: WindowProps) {
return (
<div className="w-full bg-gray-200 h-screen flex justify-center items-center">
{children}
</div>
);
}

View File

@@ -1,4 +1,6 @@
export default function Button({
import PlainButton from "./PlainButton";
export default function DarkButton({
onClick,
className,
selected,
@@ -10,11 +12,11 @@ export default function Button({
children?: React.ReactNode;
}) {
return (
<button
<PlainButton
onClick={onClick}
className={`px-2 py-1 rounded shadow-2xs font-bold hover:bg-gray-300 hover:cursor-pointer ${selected ? "bg-gray-300" : "bg-white"} ${className}`}
className={`hover:bg-gray-600 text-white ${selected ? "bg-gray-600" : "bg-gray-800"} ${className}`}
>
{children}
</button>
</PlainButton>
);
}

View File

@@ -0,0 +1,22 @@
import PlainButton from "./PlainButton";
export default function LightButton({
onClick,
className,
selected,
children,
}: {
onClick?: () => void;
className?: string;
selected?: boolean;
children?: React.ReactNode;
}) {
return (
<PlainButton
onClick={onClick}
className={`hover:bg-gray-200 text-gray-800 ${selected ? "bg-gray-200" : "bg-white"} ${className}`}
>
{children}
</PlainButton>
);
}

View File

@@ -0,0 +1,18 @@
export default function PlainButton({
onClick,
className,
children,
}: {
onClick?: () => void;
className?: string;
children?: React.ReactNode;
}) {
return (
<button
onClick={onClick}
className={`px-2 py-1 rounded shadow font-bold hover:cursor-pointer ${className}`}
>
{children}
</button>
);
}

View File

@@ -0,0 +1,16 @@
"use client";
interface ACardProps {
children?: React.ReactNode;
className?: string;
}
export default function ACard({ children, className }: ACardProps) {
return (
<div
className={`${className} w-[61vw] h-96 p-2 shadow-2xl bg-white rounded-xl`}
>
{children}
</div>
);
}

View File

@@ -0,0 +1,12 @@
"use client";
interface BCardProps {
children?: React.ReactNode;
className?: string;
}
export default function BCard({ children, className }: BCardProps) {
return (
<div className={`${className} rounded-xl p-2 shadow-xl`}>{children}</div>
);
}