diff --git a/src/main.js b/src/main.js index d73e52d..2be167e 100644 --- a/src/main.js +++ b/src/main.js @@ -15,6 +15,7 @@ import { renderPage, } from "./pageUtils.js"; import { PageState } from "./PageState.js"; +import { makeElement } from "./htmlUtils.js"; import { HomePage, @@ -61,28 +62,67 @@ const pages = { var pageState = new PageState(); window.pageState = pageState; window.pages = pages; -// when making static html, make changePage global so it can be used with onclick window.changePage = changePage; +function ListItem(children) { + return makeElement({ + tag: "li", + children: children + }); +} + document.addEventListener('DOMContentLoaded', function () { - document.body.innerHTML += ` - -
-
-

Title

-
-
-
-
- `; + document.body.innerHTML = ""; + document.body.appendChild(makeElement({ + 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: "Home", + onclick: _ => { changePage(pages.HOME); } + })), + ListItem(makeElement({ + tag: "a", + text: "Back", + onclick: _ => { pageState.currentPage.goBack(); } + })), + ListItem(makeElement({ + tag: "a", + text: "Refresh", + onclick: _ => { changePage(pageState.currentPage); } + })), + ] + }) + }) + })); + document.body.appendChild(makeElement({ + tag: "div", + class: ["uk-container", "uk-container-medium", "uk-align-center"], + children: makeElement({ + tag: "div", + class: ["uk-card", "uk-card-body"], + children: [ + makeElement({ + tag: "h3", + class: "uk-card-title", + id: "pageTitle", + text: "Title" + }), + makeElement({ + tag: "div", + id: "pageContent" + }) + ] + }) + })); + window.pageContent = document.querySelector("#pageContent"); renderPage();