remove everything except js code to be exported.

This commit is contained in:
trans_soup 2023-07-15 22:10:36 +02:00
parent 416d31b1ad
commit 9eca9236ea
4 changed files with 1 additions and 60 deletions

View File

@ -1,16 +0,0 @@
html, body {
margin: 0;
min-height: 100vh;
overflow: auto;
}
body {
background-color: #000;
color: #fff;
padding: 0;
}
a {
color: #0f0;
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 127 B

View File

@ -1,13 +0,0 @@
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" type="text/css" href="/assets/styles/base.css">
<title>json as html</title>
<script defer type="module" src="js/main.mjs"></script>
</head>
<body></body>

View File

@ -2,7 +2,7 @@ function use_as_array (val) {
return Array.isArray(val) ? val : [val];
}
function json_as_html (json, state = new Map()) {
export function json_as_html (json, state = new Map()) {
if (json instanceof Node) {
return json;
}
@ -28,33 +28,3 @@ function json_as_html (json, state = new Map()) {
return elem;
}
const demo = [
"div",
[
["id", "wrapper"]
],
[
["h1", [], "header :)"],
["p", [], "paragraph! meow"],
["p", [], "another paragraph!! this is so cool"],
state => ["button", [
["onclick", _ => {
state.set("clicked", true);
render();
}]
], "it can even do buttons!"],
state => ["p", [], state.get("clicked") ? "clicked" : "not clicked"],
],
];
const state = new Map();
function render () {
document.body.innerHTML = "";
document.body.appendChild(json_as_html(demo, state));
}
render();