libh

0.0.108 • Public • Published

🐛 libh

Open in StackBlitz NPM Version npm package minimized gzipped size

// get ingredients

import { $, h as html, on } from "libh"


// cook yours

function Component() {

    const count = $(0);

    return html`
        <h1>Count is ${count}</h1>
        <button ${{ [on.click]: () => count.$++ }}>
            Add more!
        </button>
    `;
}


// throw into the DOM

document.body.append(...Component());

Visit live demo.



Install

npm i libh

Download

import { $, h as html } from "https://libh.dev";

Examples

Class-model | Bidirecetional binding | Post-processing

Class-model

import { $, h as html, on, css } from "libh"

const ButtonClass = {
    [css]: {
        color: "white",
        backgroundColor: "blue",
    },
    [on.click]: () => alert("hi")
}

function Main() {

    const count = $(0);

    return html`
        <button ${{ [on.click]: () => count.$++, ...ButtonClass }}>
            I'm styled ${count}!
        </button>
    `
}

Bidirecetional binding

function Linked() {

    const valueHolder = $(0)

    return html`
        <h1>these are linked!</h1>
        <input ${{ value: valueHolder, type: "range" }}>
        <input ${{ value: valueHolder, type: "range" }}>
        <label>value is ${valueHolder}</label>
    `
}

Post-processing

function Canvas() {

    const colorSwitch = $(true);

    return html`
        <canvas ${{ id: "color", [on.click]: () => colorSwitch.switch() }}></canvas>

    `.then(({ color }) => {

        const ctx = color.getContext("2d");
        colorSwitch.into($ => $ ? "red" : "blue").watch($ => {
            ctx.fillStyle = $;
            ctx.fillRect(0, 0, 100, 100);
        });
    })
}

Demo

License

libh is WTFPL licensed.

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
0.0.1085latest

Version History

VersionDownloads (Last 7 Days)Published
0.0.1085
0.0.1071
0.0.1060
0.0.1051
0.0.1040
0.0.1030
0.0.1021
0.0.1010
0.0.1000
0.0.990
0.0.980
0.0.970
0.0.960
0.0.950
0.0.941
0.0.931
0.0.920
0.0.911
0.0.900
0.0.890
0.0.880
0.0.870
0.0.860
0.0.850
0.0.841
0.0.831
0.0.820
0.0.810
0.0.800
0.0.790
0.0.780
0.0.770
0.0.760
0.0.750
0.0.740
0.0.720
0.0.710
0.0.700
0.0.690
0.0.680
0.0.671
0.0.660
0.0.650
0.0.640
0.0.630
0.0.620
0.0.610
0.0.600
0.0.590
0.0.580
0.0.570
0.0.560
0.0.550
0.0.530
0.0.520
0.0.510
0.0.500
0.0.490
0.0.480
0.0.470
0.0.460
0.0.450
0.0.440
0.0.430
0.0.420
0.0.410
0.0.400
0.0.390
0.0.380
0.0.370
0.0.360
0.0.350
0.0.340
0.0.330
0.0.320
0.0.310
0.0.300
0.0.290

Package Sidebar

Install

npm i libh

Homepage

libh.js.org

Weekly Downloads

14

Version

0.0.108

License

WTFPL

Unpacked Size

16.4 kB

Total Files

9

Last publish

Collaborators

  • ihasq