Move page titles into the top header bar to reclaim vertical space
PageHeader now sets title via context instead of rendering inline. TopBar displays the current page title and subtitle in the left area that was previously an empty spacer. Content area gains ~40px of vertical space on every page. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
39
src/lib/page-title-context.tsx
Normal file
39
src/lib/page-title-context.tsx
Normal file
@@ -0,0 +1,39 @@
|
||||
'use client';
|
||||
|
||||
import { createContext, useContext, useState, useCallback, ReactNode } from 'react';
|
||||
|
||||
interface PageTitleState {
|
||||
title: string;
|
||||
subtitle: string;
|
||||
}
|
||||
|
||||
interface PageTitleContextValue extends PageTitleState {
|
||||
setPageTitle: (title: string, subtitle: string) => void;
|
||||
}
|
||||
|
||||
const PageTitleContext = createContext<PageTitleContextValue>({
|
||||
title: '',
|
||||
subtitle: '',
|
||||
setPageTitle: () => {},
|
||||
});
|
||||
|
||||
export function PageTitleProvider({ children }: { children: ReactNode }) {
|
||||
const [state, setState] = useState<PageTitleState>({ title: '', subtitle: '' });
|
||||
|
||||
const setPageTitle = useCallback((title: string, subtitle: string) => {
|
||||
setState(prev => {
|
||||
if (prev.title === title && prev.subtitle === subtitle) return prev;
|
||||
return { title, subtitle };
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PageTitleContext.Provider value={{ ...state, setPageTitle }}>
|
||||
{children}
|
||||
</PageTitleContext.Provider>
|
||||
);
|
||||
}
|
||||
|
||||
export function usePageTitle() {
|
||||
return useContext(PageTitleContext);
|
||||
}
|
||||
Reference in New Issue
Block a user