h-spa
v0.0.9
Published
Typescript Helpers
Downloads
18
Readme
Incredibly simple single pager router application
will generate a very simple home page
expects an element named content
Usage
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Page Title</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type="text/css" media="screen" href="https://static.jackman.biz/cdn/reset.css" />
</head>
<body>
<div id="menubar" style="position: fixed;top: 0"><a href="#">[🏠home]</a></div>
<div id="content"></div>
<script src="dist/index.js"></script>
<script src="/rldr"></script>
</body>
</html>
import {router} from "h-spa"
function demo1 (el: HTMLDivElement) => {
var alive = true
i = 0
function loop() {
el.innerText = `Counter: ${i++}`
if (alive) requestAnimationFrom(loop)
}
requestAnimationFrame(loop)
function stop() {alive = false}
return stop
}
function demo2 (el: HTMLDivElement) => {
el.innerText = "HELLO DEMO 2"
}
router({
demo1,
demo2,
})
http://localhost:1234/#demo1
http://localhost:1234/#demo2
http://localhost:1234/#demo3