Last active
February 19, 2018 11:52
-
-
Save AshleyGrant/878bf59ffa05a09c6d996b6c41b9674e to your computer and use it in GitHub Desktop.
au wizard element with page element
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
<template> | |
<require from='./wizard'></require> | |
<wizard> | |
<page> | |
<p> | |
Page 1 | |
</p> | |
</page> | |
<page> | |
${names[2]} | |
</page> | |
</wizard> | |
</template> |
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
export class App { | |
names = ['Jane', 'John'] | |
} |
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
<!doctype html> | |
<html> | |
<head> | |
<title>Aurelia</title> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/meyer-reset/2.0/reset.min.css"> | |
<style> | |
body { | |
padding: 20px; | |
} | |
.form-component { | |
display: block; | |
margin-bottom: 20px; | |
} | |
</style> | |
</head> | |
<body aurelia-app> | |
<h1>Loading...</h1> | |
<script src="https://jdanyow.github.io/rjs-bundle/node_modules/requirejs/require.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/config.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/aurelia.js"></script> | |
<script src="https://jdanyow.github.io/rjs-bundle/bundles/babel.js"></script> | |
<script> | |
require(['aurelia-bootstrapper']); | |
</script> | |
</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
<template> | |
<slot></slot> | |
</template> |
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
export class Page { | |
} |
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
<template> | |
<slot></slot> | |
<div> | |
<button disabled.bind="currentPage === 1" click.trigger="currentPage = currentPage - 1"><<</button> | |
<button disabled.bind="currentPage === pages.length - 1" click.trigger="currentPage = currentPage + 1">>></button> | |
</div> | |
</template> |
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
import { processContent, children} from 'aurelia-framework'; | |
@processContent(parsePages) | |
export class Wizard { | |
@children('page') pages; | |
currentPage = 1; | |
attached() { | |
console.log('pages', this.pages); | |
} | |
} | |
function parsePages(compiler, resources, node, instruction) { | |
const pages = node.querySelectorAll('page'); | |
for( let i = 0, numberOfPages = pages.length; i < numberOfPages; i++ ) { | |
const page = pages[i]; | |
page.setAttribute('if.bind', `currentPage === ${i+1}`) | |
} | |
console.log('node', node) | |
console.log('node.innerHTML', node.innerHTML) | |
// debugger; | |
return true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment