Last active
August 25, 2023 19:22
-
-
Save claytongulick/e4251c1b27b22c25fb68f31761b0f293 to your computer and use it in GitHub Desktop.
VSCode snippet to create a skeleton Web Component using lit-html for rendering
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"Create lit-html Web Component Skeleton": { | |
"prefix": "webc", | |
"body": [ | |
"import {html, render} from 'lit-html';", | |
"", | |
"export default class ${1:AppComponent} extends HTMLElement {", | |
" constructor() {", | |
" super();", | |
" }", | |
"", | |
" connectedCallback() {", | |
" this.template = () => html`", | |
" ", | |
" `;", | |
" ", | |
" this.init();", | |
" }", | |
"", | |
" async init() {", | |
" this.render();", | |
" }", | |
"", | |
" async render() {", | |
" if(!this.template)", | |
" return;", | |
"", | |
" render(this.template(), this);", | |
" }", | |
"}", | |
"", | |
"customElements.define('${2:app-component}', ${1:AppComponent});" | |
], | |
"description": "Create a blank web component skeleton" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment