No description
Find a file
2025-02-23 19:23:50 +01:00
documentation Document render module 2025-02-17 14:51:58 +01:00
.editorconfig Add basic editorconfig 2024-06-24 12:27:05 +02:00
domProxy.js Add meta-tag domProxy 2024-02-06 22:56:08 +01:00
importmaps.html Add observable to importmap snippet 2025-02-23 19:22:51 +01:00
jsconfig.json Add jsdoc class annotations to skooma module 2024-02-12 13:38:57 +01:00
license.md Update metadata 2023-10-04 10:35:56 +02:00
mini.js Improved case rewriting 2025-02-17 15:13:56 +01:00
observable.js Rename o-value compose method to transform 2025-02-23 19:23:50 +01:00
package.json Update package information 2025-02-18 08:57:03 +01:00
readme.md Simplify readme 2025-02-18 15:42:20 +01:00
ref.js Extract Ref class into separate module 2024-02-29 15:33:26 +01:00
render.js Fix GC bug in reactive elements 2025-02-20 22:59:12 +01:00

Nyooom

import {html} from "nyooom/render"
import {ObservableValue} from "nyooom/observable"

const text = new ObservableValue("Nyooom is cool")
setTimeout(() => {text.value = "Nyooom is awesome!"}, 1e5)

document.body.append(html.div(
    html.h1("Hello, World!"),
    html.p(text, {class: "amazing"}),
    html.button("Show Proof", {click: event => { alert("It's true!") }})
))

Goals

Arrakis teaches the attitude of the knife - chopping off what's incomplete and saying: "Now, it's complete because it's ended here."

— Frank Herbert, Dune

Nyooom aims to offer as much convenienve as possible within the following constraints:

  1. Small, independent modules that can also work on their own
  2. Code should be easy to figure out by someone who doesn't actiely use nyooom
  3. Easy to gradually introduce and remove rather than forcing big re-writes
  4. Flexible, hackable and easy to audit

Importmaps

The included file importmaps.html can be used as a starting point for importing nyooom via importmaps in a minimal environment. Search-and-replace ./ to wherever the library should be loaded from if necessary.

A few more examples:

Create a Button that deletes itself:

document.body.append(
	html.button("Delete Me", {click: event => event.target.remove()})
)

Turn a two-dimensional array into an HTML table:

const table = rows =>
	html.table(html.tbody(rows.map(
		row => html.tr(row.map(
			cell => html.rd(cell, {dataset: {
				content: cell.toLowerCase(),
			}})
		))
	)))

A list that you can add items to

let list, input = ""
document.body.append(html.div([
	list=html.ul(),
	html.input({type: 'text', input: e => input = e.target.value}),
	html.button({click: event => list.append(html.li(input))}, "Add"),
]))

A list that you can also delete items from

const listItem = content => html.li(
	html.span(content), " ", html.a("[remove]", {
		click: event => event.target.closest("li").remove(),
		style: { cursor: 'pointer', color: 'red' },
	})
)
let list, input = ""
document.body.append(html.div([
	list=html.ul(),
	html.input({type: 'text', input: e => input = e.target.value}),
	html.button({click: event => list.append(listItem(input))}, "Add"),
]))