Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/9elt/miniframe

Everything you need to create nodes with states, in 200 LOC
https://github.com/9elt/miniframe

vanilla-js

Last synced: 1 day ago
JSON representation

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

Awesome Lists containing this project

README

        

# Miniframe

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

> This is a beta, do not use in production!

## usage

In your `tsconfig.json` add:

```json
{
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "@9elt/miniframe"
}
}
```

## example

A simple counter that stops at 10

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

const counter = new State(0);

const div = createNode(


current count: {counter}


(c < 10 ? "green" : "red")),
}}
>
{counter.as((c) => (c < 10 ? "keep going" : "stop!"))}


counter.value++}
disabled={counter.as((c) => c === 10)}
>
increment


);

document.body.append(div);
```