File tree Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Expand file tree Collapse file tree 3 files changed +55
-0
lines changed Original file line number Diff line number Diff line change
1
+ # Learn to yo-yo
2
+
3
+ > [ https://youtu.be/MKJHuub6UJI ] ( https://youtu.be/MKJHuub6UJI )
4
+
5
+ * Install [ Node.js] ( https://nodejs.org/ ) .
6
+ * Install dependencies: ` npm install `
7
+ * Then run ` npm start ` and go to http://localhost:9966 in the browser.
Original file line number Diff line number Diff line change
1
+ var yo = require ( 'yo-yo' )
2
+ var css = require ( 'dom-css' )
3
+
4
+ // var element = yo`<div>Grrrr</div>`
5
+ // document.body.appendChild(element)
6
+ //
7
+ // setTimeout(function () {
8
+ // yo.update(element, yo`<h1>Growl</h1>`)
9
+ // }, 1000)
10
+
11
+ function list ( items , onadd ) {
12
+ return yo `<ul>
13
+ ${ items . map ( function ( item ) {
14
+ return yo `<li>${ item } </li>`
15
+ } ) }
16
+ <li>${ button ( onadd ) } </li>
17
+ </ul>`
18
+ }
19
+
20
+ function button ( onclick ) {
21
+ var el = yo `<button onclick=${ onclick } >add bear</button>`
22
+ css ( el , {
23
+ 'border-radius' : 10
24
+ } )
25
+ return el
26
+ }
27
+
28
+ var bears = [ 'Polar' , 'Brown' , 'Grizzly' ]
29
+ var element = list ( bears , function onadd ( ) {
30
+ bears . push ( 'Black' )
31
+ yo . update ( element , list ( bears , onadd ) )
32
+ } )
33
+ document . body . appendChild ( element )
Original file line number Diff line number Diff line change
1
+ {
2
+ "name" : " learn-to-yo-yo" ,
3
+ "version" : " 0.1.0" ,
4
+ "description" : " " ,
5
+ "main" : " index.js" ,
6
+ "scripts" : {
7
+ "start" : " budo index.js" ,
8
+ "test" : " node test.js"
9
+ },
10
+ "author" : " Kyle Robinson Young <kyle@dontkry.com> (http://dontkry.com)" ,
11
+ "license" : " MIT" ,
12
+ "devDependencies" : {
13
+ "budo" : " ^8.3.0"
14
+ }
15
+ }
You can’t perform that action at this time.
0 commit comments