Skip to content

Commit

Permalink
Merge pull request #1 from sitcon-tw/feature/layout
Browse files Browse the repository at this point in the history
Feature/layout
  • Loading branch information
pizza6inch authored Feb 2, 2025
2 parents e2db3cf + 879abd3 commit 3c164ad
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 8 deletions.
7 changes: 7 additions & 0 deletions src/app/(screens)/fragment/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function FragmentPage() {
return (
<>
<p>板塊頁面</p>
</>
);
}
7 changes: 7 additions & 0 deletions src/app/(screens)/game/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function GamePage() {
return (
<>
<p>遊戲頁面</p>
</>
);
}
7 changes: 7 additions & 0 deletions src/app/(screens)/personal/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function PersonalPage() {
return (
<>
<p>個人頁面</p>
</>
);
}
7 changes: 7 additions & 0 deletions src/app/(screens)/store/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export default function StorePage() {
return (
<>
<p>商店頁面</p>
</>
);
}
51 changes: 43 additions & 8 deletions src/app/layout.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
import type { Metadata } from "next";
import "./globals.css";
import texts from "@/data/metadata.json";
"use client";

export const metadata: Metadata = {
title: texts.title,
description: texts.description,
};
import "./globals.css";
import Link from "next/link";
import { Blocks, Gamepad, LucideIcon, Store, UserRound } from "lucide-react";
import { cn } from "@/lib/utils";
import { usePathname } from "next/navigation";

export default function RootLayout({
children,
Expand All @@ -14,7 +13,43 @@ export default function RootLayout({
}>) {
return (
<html lang="zh-Hant-TW">
<body className="m-4 h-screen">{children}</body>
<body className="flex h-screen flex-col overflow-hidden">
<div className="h-full w-full">{children}</div>
<div className="w-full">
<footer className="flex border-t-2 border-gray-400 bg-gray-200 px-2 py-2 text-center text-sm text-gray-600">
<NavbarItem href="/" name="遊戲" Icon={Gamepad} />
<NavbarItem href="/fragment" name="板塊" Icon={Blocks} />
<NavbarItem href="/store" name="商店" Icon={Store} />
<NavbarItem href="/personal" name="個人" Icon={UserRound} />
</footer>
</div>
</body>
</html>
);
}

function NavbarItem({
href,
name,
Icon,
}: Readonly<{
href: string;
name: string;
Icon: LucideIcon;
}>) {
const pathname = usePathname();
const isActive = pathname === href;
return (
<Link href={href} className="flex-1 px-4">
<div
className={cn(
"flex flex-col items-center justify-center gap-1 px-3 py-1",
isActive && "border-b-2 border-blue-500 text-blue-500",
)}
>
<Icon strokeWidth={2} size={32} />
{name}
</div>
</Link>
);
}

0 comments on commit 3c164ad

Please sign in to comment.