-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #24 from mreinstein/2.0
2.0 fixes #23
- Loading branch information
Showing
19 changed files
with
2,859 additions
and
1,181 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
engine-strict=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,5 @@ sudo: false | |
language: node_js | ||
node_js: | ||
- 'node' | ||
- '6' | ||
- '5' | ||
- '4' | ||
- '14' | ||
- '12' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Snabby - Counter Example</title> | ||
<meta name=theme-color content=#303F9F><meta name=viewport content="width=device-width,minimum-scale=1"> | ||
<style> | ||
body { | ||
font-family: monospace; | ||
background-color: whitesmoke; | ||
padding: 10px; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<p> | ||
|
||
</p> | ||
|
||
<script type="module"> | ||
import html from '../snabby.js' | ||
|
||
|
||
function counter (count) { | ||
const view = html` | ||
<div class="main"> | ||
<button @on:click=${sub}>-</button> | ||
<span>${count}</span> | ||
<button @on:click=${add}>+</button> | ||
</div>` | ||
|
||
function add () { | ||
html.update(view, counter(count + 1)) | ||
} | ||
|
||
function sub () { | ||
html.update(view, counter(count - 1)) | ||
} | ||
|
||
return view | ||
} | ||
|
||
|
||
html.update(document.body, counter(0)) | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
<!doctype html> | ||
<html> | ||
<head> | ||
<title>Snabby - Thunk Example</title> | ||
<meta name=theme-color content=#303F9F><meta name=viewport content="width=device-width,minimum-scale=1"> | ||
<style> | ||
body { | ||
font-family: monospace; | ||
background-color: whitesmoke; | ||
padding: 10px; | ||
} | ||
|
||
</style> | ||
</head> | ||
<body> | ||
|
||
<p> | ||
For this example, take a look at the javascript console, and press the random button several times. | ||
You'll notice that when the value that gets chosen matches the previous value, the "ACTUAL UPDATE" console message | ||
doesn't fire. this is because the view hasn't changed, so the thunk doesn't re-evaluate the snabby dom vnode. | ||
</p> | ||
|
||
<script type="module"> | ||
import html from '../snabby.js' | ||
|
||
|
||
function randomInt () { | ||
return Math.ceil(Math.random() * 3) | ||
} | ||
|
||
|
||
function numberView (n) { | ||
console.log('ACTUAL UPDATE:', n) | ||
return html`<span>Number is ${n}</span>` | ||
} | ||
|
||
|
||
function counter (count) { | ||
console.log('outer call:', count) | ||
const view = html` | ||
<div class="main"> | ||
<button @on:click=${sub}>-</button> | ||
<span>${html.thunk('num', numberView, [count])}</span> | ||
<button @on:click=${add}>+</button> | ||
<button @on:click=${rand}>random</button> | ||
</div> | ||
` | ||
|
||
function add () { | ||
html.update(view, counter(count + 1)) | ||
} | ||
|
||
function sub () { | ||
html.update(view, counter(count - 1)) | ||
} | ||
|
||
function rand () { | ||
html.update(view, counter(randomInt())) | ||
} | ||
|
||
return view | ||
} | ||
|
||
|
||
html.update(document.body, counter(0)) | ||
|
||
</script> | ||
|
||
</body> | ||
</html> |
Oops, something went wrong.