From d86f9cf4e3cff3f12a11363ef8bcbfbc13d7414e Mon Sep 17 00:00:00 2001 From: Dino Reic Date: Mon, 15 Jul 2024 14:34:59 +0200 Subject: [PATCH] copy code in example --- README.md | 66 ++++++++++-------- demo/fez/todo.html | 2 +- demo/fez/todo.js | 4 +- demo/main.css | 43 +++++++++--- dist/fez.js | 6 +- dist/fez.js.map | 6 +- index.html | 162 ++++++++++++++++++++++++++++++++------------- index.html.tpl | 28 ++++++-- package.json | 5 +- src/fez.js | 32 ++++----- 10 files changed, 234 insertions(+), 120 deletions(-) diff --git a/README.md b/README.md index c536b7a..dc1535a 100644 --- a/README.md +++ b/README.md @@ -73,6 +73,12 @@ Fez.globalCss(` ... `) +// internal, get unique ID for a string, poor mans MD5 / SHA1 +Fez.fnv1('some string') + +// get generated css class name, from scss source string +Fez.css(text) + // define custom DOM node name -> ... Fez('foo-bar', class extends FezBase { // set element node name, set as property or method, defaults to DIV @@ -104,28 +110,15 @@ Fez('foo-bar', class extends FezBase { static html = `...` connect(props) { - // internal, get unique ID for a string, poor mans MD5 - const uid = this.klass.fnv1('some string') - // copy attributes from attr hash to root node this.copy('href', 'onclick', 'style') - // internal, check if node is attached - this.isAttached() - - // copy all child nodes from source to target, without target returns tm node - this.slot(someNode, tmpRoot) - const tmpRoot = this.slot(self.root) - // clasic interval, that rune only while node is attached this.setInterval(func, tick) { ... } // get closest form data, as object this.formData() - // get generated css class (uses gobber.js) - const localCssClass = this.css(text) - // mounted DOM node root this.root @@ -143,35 +136,52 @@ Fez('foo-bar', class extends FezBase { // gets value for FORM fields or node innerHTML this.val(selector) - - // gets root childNodes. pass function to loop forEach on selection - this.childNodes(func) + // set value to a node, uses value or innerHTML + this.val(selector, value) // you can publish globaly, and subscribe localy Fez.publish('channel', foo) this.subscribe('channel', (foo) => { ... }) + // gets root childNodes. pass function to loop forEach on selection + this.childNodes(func) + + // check if the this.root node is attached to dom + this.isAttached() + // on every "this.data" props change, auto update view. this.data = this.reactiveStore() // render template and attach result dom to root. uses Idiomorph for DOM morph this.html(` - {{if @list}} -