import { faRunning, faHome, faSun, faMoon, } from "@fortawesome/free-solid-svg-icons"; import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; import { useEffect, useState } from "react"; import { Notification } from "../types"; import { isMacLike } from "../../common/util"; function prettyName(s: string | undefined): string { if (!s) { return ""; } return s.replaceAll("/", " / "); } export function TopBar({ pageName, unsavedChanges, isLoading, notifications, onClick, onThemeClick, onHomeClick, onActionClick, lhs, rhs, }: { pageName?: string; unsavedChanges: boolean; isLoading: boolean; notifications: Notification[]; onClick: () => void; onThemeClick: () => void; onHomeClick: () => void; onActionClick: () => void; lhs?: React.ReactNode; rhs?: React.ReactNode; }) { const [theme, setTheme] = useState(localStorage.theme ?? "light"); const isMac = isMacLike(); return (
{lhs}
{prettyName(pageName)} {notifications.length > 0 && (
{notifications.map((notification) => (
{notification.message}
))}
)}
{rhs}
); }