Commit a2f33089 authored by Sylvain Le Bon's avatar Sylvain Le Bon

feature: Trigger

parent 83444cf9
...@@ -91,6 +91,7 @@ ...@@ -91,6 +91,7 @@
></sib-form> ></sib-form>
</section> </section>
</div> </div>
<sib-trigger next="detail">Go to detail</sib-trigger>
</main> </main>
</body> </body>
</html> </html>
...@@ -121,5 +121,21 @@ ...@@ -121,5 +121,21 @@
} }
customElements.define('sib-router', SIBRouter); customElements.define('sib-router', SIBRouter);
class SIBTrigger extends HTMLElement {
constructor() {
super();
this.addEventListener('click', event => this.trigger());
}
get next() {
return this.getAttribute('next');
}
trigger() {
if(this.next) window.dispatchEvent(new CustomEvent('navigate', {detail: {route: this.next}}));
}
}
customElements.define('sib-trigger', SIBTrigger);
}()); }());
</script> </script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment