mirror of https://github.com/n2geoff/um
rename um
This commit is contained in:
parent
b728135c77
commit
39a48fa66c
14
README.md
14
README.md
|
@ -1,8 +1,10 @@
|
||||||
# Tagged
|
# Um
|
||||||
|
|
||||||
> Minimal JavaScript UI Builder
|
> Minimal JavaScript UI Builder
|
||||||
|
|
||||||
An experimental composable UI builder that takes ideas from early [hyperapp](https://github.com/jorgebucaran/hyperapp) design, but does not stick to strict Elm Architecture.
|
Um, is an experimental composable UI builder that takes ideas from early [hyperapp](https://github.com/jorgebucaran/hyperapp) design, but does not stick to strict Elm Architecture.
|
||||||
|
|
||||||
|
Um, because you should think about NOT using it.
|
||||||
|
|
||||||
## Features
|
## Features
|
||||||
- No Virtual Dom
|
- No Virtual Dom
|
||||||
|
@ -13,9 +15,9 @@ An experimental composable UI builder that takes ideas from early [hyperapp](htt
|
||||||
|
|
||||||
## Overview
|
## Overview
|
||||||
|
|
||||||
The library only has 2 functions, `app()` and `h()`, and the later is optional.
|
The library only has 2 functions, `app()` and `h()`, and the later is optional.
|
||||||
|
|
||||||
### app({opts})
|
### app({opts})
|
||||||
|
|
||||||
The `app()` is the builder function and takes an `opts` object:
|
The `app()` is the builder function and takes an `opts` object:
|
||||||
|
|
||||||
|
@ -43,7 +45,7 @@ The `h()` is an **optional** hypertext build utility that weighs in around **~25
|
||||||
|
|
||||||
```html
|
```html
|
||||||
<script type="module">
|
<script type="module">
|
||||||
import {app, h} from "./tagged.min.js";
|
import {app, h} from "./um.min.js";
|
||||||
|
|
||||||
const myapp = app({
|
const myapp = app({
|
||||||
state: {name: "[Your Name Here]", job: "Developer"},
|
state: {name: "[Your Name Here]", job: "Developer"},
|
||||||
|
@ -52,7 +54,7 @@ The `h()` is an **optional** hypertext build utility that weighs in around **~25
|
||||||
h("strong", `Greeting from ${state.name}`),
|
h("strong", `Greeting from ${state.name}`),
|
||||||
h("div", `Your local ${state.job}`),
|
h("div", `Your local ${state.job}`),
|
||||||
h("div", {id: "test"}, [
|
h("div", {id: "test"}, [
|
||||||
h("h1", "Hello Tagged"),
|
h("h1", "Um, Hello"),
|
||||||
h("p", 21),
|
h("p", 21),
|
||||||
h("hr")
|
h("hr")
|
||||||
])
|
])
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
{"version":3,"names":["tag","args","el","document","createElement","forEach","arg","includes","appendChild","createTextNode","Array","isArray","append","Object","assign","app","opts","data","check","state","view","actions","mount","value","type","update","querySelector","replaceChildren","input","entries","name","action","dispatch","h"],"sources":["dist/tagged.js"],"mappings":"AAQA,SAASA,IAAIA,OAAQC,MACjB,MAAMC,GAAKC,SAASC,cAAcJ,KAelC,OAVAC,KAAKI,SAASC,MAFc,CAAC,UAAW,SAAU,UAAUC,gBAG3CD,KACTJ,GAAGM,YAAYL,SAASM,eAAeH,MAChCI,MAAMC,QAAQL,KACrBJ,GAAGU,UAAUN,KAEbO,OAAOC,OAAOZ,GAAII,IACtB,IAGGJ,EACX,CAEA,SAASa,IAAIC,MAET,IAAIC,KAAUC,MAAMF,KAAKG,MAAO,CAAC,GAC7BC,KAAUF,MAAMF,KAAKI,MAAM,IAAM,OACjCC,QAAUH,MAAMF,KAAKK,QAAS,CAAC,GAC/BC,MAAUN,KAAKM,OAAS,OAG5B,SAASJ,MAAMK,MAAOC,MAClB,cAAcD,cAAiBC,KAAOD,MAAQC,IAClD,CAgCA,MAAMC,OAAS,KACXtB,SAASuB,cAAcJ,OAAOK,gBAAgBP,KAAKH,KAAMI,SAAS,EAQtE,OAJIL,KAAKI,MAAQE,OArBjB,SAAkBM,MAAOP,SACrBR,OAAOgB,QAAQR,SAAShB,SAAQ,EAAEyB,KAAMC,WACd,mBAAXA,SACPV,QAAQS,MAAQ,IAAI7B,QAEhBY,OAAOC,OAAOG,KAAMc,OAAOH,SAAU3B,OAGrCwB,QAAQ,EAEhB,IAGJA,QACJ,CAQIO,CAASf,KAAMI,SAGZ,CAACF,MAtCOA,QACS,iBAAVA,QACNF,KAAO,IAAIA,QAASE,QAIxBM,SAGOR,MA8Bf,CAEA,MAAMgB,EAAIjC,WAEDe,IAAKkB","ignoreList":[]}
|
|
|
@ -1,3 +1,3 @@
|
||||||
/*! Tagged v:0.2 | MIT LICENSE | https://github.com/n2geoff/tagged */
|
/*! Um v:0.3 | MIT LICENSE | https://github.com/n2geoff/um */
|
||||||
function tag(tag,...args){const el=document.createElement(tag);return args.forEach((arg=>{["boolean","string","number"].includes(typeof arg)?el.appendChild(document.createTextNode(arg)):Array.isArray(arg)?el.append(...arg):Object.assign(el,arg)})),el}function app(opts){let data=check(opts.state,{}),view=check(opts.view,(()=>null)),actions=check(opts.actions,{}),mount=opts.mount||"body";function check(value,type){return typeof value==typeof type?value:type}const update=()=>{document.querySelector(mount).replaceChildren(view(data,actions))};return opts.view&&mount&&function(input,actions){Object.entries(actions).forEach((([name,action])=>{"function"==typeof action&&(actions[name]=(...args)=>{Object.assign(data,action(input,...args)),update()})})),update()}(data,actions),{state:state=>("object"==typeof state&&(data={...data,...state}),update(),data)}}const h=tag;export{app,h};
|
function tag(tag,...args){const el=document.createElement(tag);return args.forEach((arg=>{["boolean","string","number"].includes(typeof arg)?el.appendChild(document.createTextNode(arg)):Array.isArray(arg)?el.append(...arg):Object.assign(el,arg)})),el}function app(opts){let data=check(opts.state,{}),view=check(opts.view,(()=>null)),actions=check(opts.actions,{}),mount=opts.mount||"body";function check(value,type){return typeof value==typeof type?value:type}const update=()=>{document.querySelector(mount).replaceChildren(view(data,actions))};return opts.view&&mount&&function(input,actions){Object.entries(actions).forEach((([name,action])=>{"function"==typeof action&&(actions[name]=(...args)=>{Object.assign(data,action(input,...args)),update()})})),update()}(data,actions),{state:state=>("object"==typeof state&&(data={...data,...state}),update(),data)}}const h=tag;export{app,h};
|
||||||
//# sourceMappingURL=true
|
//# sourceMappingURL=true
|
|
@ -0,0 +1 @@
|
||||||
|
{"version":3,"names":["tag","args","el","document","createElement","forEach","arg","includes","appendChild","createTextNode","Array","isArray","append","Object","assign","app","opts","data","check","state","view","actions","mount","value","type","update","querySelector","replaceChildren","input","entries","name","action","dispatch","h"],"sources":["dist/um.js"],"mappings":"AAQA,SAASA,IAAIA,OAAQC,MACjB,MAAMC,GAAKC,SAASC,cAAcJ,KAelC,OAVAC,KAAKI,SAASC,MAFc,CAAC,UAAW,SAAU,UAAUC,gBAG3CD,KACTJ,GAAGM,YAAYL,SAASM,eAAeH,MAChCI,MAAMC,QAAQL,KACrBJ,GAAGU,UAAUN,KAEbO,OAAOC,OAAOZ,GAAII,IACtB,IAGGJ,EACX,CAEA,SAASa,IAAIC,MAET,IAAIC,KAAUC,MAAMF,KAAKG,MAAO,CAAC,GAC7BC,KAAUF,MAAMF,KAAKI,MAAM,IAAM,OACjCC,QAAUH,MAAMF,KAAKK,QAAS,CAAC,GAC/BC,MAAUN,KAAKM,OAAS,OAG5B,SAASJ,MAAMK,MAAOC,MAClB,cAAcD,cAAiBC,KAAOD,MAAQC,IAClD,CAgCA,MAAMC,OAAS,KACXtB,SAASuB,cAAcJ,OAAOK,gBAAgBP,KAAKH,KAAMI,SAAS,EAQtE,OAJIL,KAAKI,MAAQE,OArBjB,SAAkBM,MAAOP,SACrBR,OAAOgB,QAAQR,SAAShB,SAAQ,EAAEyB,KAAMC,WACd,mBAAXA,SACPV,QAAQS,MAAQ,IAAI7B,QAEhBY,OAAOC,OAAOG,KAAMc,OAAOH,SAAU3B,OAGrCwB,QAAQ,EAEhB,IAGJA,QACJ,CAQIO,CAASf,KAAMI,SAGZ,CAACF,MAtCOA,QACS,iBAAVA,QACNF,KAAO,IAAIA,QAASE,QAIxBM,SAGOR,MA8Bf,CAEA,MAAMgB,EAAIjC,WAEDe,IAAKkB","ignoreList":[]}
|
4
makefile
4
makefile
|
@ -1,7 +1,7 @@
|
||||||
build:
|
build:
|
||||||
bunx rollup src/index.js --file dist/tagged.js --format esm
|
bunx rollup src/index.js --file dist/um.js --format esm
|
||||||
|
|
||||||
minify:
|
minify:
|
||||||
bunx terser dist/tagged.js -c -o dist/tagged.min.js --source-map url
|
bunx terser dist/um.js -c -o dist/um.min.js --source-map url
|
||||||
|
|
||||||
all: build minify
|
all: build minify
|
||||||
|
|
Loading…
Reference in New Issue