-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
486 additions
and
24 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
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,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>FancyPants Example Two</title> | ||
<script type="module"> | ||
|
||
import Component from '../lib/component.js'; | ||
import { tracked } from '../lib/tracking.js'; | ||
|
||
class FooBar extends Component { | ||
foo = tracked(0); | ||
|
||
get bar() { | ||
return `bar-${this.foo}`; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.shadow.querySelector('.go') | ||
.addEventListener('click', () => { this.foo += 1 }); | ||
} | ||
|
||
render() { | ||
this.shadow.querySelector('.foo').value = this.foo; | ||
this.shadow.querySelector('.bar').value = this.bar; | ||
} | ||
|
||
static template = ` | ||
<button class="go">+1</button> | ||
<output class="foo"></output> | ||
<output class="bar"></output> | ||
`; | ||
|
||
} | ||
|
||
FooBar.register(); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
|
||
<h1>FancyPants Example Two</h1> | ||
|
||
<p><foo-bar></foo-bar></p> | ||
<p><foo-bar></foo-bar></p> | ||
|
||
</body> | ||
</html> |
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,49 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>FancyPants Example Three</title> | ||
<script type="module"> | ||
|
||
import Component from '../lib/component.js'; | ||
import { tracked } from '../lib/tracking.js'; | ||
|
||
class FooBar extends Component { | ||
foo = tracked(0); | ||
|
||
get bar() { | ||
return `bar-${this.foo}`; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.shadow.querySelector('.go') | ||
.addEventListener('click', () => { this.foo += 1 }); | ||
} | ||
|
||
render() { | ||
this.shadow.querySelector('.foo').value = this.foo; | ||
this.shadow.querySelector('.bar').value = this.bar; | ||
} | ||
|
||
} | ||
|
||
FooBar.register('#different-id'); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
|
||
<h1>FancyPants Example Three</h1> | ||
|
||
<p><foo-bar></foo-bar></p> | ||
<p><foo-bar></foo-bar></p> | ||
|
||
<template id="different-id"> | ||
<button class="go">+1</button> | ||
<output class="foo"></output> | ||
<output class="bar"></output> | ||
</template> | ||
|
||
</body> | ||
</html> |
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,51 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>FancyPants Example Four</title> | ||
<script type="module"> | ||
|
||
import Component from '../lib/component.js'; | ||
import { tracked, activateTracking } from '../lib/tracking.js'; | ||
|
||
const globalTrackable = activateTracking({ | ||
foo: tracked(0), | ||
}); | ||
|
||
class FooBar extends Component { | ||
|
||
get bar() { | ||
return `bar-${globalTrackable.foo}`; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.shadow.querySelector('.go') | ||
.addEventListener('click', () => { globalTrackable.foo += 1 }); | ||
} | ||
|
||
render() { | ||
this.shadow.querySelector('.foo').value = globalTrackable.foo; | ||
this.shadow.querySelector('.bar').value = this.bar; | ||
} | ||
} | ||
|
||
FooBar.register(); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
|
||
<h1>FancyPants Example Four</h1> | ||
|
||
<p><foo-bar></foo-bar></p> | ||
<p><foo-bar></foo-bar></p> | ||
|
||
<template id="foo-bar"> | ||
<button class="go">+1</button> | ||
<output class="foo"></output> | ||
<output class="bar"></output> | ||
</template> | ||
|
||
</body> | ||
</html> |
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,60 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>FancyPants Example Five</title> | ||
<script type="module"> | ||
|
||
import Component from '../lib/component.js'; | ||
import { tracked, dirtyTag, consumeTag, createTag } from '../lib/tracking.js'; | ||
|
||
const globalTag = createTag(); | ||
let globalValue = 0; | ||
|
||
function updateGlobalValue() { | ||
dirtyTag(globalTag); | ||
globalValue++; | ||
} | ||
|
||
function getGlobalValue() { | ||
consumeTag(globalTag); | ||
return globalValue; | ||
} | ||
|
||
class FooBar extends Component { | ||
|
||
get bar() { | ||
return `bar-${getGlobalValue()}`; | ||
} | ||
|
||
constructor() { | ||
super(); | ||
this.shadow.querySelector('.go') | ||
.addEventListener('click', updateGlobalValue); | ||
} | ||
|
||
render() { | ||
this.shadow.querySelector('.foo').value = getGlobalValue(); | ||
this.shadow.querySelector('.bar').value = this.bar; | ||
} | ||
} | ||
|
||
FooBar.register(); | ||
|
||
</script> | ||
</head> | ||
<body> | ||
|
||
<h1>FancyPants Example Five</h1> | ||
|
||
<p><foo-bar></foo-bar></p> | ||
<p><foo-bar></foo-bar></p> | ||
|
||
<template id="foo-bar"> | ||
<button class="go">+1</button> | ||
<output class="foo"></output> | ||
<output class="bar"></output> | ||
</template> | ||
|
||
</body> | ||
</html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
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 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