2022-04-04 16:33:13 +00:00
|
|
|
import {Notification} from "../types";
|
|
|
|
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
|
|
|
import {faFileLines} from "@fortawesome/free-solid-svg-icons";
|
2022-03-20 08:56:28 +00:00
|
|
|
|
|
|
|
function prettyName(s: string | undefined): string {
|
|
|
|
if (!s) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
return s.replaceAll("/", " / ");
|
|
|
|
}
|
|
|
|
|
|
|
|
export function TopBar({
|
|
|
|
pageName,
|
2022-03-31 12:28:07 +00:00
|
|
|
unsavedChanges,
|
2022-03-20 08:56:28 +00:00
|
|
|
notifications,
|
|
|
|
onClick,
|
2022-04-04 16:33:13 +00:00
|
|
|
lhs,
|
|
|
|
rhs,
|
2022-03-20 08:56:28 +00:00
|
|
|
}: {
|
|
|
|
pageName?: string;
|
2022-03-31 12:28:07 +00:00
|
|
|
unsavedChanges: boolean;
|
2022-03-20 08:56:28 +00:00
|
|
|
notifications: Notification[];
|
|
|
|
onClick: () => void;
|
2022-04-04 16:33:13 +00:00
|
|
|
lhs?: React.ReactNode;
|
|
|
|
rhs?: React.ReactNode;
|
2022-03-20 08:56:28 +00:00
|
|
|
}) {
|
|
|
|
return (
|
|
|
|
<div id="top" onClick={onClick}>
|
2022-04-04 16:33:13 +00:00
|
|
|
{lhs}
|
|
|
|
<div className="main">
|
|
|
|
<div className="inner">
|
|
|
|
<span className={`icon ${unsavedChanges ? "unsaved" : "saved"}`}>
|
|
|
|
<FontAwesomeIcon icon={faFileLines} />
|
|
|
|
</span>
|
|
|
|
<span className="current-page">{prettyName(pageName)}</span>
|
|
|
|
{notifications.length > 0 && (
|
|
|
|
<div className="status">
|
|
|
|
{notifications.map((notification) => (
|
|
|
|
<div key={notification.id}>{notification.message}</div>
|
|
|
|
))}
|
|
|
|
</div>
|
|
|
|
)}
|
|
|
|
</div>
|
2022-03-20 08:56:28 +00:00
|
|
|
</div>
|
2022-04-04 16:33:13 +00:00
|
|
|
{rhs}
|
2022-03-20 08:56:28 +00:00
|
|
|
</div>
|
|
|
|
);
|
|
|
|
}
|