gale/app.js

54 lines
1.3 KiB
JavaScript
Raw Normal View History

2025-02-13 14:27:41 -05:00
const {DOM} = Gale({
Button: {
padding: "20px",
2025-02-22 16:38:11 -05:00
background: "blue",
2025-02-13 14:27:41 -05:00
".Inner": {
fontSize: "10rem"
2025-02-12 16:09:59 -05:00
}
},
2025-02-13 14:27:41 -05:00
Outline: {
border: "2px solid orange"
2025-02-22 09:37:11 -05:00
},
Window:{
height: "100vh",
border: "2px solid black",
display: "flex",
flexDirection: "row",
alignItems: "end",
justifyContent: "center",
gap: "10px"
},
Ability:{
width: "50px",
height: "50px",
background: "red",
transition: "all 0.4s",
":hover":{
transform:"scale(1.1)"
}
2025-02-13 14:27:41 -05:00
}
2025-02-12 16:09:59 -05:00
});
2025-02-13 14:27:41 -05:00
2025-02-19 17:01:11 -05:00
/** @typedef {{done:boolean, text:string}} Todo */
2025-02-22 16:38:11 -05:00
const items = vanX.Store({
2025-02-19 17:01:11 -05:00
pending:"",
todos:/** @type {Todo[]}*/([])
2025-02-22 16:38:11 -05:00
}, "Todos");
2025-02-19 17:01:11 -05:00
const {div, input, button, del, span, a} = van.tags;
const TodoList = () => {
const inputDom = input({type: "text", value:()=>items.pending, oninput(){items.pending = this.value}});
return div(
()=>div(items.pending),
inputDom, DOM.button.Outline.Button({onclick: () => items.todos.push({text: inputDom.value, done: false})}, "Add"),
vanX.list(div, items.todos, ({val: v}, deleter) => div(
input({type: "checkbox", checked: () => v.done, onclick: e => v.done = e.target.checked}),
() => (v.done ? del : span)(v.text),
a({onclick: deleter}, "❌"),
)),
)
2025-02-22 16:38:11 -05:00
}
van.add(document.body, TodoList());