Skip to content
Snippets Groups Projects
Select Git revision
  • 4a73c52d2be5ac3eb82a3dd1c5dc453447b11411
  • main default protected
  • renovate/lock-file-maintenance
  • demo protected
  • person-select-custom
  • dbp-translation-component
  • icon-set-mapping
  • port-i18next-parser
  • remove-sentry
  • favorites-and-recent-files
  • revert-6c632dc6
  • lit2
  • advertisement
  • wc-part
  • automagic
  • publish
  • wip-cleanup
  • demo-file-handling
18 results

dbp-activity-example.js

Blame
  • dbp-activity-example.js 1.02 KiB
    import {html , LitElement} from 'lit-element';
    import {createI18nInstance} from './i18n.js';
    import * as commonUtils from '@dbp-toolkit/common/utils';
    
    const i18n = createI18nInstance();
    
    class ActivityExample extends LitElement {
    
        constructor() {
            super();
            this.lang = i18n.language;
        }
    
        static get properties() {
            return {
                lang: { type: String },
            };
        }
    
        update(changedProperties) {
            changedProperties.forEach((oldValue, propName) => {
                switch (propName) {
                    case "lang":
                        i18n.changeLanguage(this.lang);
                        break;
                }
            });
    
            super.update(changedProperties);
        }
    
        render() {
            return html`
                <h3>${i18n.t('activity-example.hello-world')}</h3>
                <ul>${(Array.from(Array(100).keys())).map(i => html`<li>${i18n.t('activity-example.hello-world') + ' ' + i}</li>`)}</ul>
            `;
        }
    }
    
    commonUtils.defineCustomElement('dbp-activity-example', ActivityExample);