HyperStandard
import { $, h as html, on } from "hstd"
function Component() {
const count = $(0);
return html`
<h1>Count is ${count}</h1>
<button ${{ [on.click]: () => count.$++ }}>
Add more!
</button>
`;
}
document.body.append(...Component());
hstd = HyperStandard is a minimal JavaScript library to build fast, interactive, extensible web interface. Visit live demo.
npm i hstd
import { $, h as html } from "hstd";
Class-model | Bidirecetional binding | Post-processing
import { $, h as html, on, css } from "hstd"
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>
`
}
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>
`
}
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);
});
})
}
hstd is MIT licensed.