Skip to content

Commit

Permalink
review examples
Browse files Browse the repository at this point in the history
  • Loading branch information
marcodpt committed Nov 18, 2024
1 parent 4609ea4 commit 78b22bd
Show file tree
Hide file tree
Showing 11 changed files with 65 additions and 53 deletions.
2 changes: 1 addition & 1 deletion examples/convert.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>
<body>
<h1>
<img src="../favicon.ico">
<a href=".."><img src="../favicon.ico"></a>
Convert HTML to Hyperscript
</h1>
<div id="input">
Expand Down
30 changes: 29 additions & 1 deletion examples/counter.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,34 @@
<title>Counter - Hammer</title>
</head>
<body>
<script type="module" src="./counter.js"></script>
<h1>
<a href=".."><img src="../favicon.ico"></a>
Counter: <span>0</span>
</h1>
<script type="module">
import {dom} from "../index.js"

document.body.appendChild(dom(({button, text}) =>
button({
onclick: ev => {
const el = document.body.querySelector('span')
el.textContent = parseInt(el.textContent) - 1
}
}, [
text('-')
])
))

document.body.appendChild(dom(({button, text}) =>
button({
onclick: ev => {
const el = document.body.querySelector('span')
el.textContent = parseInt(el.textContent) + 1
}
}, [
text('+')
])
))
</script>
</body>
</html>
33 changes: 0 additions & 33 deletions examples/counter.js

This file was deleted.

5 changes: 3 additions & 2 deletions examples/debug.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@
</head>
<body>
<h1>
<img src="../favicon.ico">
<a href=".."><img src="../favicon.ico"></a>
To do list (Debug mode!)
</h1>
<input type="text">
<pre><code></code></pre>
<pre><code style="display: none"></code></pre>
<button onclick="addTodo(this)">
New!
</button>
Expand All @@ -24,6 +24,7 @@ <h1>
window.addTodo = btn => {
const input = document.body.querySelector('input')
const code = document.body.querySelector('code')
code.setAttribute('style', '')

code.textContent += (code.textContent ? '\n\n' : '')+
JSON.stringify(debug(({li, text}) => li({}, [
Expand Down
2 changes: 1 addition & 1 deletion examples/format.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>
<body>
<h1>
<img src="../favicon.ico">
<a href=".."><img src="../favicon.ico"></a>
Format HTML
</h1>
<div id="input">
Expand Down
2 changes: 1 addition & 1 deletion examples/hyperapp.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>
<body>
<h1>
<img src="../favicon.ico">
<a href=".."><img src="../favicon.ico"></a>
<a href="https://github.com/jorgebucaran/hyperapp">Hyperapp</a>
</h1>
<main id="app"></main>
Expand Down
3 changes: 1 addition & 2 deletions examples/superfine.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,8 @@
</head>
<body>
<h1>
<img src="../favicon.ico">
<a href=".."><img src="../favicon.ico"></a>
<a href="https://github.com/jorgebucaran/superfine">Superfine</a>
Counter
</h1>
<main id="app"></main>
<script type="module" src="./superfine_counter.js"></script>
Expand Down
2 changes: 1 addition & 1 deletion examples/superfine_counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const setState = state => superfine(
document.getElementById("app"),
({main, h1, button, text}) => main({}, [
h1({}, [
text(state)
text('Counter: '+String(state))
]),
button({
onclick: () => setState(state - 1)
Expand Down
2 changes: 1 addition & 1 deletion examples/template.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
</head>
<body>
<h1>
<img src="../favicon.ico">
<a href=".."><img src="../favicon.ico"></a>
To do list (text based!)
</h1>
<input type="text">
Expand Down
28 changes: 27 additions & 1 deletion examples/todo.html
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,32 @@
<title>Todo - Hammer</title>
</head>
<body>
<script type="module" src="./todo.js"></script>
<h1>
<a href=".."><img src="../favicon.ico"></a>
To do list
</h1>
<input type="text">
<ul></ul>
<script type="module">
import {dom} from "../index.js"

document.body.appendChild(dom(({
button, li, text
}) =>
button({
onclick: ev => {
const input = document.body.querySelector('input')
document.body.querySelector('ul').appendChild(
li({}, [
text(input.value)
])
)
input.value = ""
}
}, [
text('New!')
])
))
</script>
</body>
</html>
9 changes: 0 additions & 9 deletions examples/todo.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,6 @@ document.body.appendChild(dom(({
main, h1, img, input, ul, li, button, text
}) =>
main({}, [
h1({}, [
img({
src: '../favicon.ico'
}),
text(' To do list')
]),
input({
type: 'text'
}),
ul(),
button({
onclick: ev => {
Expand Down

0 comments on commit 78b22bd

Please sign in to comment.