From 79c8c67be0a183d67ea89010d6b911684f039824 Mon Sep 17 00:00:00 2001 From: fyui001 Date: Fri, 10 Jul 2026 02:43:10 +0900 Subject: [PATCH 1/3] Move the page title into the top header Derive the title from the active nav item and render it in the header bar, replacing the duplicated app name. Content areas no longer repeat the section heading; action rows stay right-aligned. Detail and edit pages keep their own content headings. --- components/layout/AppShell.tsx | 24 ++++++++++++------- components/page-component/DashboardPage.tsx | 5 +--- components/page-component/DrugListPage.tsx | 4 +--- .../page-component/MedicationHistoryPage.tsx | 10 ++++---- components/page-component/SettingsPage.tsx | 2 -- stories/layout/AppShell.stories.tsx | 8 +++---- 6 files changed, 25 insertions(+), 28 deletions(-) diff --git a/components/layout/AppShell.tsx b/components/layout/AppShell.tsx index e7387a7..d038814 100644 --- a/components/layout/AppShell.tsx +++ b/components/layout/AppShell.tsx @@ -92,6 +92,18 @@ const NAV_EXTRA: NavItem[] = [ { text: '設定', href: '/settings', icon: Settings }, ] +const ALL_NAV_ITEMS = [...NAV_GROUPS.flatMap((g) => g.items), ...NAV_EXTRA] + +/** ヘッダーに表示するページタイトル — アクティブなナビ項目から導出する */ +function usePageTitle() { + const pathname = usePathname() + return ( + ALL_NAV_ITEMS.find( + (item) => pathname === item.href || pathname.startsWith(`${item.href}/`), + )?.text ?? 'Grace' + ) +} + const SIDEBAR_COLLAPSED_WIDTH = 56 interface AppShellProps { @@ -113,6 +125,7 @@ export default function AppShell({ const pathname = usePathname() const router = useRouter() const isMobile = useIsMobile() + const pageTitle = usePageTitle() const [sidebarOpen, setSidebarOpenState] = useState(initialSidebarOpen) const [mobileMenuOpen, setMobileMenuOpen] = useState(false) const [groupOpen, setGroupOpen] = useState(true) @@ -136,8 +149,6 @@ export default function AppShell({ [router], ) - const allNavItems = [...NAV_GROUPS.flatMap((g) => g.items), ...NAV_EXTRA] - const sideNavContent = (