UziTech / web-component-abstract

Abstract class for creating web components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

web-component-abstract

Abstract class for creating web components with attributes bound to state.

Install

npm install --save web-component-abstract

Usage

JavaScript:

const Component = require("web-component-abstract");

class Hello extends Component({name: "World"}) {
	styles() {
		return "./style.css";
	}
	render() {
		const element = document.createElement("div");
		element.textContent = `Hello ${this.state.name}`;
		return element;
	}
}
Hello.define("my-hello");

HTML:

<my-hello name="Web Components"></my-hello>

Output:

Hello Web Components

About

Abstract class for creating web components

License:MIT License


Languages

Language:JavaScript 100.0%