Skip to content
Snippets Groups Projects
dbp-file-handling-demo-activity.js 2 KiB
Newer Older
import {css, html} from 'lit';
import {ScopedElementsMixin} from '@open-wc/scoped-elements';
import {FileSourceDemo} from '@dbp-toolkit/file-handling/src/demo';
import * as commonStyles from '@dbp-toolkit/common/styles';
Steinwender, Tamara's avatar
Steinwender, Tamara committed
import * as commonUtils from '@dbp-toolkit/common/utils';
import {unsafeHTML} from 'lit/directives/unsafe-html.js';
import readme from '@dbp-toolkit/file-handling/README.md';
Reiter, Christoph's avatar
Reiter, Christoph committed
import * as demoStyles from './styles';
import {AdapterLitElement} from '@dbp-toolkit/provider/src/adapter-lit-element';
Steinwender, Tamara's avatar
Steinwender, Tamara committed
export class DbpFileHandlingDemoActivity extends ScopedElementsMixin(AdapterLitElement) {
    constructor() {
        super();
        this.lang = 'en';
        this.entryPointUrl = '';
    }

    static get scopedElements() {
        return {
Steinwender, Tamara's avatar
Steinwender, Tamara committed
            'dbp-file-source-demo': FileSourceDemo,
        };
    }

    static get properties() {
        return {
            ...super.properties,
Reiter, Christoph's avatar
Reiter, Christoph committed
            lang: {type: String},
            entryPointUrl: {type: String, attribute: 'entry-point-url'},
    }

    connectedCallback() {
        super.connectedCallback();

Reiter, Christoph's avatar
Reiter, Christoph committed
        this.updateComplete.then(() => {});
    }

    static get styles() {
        // language=css
        return [
            commonStyles.getThemeCSS(),
            commonStyles.getGeneralCSS(),
            demoStyles.getDemoCSS(),
            css`
Reiter, Christoph's avatar
Reiter, Christoph committed
                h1.title {
                    margin-bottom: 1em;
                }
                div.container {
                    margin-bottom: 1.5em;
                }
Reiter, Christoph's avatar
Reiter, Christoph committed
                #demo {
                    display: block;
                    padding-top: 50px;
                }
            `,
        ];
    }

    render() {
        return html`
Reiter, Christoph's avatar
Reiter, Christoph committed
            ${unsafeHTML(readme)}
Steinwender, Tamara's avatar
Steinwender, Tamara committed
            <dbp-file-source-demo
Reiter, Christoph's avatar
Reiter, Christoph committed
                id="demo"
                lang="${this.lang}"
Steinwender, Tamara's avatar
Steinwender, Tamara committed
                entry-point-url="${this.entryPointUrl}"></dbp-file-source-demo>
        `;
    }
}

commonUtils.defineCustomElement('dbp-file-handling-demo-activity', DbpFileHandlingDemoActivity);