Skip to content

Instantly share code, notes, and snippets.

@himerus
Last active April 12, 2022 11:23
Show Gist options
  • Select an option

  • Save himerus/b9062ef8527cd928b7b25f71703f3fa9 to your computer and use it in GitHub Desktop.

Select an option

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.
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