Last active
April 12, 2022 11:23
-
-
Save himerus/b9062ef8527cd928b7b25f71703f3fa9 to your computer and use it in GitHub Desktop.
Sample code snippet for an extremely simple Lit2 Web Component with a hard coded render function.
This file contains hidden or 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
| import { html, css, CSSResultGroup, TemplateResult } from 'lit'; | |
| import { OutlineElement } from '../outline-element/outline-element'; | |
| import { customElement } from "lit/decorators.js"; | |
| /** | |
| * The Outline Widget Component | |
| * | |
| * @element OutlineWidget | |
| * @extends OutlineElement | |
| */ | |
| @customElement("outline-widget") | |
| export class OutlineWidget extends OutlineElement { | |
| static styles: CSSResultGroup = css` | |
| p { | |
| color: red; font-weight: bold; | |
| animation: blink-animation 1s steps(5, start) infinite; | |
| } | |
| @keyframes blink-animation { to { visibility: hidden; } } | |
| `; | |
| render(): TemplateResult { | |
| return html` | |
| <div> | |
| <p>Simple "hard coded" element inside the component ShadowDOM.</p> | |
| </div>` | |
| } | |
| } | |
| declare global { | |
| interface HTMLElementTagNameMap { | |
| "outline-widget": OutlineWidget; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment