diff --git a/src/elements/NavBar.ts b/src/elements/NavBar.ts
deleted file mode 100644
index 032d0e8..0000000
--- a/src/elements/NavBar.ts
+++ /dev/null
@@ -1,74 +0,0 @@
-import { ListItem } from "./ListItem";
-import { PageRouter } from "z-pagerouter";
-import { makeElement } from "z-makeelement";
-import i18next from "i18next";
-
-export function NavBar(router: PageRouter): HTMLElement {
- return makeElement({
- id: "navBar",
- tag: "nav",
- class: ["uk-navbar", "uk-navbar-container"],
- children: [
- makeElement({
- tag: "div",
- class: "uk-navbar-left",
- children: makeElement({
- tag: "ul",
- class: "uk-navbar-nav",
- children: [
- ListItem(
- makeElement({
- tag: "a",
- text: i18next.t("home_btn"),
- onclick: async () => {
- await router.changePage("HOME");
- },
- }),
- ),
- ListItem(
- makeElement({
- tag: "a",
- text: i18next.t("back_btn"),
- onclick: async () => {
- await router.goBack();
- },
- }),
- ),
- ListItem(
- makeElement({
- tag: "a",
- text: i18next.t("refresh_btn"),
- onclick: async () => {
- await router.refresh();
- },
- }),
- ),
- ],
- }),
- }),
- makeElement({
- tag: "div",
- class: "uk-navbar-right",
- children: makeElement({
- tag: "ul",
- class: "uk-navbar-nav",
- children: [
- ListItem(
- makeElement({
- tag: "a",
- text: i18next.t("me_btn"),
- onclick: async () => {
- await router.changePage("ME");
- },
- }),
- ),
- ],
- }),
- }),
- ],
- });
-}
-
-export function reloadNavBar(router: PageRouter): void {
- document.querySelector("#navBar").replaceWith(NavBar(router));
-}
diff --git a/src/elements/NavBar.tsx b/src/elements/NavBar.tsx
new file mode 100644
index 0000000..8fcb043
--- /dev/null
+++ b/src/elements/NavBar.tsx
@@ -0,0 +1,62 @@
+import { JSX, render } from "preact";
+import { PageRouter } from "z-pagerouter";
+import i18next from "i18next";
+
+export type NavBarProps = {
+ router: PageRouter;
+};
+
+export function NavBar(props: NavBarProps): JSX.Element {
+ return (
+
+ );
+}
+
+export function reloadNavBar(router: PageRouter): void {
+ render(, document.querySelector("#navBarBox"));
+}
diff --git a/src/main.ts b/src/main.ts
index 75972d3..0119ca6 100644
--- a/src/main.ts
+++ b/src/main.ts
@@ -19,7 +19,6 @@ Prism.highlightAll();
// Actual Imports
-import { NavBar } from "./elements/NavBar";
import { PageRouter } from "z-pagerouter";
import { formatDistance } from "./formatDistance";
import { getSealStatus } from "./api/sys/getSealStatus";
@@ -27,6 +26,7 @@ import { makeElement } from "z-makeelement";
import { pageList } from "./allPages";
import { pageState } from "./globalPageState";
import { playground } from "./playground";
+import { reloadNavBar } from "./elements/NavBar";
import i18next from "i18next";
// @ts-ignore
@@ -34,7 +34,7 @@ import translations from "./translations/index.mjs";
async function onLoad(): Promise {
document.body.innerHTML = "";
- document.body.appendChild(makeElement({ tag: "div", id: "navBarReplace" }));
+ document.body.appendChild(makeElement({ tag: "div", id: "navBarBox" }));
document.body.appendChild(
makeElement({
tag: "div",
@@ -65,7 +65,7 @@ async function onLoad(): Promise {
document.getElementById("pageTitle"),
);
- document.querySelector("#navBarReplace").replaceWith(NavBar(pageRouter));
+ reloadNavBar(pageRouter);
pageRouter.addEventListener("pageChanged", async function (_) {
pageState.currentPage = await pageRouter.getCurrentPageID();