// import { Fragment, h } from "../deps.ts"; import { faHome, faMoon, faRunning, faSun, } from "https://esm.sh/@fortawesome/free-solid-svg-icons@6.2.0"; import { FontAwesomeIcon } from "../deps.ts"; import { ComponentChildren, useState } from "../deps.ts"; import { Notification } from "../types.ts"; import { isMacLike } from "../../common/util.ts"; 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?: ComponentChildren; rhs?: ComponentChildren; }) { const [theme, setTheme] = useState(localStorage.theme ?? "light"); const isMac = isMacLike(); return (
{lhs}
{prettyName(pageName)} {notifications.length > 0 && (
{notifications.map((notification) => (
{notification.message}
))}
)}
{rhs}
); }