Skip to content

Instantly share code, notes, and snippets.

@claytongulick
Last active August 25, 2023 19:22
Show Gist options
  • Save claytongulick/e4251c1b27b22c25fb68f31761b0f293 to your computer and use it in GitHub Desktop.
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
{
"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