| 1 | import { ArrowLeftIcon } from "@heroicons/react/24/outline"; |
| 2 | import { useFontSize } from "./ui/font"; |
| 3 | |
| 4 | export interface PageHeaderProps { |
| 5 | onTitleClick?: () => void; |
| 6 | title?: string; |
| 7 | rightContent?: React.ReactNode; |
| 8 | showBorder?: boolean; |
| 9 | } |
| 10 | |
| 11 | export function PageHeader({ |
| 12 | onTitleClick, |
| 13 | title, |
| 14 | rightContent, |
| 15 | showBorder, |
| 16 | }: PageHeaderProps) { |
| 17 | const fontSize = useFontSize(-1); |
| 18 | |
| 19 | return ( |
| 20 | <div |
| 21 | className={`sticky top-0 z-20 m-0 flex items-center justify-between bg-inherit py-1 ${ |
| 22 | showBorder |
| 23 | ? "border-0 border-b-[1px] border-solid border-b-zinc-700" |
| 24 | : "" |
| 25 | }`} |
| 26 | > |
| 27 | {title ? ( |
| 28 | <div |
| 29 | className="flex cursor-pointer items-center transition-colors duration-200 hover:brightness-125" |
| 30 | onClick={onTitleClick} |
| 31 | > |
| 32 | <ArrowLeftIcon className="ml-3 inline-block h-3 w-3" /> |
| 33 | <span |
| 34 | className="mx-2 inline-block text-lg font-bold" |
| 35 | style={{ |
| 36 | fontSize, |
| 37 | }} |
| 38 | > |
| 39 | {title} |
| 40 | </span> |
| 41 | </div> |
| 42 | ) : ( |
| 43 | <div /> |
| 44 | )} |
| 45 | |
| 46 | {rightContent && <div className="pr-2">{rightContent}</div>} |
| 47 | </div> |
| 48 | ); |
| 49 | } |