refactor: extract header and footer components and removed link to changelog page

This commit is contained in:
siujamo
2026-03-02 09:42:20 +08:00
parent 605087f0a8
commit 25d95df8f7
4 changed files with 65 additions and 88 deletions
+18
View File
@@ -0,0 +1,18 @@
import { useTranslation } from "react-i18next"
import { useMemo } from "react"
import dayjs from "dayjs"
export default function Footer() {
const { t } = useTranslation()
const today = useMemo(() => dayjs(), [])
return (
<footer className="bg-white border-t shrink-0">
<div className="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8">
<p className="text-center text-sm text-gray-500">
{t("app.copyright", { year: today.year() })}
</p>
</div>
</footer>
)
}
+39
View File
@@ -0,0 +1,39 @@
import { Link } from "react-router-dom"
import { useTranslation } from "react-i18next"
import LanguageSwitcher from "@/components/language-switcher"
export default function Header() {
const { t } = useTranslation()
return (
<header className="bg-white shadow-sm border-b">
<div className="px-4">
<div className="flex justify-between items-center h-16">
<div className="flex items-center">
<h1 className="text-xl font-semibold text-gray-900">{t("app.title")}</h1>
</div>
<div className="flex items-center gap-4">
<nav className="flex space-x-8">
<Link
to="/"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.home")}
</Link>
<Link
to="/about"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.about")}
</Link>
<Link
to="/contact"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.contact")}
</Link>
</nav>
<LanguageSwitcher />
</div>
</div>
</div>
</header>
)
}
+4 -47
View File
@@ -3,6 +3,8 @@ import { useMemo } from "react"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
import dayjs from "dayjs" import dayjs from "dayjs"
import LanguageSwitcher from "@/components/language-switcher" import LanguageSwitcher from "@/components/language-switcher"
import Header from "@/components/header"
import Footer from "@/components/footer"
/** /**
* Main application component that serves as the root layout. * Main application component that serves as the root layout.
@@ -15,46 +17,7 @@ export default function HeroLayout() {
return ( return (
<div className="h-screen bg-gray-50 flex flex-col overflow-hidden"> <div className="h-screen bg-gray-50 flex flex-col overflow-hidden">
{/* Navigation Header */} {/* Navigation Header */}
<header className="bg-white shadow-sm border-b"> <Header></Header>
<div className="px-4">
<div className="flex justify-between items-center h-16">
<div className="flex items-center">
<h1 className="text-xl font-semibold text-gray-900">
{t("app.title")}
</h1>
</div>
<div className="flex items-center gap-4">
<nav className="flex space-x-8">
<Link
to="/"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium"
>
{t("navigation.home")}
</Link>
<Link
to="/about"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium"
>
{t("navigation.about")}
</Link>
<Link
to="/contact"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium"
>
{t("navigation.contact")}
</Link>
<Link
to="/changelog"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium"
>
{t("navigation.changelog")}
</Link>
</nav>
<LanguageSwitcher />
</div>
</div>
</div>
</header>
{/* Main Content Area */} {/* Main Content Area */}
<main className="flex-1 p-4 overflow-hidden min-h-0"> <main className="flex-1 p-4 overflow-hidden min-h-0">
@@ -62,13 +25,7 @@ export default function HeroLayout() {
</main> </main>
{/* Footer */} {/* Footer */}
<footer className="bg-white border-t shrink-0"> <Footer></Footer>
<div className="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8">
<p className="text-center text-sm text-gray-500">
{t("app.copyright", { year: today.year() })}
</p>
</div>
</footer>
</div> </div>
) )
} }
+4 -41
View File
@@ -3,6 +3,8 @@ import { Link, NavLink, Outlet } from "react-router-dom"
import { useTranslation } from "react-i18next" import { useTranslation } from "react-i18next"
import dayjs from "dayjs" import dayjs from "dayjs"
import LanguageSwitcher from "@/components/language-switcher" import LanguageSwitcher from "@/components/language-switcher"
import Header from "@/components/header"
import Footer from "@/components/footer"
export default function ToolsLayout() { export default function ToolsLayout() {
const today = useMemo(() => dayjs(), []) const today = useMemo(() => dayjs(), [])
@@ -28,40 +30,7 @@ export default function ToolsLayout() {
return ( return (
<div className="h-screen bg-gray-50 flex flex-col overflow-hidden"> <div className="h-screen bg-gray-50 flex flex-col overflow-hidden">
<header className="bg-white shadow-sm border-b"> <Header></Header>
<div className="px-4">
<div className="flex justify-between items-center h-16">
<div className="flex items-center">
<h1 className="text-xl font-semibold text-gray-900">{t("app.title")}</h1>
</div>
<div className="flex items-center gap-4">
<nav className="flex space-x-8">
<Link
to="/"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.home")}
</Link>
<Link
to="/about"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.about")}
</Link>
<Link
to="/contact"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.contact")}
</Link>
<Link
to="/changelog"
className="text-gray-500 hover:text-gray-900 px-3 py-2 rounded-md text-sm font-medium">
{t("navigation.changelog")}
</Link>
</nav>
<LanguageSwitcher />
</div>
</div>
</div>
</header>
<main className="flex-1 p-4 overflow-hidden min-h-0"> <main className="flex-1 p-4 overflow-hidden min-h-0">
<div className="h-full flex gap-4 overflow-hidden"> <div className="h-full flex gap-4 overflow-hidden">
@@ -120,13 +89,7 @@ export default function ToolsLayout() {
</div> </div>
</main> </main>
<footer className="bg-white border-t shrink-0"> <Footer></Footer>
<div className="max-w-7xl mx-auto py-4 px-4 sm:px-6 lg:px-8">
<p className="text-center text-sm text-gray-500">
{t("app.copyright", { year: today.year() })}
</p>
</div>
</footer>
</div> </div>
) )
} }