Created
May 8, 2023 03:54
-
-
Save Westbrook/fca1faa0f2dad202903c4c1f5f7c6222 to your computer and use it in GitHub Desktop.
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
import { LitComponent } from "./LitComponent.js"; | |
export const TAG_NAME = "hz-lit-component"; | |
if (!customElements.get(TAG_NAME)) { | |
customElements.define(TAG_NAME, LitComponent); | |
} | |
declare global { | |
interface HTMLElementTagNameMap { | |
[TAG_NAME]: LitComponent; | |
} | |
} |
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
<!DOCTYPE html> | |
<head> | |
<script type="module" src="./hz-lit-component.js"></script> | |
</head> | |
<body> | |
<button id="remove">Remove</button> | |
<hz-lit-component></hz-lit-component> | |
<script> | |
document.remove.addEventListener('click', ({target}) => target.nextElementSibling.remove()); | |
</script> | |
</body> |
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
import { css } from "lit"; | |
export const style = css` | |
:host { | |
border: 1px solid black; | |
display: block; | |
width: 100%; | |
padding: 10px; | |
} | |
`; |
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
import { html, LitElement } from "lit"; | |
import { style } from "./LitComponent.css.js"; | |
import type { TemplateResult } from "lit"; | |
export class LitComponent extends LitElement { | |
public static readonly styles = style; | |
public render(): TemplateResult { | |
return html` <p>This is a simple component using LitCompoent</p> `; | |
} | |
} |
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
{ | |
"dependencies": { | |
"lit": "^2.0.0", | |
"@lit/reactive-element": "^1.0.0", | |
"lit-element": "^3.0.0", | |
"lit-html": "^2.0.0" | |
} | |
} |
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
{ | |
"files": { | |
"LitComponent.ts": { | |
"position": 0 | |
}, | |
"index.html": { | |
"position": 1 | |
}, | |
"package.json": { | |
"position": 2, | |
"hidden": true | |
}, | |
"LitComponent.css.ts": { | |
"position": 3 | |
}, | |
"hz-lit-component.ts": { | |
"position": 4 | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment