0.2.3 • Published 11 months ago

@purewc/template v0.2.3

Weekly downloads
-
License
ISC
Repository
github
Last release
11 months ago

npm.io

HTMLElementTemplate

An ultra-light (1.3kb) base class for writing vanilla Web Components

npm.io npm.io npm.io

Overview

Usage

Install

npm i @purewc/template

Import and extend from template

import HTMLElementTemplate from '@purewc/template';

class HTMLSomeCustomElement extends HTMLElementTemplate {
    static CSS = `
:host {
  min-height: 100px;
}

#container {
  background-color: #eee;
}
`;
    static template = `
<div id="container">
</div>
`;

    static observedAttributes = [
        ...
    ];

    static properties = {
        "title": {
            "default": "Hello world",
            updated () {
                // Code to run whenever value has changed
                this.$container.innerHTML = this.title;
            },
        },
    };

    static refs = {
        "$container": `#container`,
    };

    constructor () {
        super();
    }
}

Contributing

See CONTRIBUTING.md

0.2.3

11 months ago

0.2.2

1 year ago

0.2.1

1 year ago

0.2.0

1 year ago

0.1.0

1 year ago