Minimal JavaScript UI Library
Go to file
Geoff Doty 6870e74986 jsdoc tweak 2024-05-22 12:45:20 -04:00
dist rename um 2024-05-05 21:22:15 -04:00
src jsdoc tweak 2024-05-22 12:45:20 -04:00
test todo example as test 2024-05-05 15:05:08 -04:00
.gitignore first pass 2024-05-04 20:34:27 -04:00
LICENSE Initial commit 2024-05-04 20:31:29 -04:00
README.md doc tweaks 2024-05-22 12:34:59 -04:00
jsr.json slow types?! 2024-05-22 12:17:29 -04:00
makefile rename um 2024-05-05 21:22:15 -04:00

README.md

Um

Minimal JavaScript UI Builder

Um, is an experimental composable UI builder that takes ideas from early hyperapp design, but does not stick to strict Elm Architecture.

Um, because you should think about, um, NOT using it.

Features

  • No Virtual Dom
  • No Build System
  • No Over Engineering
  • ~1kb minified
  • Totally INEFFICIENT rendering (at scale)

Overview

Um only has 2 exported functions, app() and h(), and the later is optional.

app({opts})

The app() is the builder function and takes an opts object:

Input:

Property Default Description
state {} initial data state
actions {} function object passed to view
view (state, actions) => null function that takes state and actions and returns valid dom
mount body valid query selector as mounting point

Output:

WARNING: May change in future

Property Description
state([data]) state function to get or update internal data

h(tag, [...args])

The h() is an optional hypertext build utility that weighs in around ~250b and is provided as a way to build out your view DOM, but you can build your view using any method you like as long as it returns valid DOM.

Example

    <script type="module">
        import {app, h} from "./um.min.js";

        const myapp = app({
            state: {name: "[Your Name Here]", job: "Developer"},
            view(state, actions) {
                return h("main", [
                    h("strong", `Greeting from ${state.name}`),
                    h("div", `Your local ${state.job}`),
                    h("div", {id: "test"}, [
                        h("h1", "Um, Hello"),
                        h("p", 21),
                        h("hr")
                    ])
                ]);
            }
        });
    </script>

Notes

WORK-IN-PROGRESS

TODO

  • Remove State Helper or make better