diff --git a/index.html b/index.html index d361c2f..00cdd51 100644 --- a/index.html +++ b/index.html @@ -7,8 +7,9 @@ diff --git a/playground/pages/sinks/Attach.ts b/playground/pages/sinks/Attach.ts index e96f705..412ffb1 100644 --- a/playground/pages/sinks/Attach.ts +++ b/playground/pages/sinks/Attach.ts @@ -1,65 +1,48 @@ -import { listen, reactive } from "@f-stack/functorial"; -import { attach, attr, html, on, show } from "@f-stack/reflow"; +import { reactive } from "@f-stack/functorial"; +import { attach, attr, component, html, on, show } from "@f-stack/reflow"; export const AttachPage = () => { - const form = reactive({ value: "Bob" }); - const color = reactive({ value: "#40E0D0" }); - const display = reactive({ value: true }); + const state = reactive({ color: "#40E0D0", show: true }); return html` -
- - -
-
({ input: function () { - color.value = this.value; + state.color = this.value; }, })}> - +
- ${show(() => display.value, () => - html` - { - const context = canvas.getContext("2d"); + ${show( + () => state.show, + component(function () { + return html` + { + const context = canvas.getContext("2d"); - if (context) { - const draw = (color: string) => { - context.fillStyle = color; - context.fillRect(0, 0, 200, 200); - }; + if (context) { + const draw = (color: string) => { + context.fillStyle = color; + context.fillRect(0, 0, 200, 200); + }; - draw(color.value); + draw(state.color); - listen(color, (e) => { - console.log(e); - if (e.type !== "update") return; - draw(e.newValue); - }); - } - }, - )}>Enable JS - `)} + this.listen(state, (e) => { + console.log(e); + if (e.type !== "update") return; + draw(e.newValue); + }); + } + }, + )}>Enable JS + `; + }), + )}