todo example as test

This commit is contained in:
Geoff Doty 2024-05-05 15:05:08 -04:00
parent 21f4c4344d
commit c91c015ffd
1 changed files with 30 additions and 15 deletions

View File

@ -7,26 +7,41 @@
<title>Tagged UI Creation Lib</title> <title>Tagged UI Creation Lib</title>
</head> </head>
<body> <body>
<div id="app"> <div id="app"></div>
Tagged Loading...
</div>
<script type="module"> <script type="module">
import {app, h} from "../src/index.js"; import {app, h} from "../src/index.js";
const myapp = app({ const $ = document.querySelector.bind(document);
state: {name: "[Your Name Here]", job: "Developer"},
view(state, actions) { const todo = app({
return h("main", [ state: {todos: ["one", "two", "three"], value: ""},
h("strong", `Greeting from ${state.name}`), actions: {
h("div", `Your local ${state.job}`), add: (state, event) => {
h("div", {id: "test"}, [ return {...state, todos: [...state.todos, $("#todo").value]};
h("h1", "Hello Tagged"),
h("p", 21),
h("hr")
])
]);
} }
}, "#app"); },
view: (state, actions) => {
return h("main", [
h("h1", "Todo App"),
h("hr"),
h("div", [
h("label", "Todo"),
h("input", {id: "todo", value: state.value}),
h("button", {onclick: actions.add}, "Add")
]),
h("hr"),
h("ul", state.todos.map((i) => {
return h("li", {}, i)
})
),
h("hr"),
h("strong", `Count: ${state.todos.length}`),
h("hr"),
]);
},
mount: "#app"
});
</script> </script>
</body> </body>
</html> </html>