From 26f247d56829afa96897b7807cba21642b1c1d2f Mon Sep 17 00:00:00 2001 From: eavichay Date: Mon, 12 Dec 2016 17:03:21 +0200 Subject: [PATCH] fixing slim-states demo --- example/Components/bg_texture.png | Bin 3076 -> 0 bytes example/Components/button-demo.html | 22 --- example/Components/index.html | 244 ------------------------- example/Components/injection-demo.html | 25 --- example/Components/repeat-demo.html | 20 -- example/Components/repeat-item.html | 20 -- example/Components/slim.js.logo.png | Bin 7627 -> 0 bytes 7 files changed, 331 deletions(-) delete mode 100644 example/Components/bg_texture.png delete mode 100644 example/Components/button-demo.html delete mode 100644 example/Components/index.html delete mode 100644 example/Components/injection-demo.html delete mode 100644 example/Components/repeat-demo.html delete mode 100644 example/Components/repeat-item.html delete mode 100644 example/Components/slim.js.logo.png diff --git a/example/Components/bg_texture.png b/example/Components/bg_texture.png deleted file mode 100644 index f7bd7e8deaf44ff720dbbca0b9f21f001db27f62..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3076 zcmZuzc|6ox8>cK;y4Iv@W6dyTv4lxukI{%M*D}OlW{8>5%*Y_4EFsGz*~*ohglM8D zTVu(REETV%6gQLPTC#^M@2Kvr_rCXhKF{x*^PKPZ+5h+@+Mlr6D|k?li;HV7(%Qm- zvpaIcXb&Ifdrp|DU>YHqgXUPG!8u0)mWlz;2th;&oOV>{D+10r@2DY4fUgj0;87)4TYG>x ziHrs4fpx)9C4?XV05Br^;ouGy$G+1!x1&n_RBA9B0tpQb1&8W@Nn|_(W@u;#foemv zwY4}1ElL=XilJ!{DazlB{AI@iOYtQK1XBY@M8J++j1MV^R1q51hjut8V?mPn;=c(8xvQ3G&4()u57J1^hd zeXYi~AdNUBg`1PH7%J9+BM5CMOj`>E)6&*+fdkQltd1s0L&c^1Jqpth<>C{3h*aG-{JqTWJ~f3z=i!=Alh)fzXJIQ^b_6B z7mg#52^cCOfPlecA*X|}cq7OU?N891Lcs0F0h~HwcKU~a8A1L}_Z@Ep*=g=i&Hgq? zU$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xdM<3KpYbZ97qmHEs(vlx!L*D0fFjg?D|c?;q|_3cwjEg9auvS@Igwsp0>?{W z#5>ozKOt0SpDOep;KD>Ao3tX&yCkRLS z8=@+$Y47@HXPM#b6uqkY`k>~$lFSgN%bBMZbu|>2V_m=$?lrn$6mxj*@4}~J9ty+k zu8?uzJr_+~Z2}1gTk9k4jo$w(dn0`7$%SQeDt_GzNc~WbQ-&s){yslOxh~O_na%=X z-Sp=M>`0&L!fK%L^lrqt4Y#e10=v!{b$0n5uMUaGj}J4p6)&y5yzyz`xtDALW{VOE z*`6AepNNl-f52-iUAo6+@Mhjwa#O<16phqYXH(U)o0v=&dxCe`@<>7ZRfgwoF($$U zq~lC?2hP!|R?dsB3mhq#Zuv0&af>|jYYLYF;I_-jM&HhdlGd|+`NjO?`N+d{sKv zTS6#*x`@L zFAk4xzwE*}`E()YpW> zT7fgJWlvCNd$|ebvK}$oOZJ&cxpGQ!B9Q5snUaD6tB;18@l{Z+DjlHir z1PL+TC3=Pvi64}wQ7lN4O1xxS!$#w_URj+H2t6M+)R%Wj=s_RG<*Ku2onGyD=cSp0 zHUm%CYOzrws!Z$rz~#ndnSGO*X)iAohjp}c?=fJ8f#N!l33YDKlq2pzb@C?$=Ky!6 zSC1)7mfzKV2yxT&9V${FVOE)Q9~tWxv`*kqV-r zb93yzj3|aXMMg2cicvWPiOJKz_@rr#bd$=U75@8;vjliEK6z{Dv>tzc`E8!Ns)J+!^H}uJP@E)? z{$)7hmwvZ9EObtyVyr>+dY9%+Xd6XOM eVl4p~+2*HL8^JWHBs+F~&5@QTESP5A(f - \ No newline at end of file diff --git a/example/Components/index.html b/example/Components/index.html deleted file mode 100644 index 416dc74..0000000 --- a/example/Components/index.html +++ /dev/null @@ -1,244 +0,0 @@ - - - - - slim.js - Productive Web Components Library - - - - - - - - - - - - - - - - - - - -© 2016 Avichay Eyal. All code provided is open source under the MIT License -Fork me on GitHub - - - -
- -

With es6 and slim you could write native web components double-time with no hassle of using external libraries that affect your workflow

-
-

SLIM is your PRODUCTIVE way
for writing NATIVE web components

- -

Featuring

-
    -
  • Lightweight and fast (~1KB minified)
  • -
  • Easy and intuitive data binding across your application
  • -
  • Dependency injection
  • -
  • Text template with data binding done naturally
  • -
  • Repeater with array as data source
  • -
- -
bower install slimjs
-npm install slim-js
- -

Data binding and Text-to-data Binding

todo-task-item.js

document.registerElement( - 'todo-task-item', - class extends SlimBaseElement { - - get updateOnAttributes() { - return ['name', 'done', 'todoid'] - } - - get template() { - return ` - <div id="container"> - <span id="number" bind>[[data.todoId]]</span> - <input type="checkbox" done="[done]"/> - <span id="title" text="[name]" bind>[[data.name]]</span> - <input type="button" value="X"> - </div>` - } - - update() { - super.update() // propogate downstream the DOM - var checkbox = this.find('input[type=checkbox]') - var delButton = this.find('input[value="X"]') - - checkbox.dataItem = this.data - if (this.data.done) { - checkbox.setAttribute('checked', 'checked') - } else { - checkbox.removeAttribute('checked') - } - - checkbox.onchange = () => { - checkbox.dataItem.done = checkbox.checked - } - - delButton.onclick = () => { - checkbox.dataItem.delete() - } - } - - })
- -

Using repeater

todo-task-list.js

document.registerElement( - 'todo-task-list', - class extends SlimBaseElement { - - // @override - get updateOnAttributes() { - return ['model'] - } - - // @override - get template() { - return `<s-repeat source="items"><todo-task-item></todo-task-item></s-repeat>` - } - - // @override abstract - afterRender() { - this.model.addEventListener('change', () => { - this.find('s-repeat').update() - }) - this.find('s-repeat').update() - }}) - - get items() { - return this.model.todos - }
- -

Using injection

Todo.html

<todo-task-list model="{model}"></todo-task-list> -
- -

TodoModel.js

-class TodoModel { - - constructor extends EventDispatcher() { - this.todos = [] - } - - addTask(value) { - this.todos.push( { - name: value, - done: false, - todoId: this.todos.length + 1, - delete: function() { - instance.removeTask(this.todoId) - }}) - - this.dispatchEvent(new Event('change')) - } - - removeTask(taskId) { - this.todos.splice(taskId - 1, 1) - this.todos.forEach( (todo, index) => { - todo.todoId = index + 1 - }) - this.dispatchEvent(new Event('change')) - } - -} - -const singleton = new TodoModel() - -SlimInjector.define('model', () => { return singleton })
- - -
- - - \ No newline at end of file diff --git a/example/Components/injection-demo.html b/example/Components/injection-demo.html deleted file mode 100644 index 5797e37..0000000 --- a/example/Components/injection-demo.html +++ /dev/null @@ -1,25 +0,0 @@ - \ No newline at end of file diff --git a/example/Components/repeat-demo.html b/example/Components/repeat-demo.html deleted file mode 100644 index bd3e585..0000000 --- a/example/Components/repeat-demo.html +++ /dev/null @@ -1,20 +0,0 @@ - \ No newline at end of file diff --git a/example/Components/repeat-item.html b/example/Components/repeat-item.html deleted file mode 100644 index a654399..0000000 --- a/example/Components/repeat-item.html +++ /dev/null @@ -1,20 +0,0 @@ - \ No newline at end of file diff --git a/example/Components/slim.js.logo.png b/example/Components/slim.js.logo.png deleted file mode 100644 index 837031fd7de5a42c1176bf5924e52eb08eddaae7..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 7627 zcmZ{I1yCH_w)ISaK?k?MAQ4rf7z`5wfj1-Xfz$F~jtR_FRi!^sGcsNV(HtM=tqa}ltaWYP?tT9A zaO&H>=LbkQYxs3VRmX4a}Fqak=S8r$sZV@fLDr+8;bU2 z3VIJ|orX?8Zl>G^l$ zV9%L}yhN+_*(rximWC5^LEgJAmV47KAu|GQc`G)KYL^ox?RQg+>DS z3EsrTps2gcr1alWcf%ZmknCMN!D(lGm0dwAy0EZmR}hc=fnXU8${p*3Gr<>>KI%_< zyuoE&@eDSY8_U(<&2t3eT_l2%kq=PQb)f-w!*VZSk#)_rC%Q%qTrId{}7 zn{;+kX|fua!58RSck}SD;)*i5MPggw1gt+0LyU>D_>cf5>k=*KNNo8dMQl6)Qx_}Z zVnh01q04ZfEHDavWGy&&2JWF-=qi0xTay=g zzvu;V@?+TgsrvJWH-~!QDtN_ctH=W4fM5x21$tV@izYlrya;r4Nt;5}*&+a31f0}a$0hs#na}`8-OcuT_Mb`o#?1&JQJuAHr43~ zDWc!fL?9FpR@7EJi_w9Wf;#u5!E1lT-&t3YSjy5eLlP0M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