Skip to content

9elt/miniframe

Repository files navigation

Miniframe

Everything you need to create nodes with states, in 200 loc

this is a beta, don't use it in production

example

A simple counter that stops at 10

import { State, createNode } from "@9elt/miniframe";

const counter = new State(0);

const root = createNode({
    tagName: "div",
    id: "root",
    style: { textAlign: "center" },
    children: [
        {
            tagName: "p",
            children: ["current count: ", counter]
        },
        {
            tagName: "p",
            style: {
                color: counter.as(c => c < 10 ? 'green' : 'red')
            },
            children: [counter.as(c => c < 10 ? 'keep going' : 'stop!')]
        },
        {
            tagName: "button",
            onclick: () => counter.value++,
            disabled: counter.as(c => c === 10),
            children: ["increment"],
        }
    ]
});

document.body.prepend(root);

About

Everything you need to create nodes with states, in 200 loc

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published