refactor folk-space to lit

This commit is contained in:
“chrisshank” 2024-12-10 15:24:32 -08:00
parent 50c07fcf81
commit ebe6c71c08
1 changed files with 44 additions and 49 deletions

View File

@ -1,4 +1,6 @@
import { html, css } from './common/tags';
import { css, PropertyValues } from '@lit/reactive-element';
import { FolkElement } from './common/folk-element';
import { html } from './common/tags';
declare global {
interface HTMLElementTagNameMap {
@ -6,7 +8,10 @@ declare global {
}
}
const styles = css`
export class FolkSpace extends FolkElement {
static tagName = 'folk-space';
static styles = css`
:host {
display: block;
perspective: 1000px;
@ -42,24 +47,14 @@ const styles = css`
.back {
transform: rotateX(90deg);
}
`;
`;
export class FolkSpace extends HTMLElement {
static tagName = 'folk-space';
override firstUpdated(changedProperties: PropertyValues): void {
super.firstUpdated(changedProperties);
static define() {
if (customElements.get(this.tagName)) return;
customElements.define(this.tagName, this);
}
if (!(this.renderRoot instanceof ShadowRoot)) return;
#shadow = this.attachShadow({ mode: 'open' });
constructor() {
super();
this.#shadow.adoptedStyleSheets.push(styles);
this.#shadow.setHTMLUnsafe(html`
this.renderRoot.setHTMLUnsafe(html`
<div class="space">
<div class="face front">
<slot name="front"></slot>