1
0
silverbullet/webapp/components/top_bar.tsx

61 lines
1.4 KiB
TypeScript
Raw Normal View History

2022-04-05 15:02:17 +00:00
import { Notification } from "../types";
function prettyName(s: string | undefined): string {
if (!s) {
return "";
}
return s.replaceAll("/", " / ");
}
export function TopBar({
pageName,
unsavedChanges,
notifications,
onClick,
2022-04-04 16:33:13 +00:00
lhs,
rhs,
}: {
pageName?: string;
unsavedChanges: boolean;
notifications: Notification[];
onClick: () => void;
2022-04-04 16:33:13 +00:00
lhs?: React.ReactNode;
rhs?: React.ReactNode;
}) {
return (
<div id="top" onClick={onClick}>
2022-04-04 16:33:13 +00:00
{lhs}
<div className="main">
<div className="inner">
2022-04-10 09:04:07 +00:00
{/*<span className={`icon ${unsavedChanges ? "unsaved" : "saved"}`}>*/}
{/* <FontAwesomeIcon icon={faFileLines} />*/}
{/*</span>*/}
<span
className={`current-page ${unsavedChanges ? "unsaved" : "saved"}`}
>
{prettyName(pageName)}
2022-04-04 16:33:13 +00:00
</span>
2022-04-09 12:28:41 +00:00
{/*<button*/}
{/* onClick={(e) => {*/}
{/* // @ts-ignore*/}
{/* window.syncer();*/}
{/* e.stopPropagation();*/}
{/* }}*/}
{/*>*/}
{/* Sync*/}
{/*</button>*/}
2022-04-04 16:33:13 +00:00
{notifications.length > 0 && (
<div className="status">
{notifications.map((notification) => (
<div key={notification.id}>{notification.message}</div>
))}
</div>
)}
</div>
</div>
2022-04-04 16:33:13 +00:00
{rhs}
</div>
);
}