0.0.9 • Published 4 years ago

h-spa v0.0.9

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

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
0.0.9

4 years ago

0.0.8

4 years ago

0.0.7

4 years ago

0.0.6

4 years ago

0.0.5

6 years ago

0.0.4

6 years ago

0.0.3

6 years ago

0.0.2

6 years ago