From be6296492bfb686a1c063752bcf576921ed02d31 Mon Sep 17 00:00:00 2001 From: Christoph Reiter <reiter.christoph@gmail.com> Date: Mon, 7 Oct 2019 12:04:34 +0200 Subject: [PATCH] Move the demo example code into the demo component --- packages/language-select/assets/index.html | 11 +------- .../src/vpu-language-select-demo.js | 26 ++++++++++++++++++- .../src/vpu-language-select.js | 1 + 3 files changed, 27 insertions(+), 11 deletions(-) diff --git a/packages/language-select/assets/index.html b/packages/language-select/assets/index.html index 3c2b6d66..b993bba4 100644 --- a/packages/language-select/assets/index.html +++ b/packages/language-select/assets/index.html @@ -11,15 +11,6 @@ </head> <body> - Select 1: <vpu-language-select></vpu-language-select> - <br> - <br> - Select 2: <vpu-language-select></vpu-language-select> - <br> - <br> - Current language 1: <vpu-language-select-demo></vpu-language-select-demo> - <br> - <br> - Current language 2: <vpu-language-select-demo></vpu-language-select-demo> + <vpu-language-select-demo></vpu-language-select-demo> </body> </html> diff --git a/packages/language-select/src/vpu-language-select-demo.js b/packages/language-select/src/vpu-language-select-demo.js index d5d7ea76..b6368212 100644 --- a/packages/language-select/src/vpu-language-select-demo.js +++ b/packages/language-select/src/vpu-language-select-demo.js @@ -2,7 +2,7 @@ import {html, LitElement} from 'lit-element'; import './vpu-language-select.js'; import * as commonUtils from 'vpu-common/utils'; -class LanguageSelectDemo extends LitElement { +class LanguageSelectDisplay extends LitElement { constructor() { super(); @@ -35,4 +35,28 @@ class LanguageSelectDemo extends LitElement { } } +commonUtils.defineCustomElement('vpu-language-select-display', LanguageSelectDisplay); + +class LanguageSelectDemo extends LitElement { + + constructor() { + super(); + } + + render() { + return html` + Select 1: <vpu-language-select></vpu-language-select> + <br> + <br> + Select 2: <vpu-language-select></vpu-language-select> + <br> + <br> + Current language 1: <vpu-language-select-display></vpu-language-select-display> + <br> + <br> + Current language 2: <vpu-language-select-display></vpu-language-select-display> + `; + } +} + commonUtils.defineCustomElement('vpu-language-select-demo', LanguageSelectDemo); diff --git a/packages/language-select/src/vpu-language-select.js b/packages/language-select/src/vpu-language-select.js index d17959c9..16894aab 100644 --- a/packages/language-select/src/vpu-language-select.js +++ b/packages/language-select/src/vpu-language-select.js @@ -55,6 +55,7 @@ class LanguageSelect extends LitElement { if (oldValue !== value) { const event = new CustomEvent("vpu-language-changed", { bubbles: true, + composed: true, detail: {'lang': value} }); this.dispatchEvent(event); -- GitLab