Created
May 14, 2021 00:40
-
-
Save pshihn/cd012312eaf6ae4ac16984b9b417efb4 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 { LitElement, CSSResult, css, property } from 'lit-element'; | |
export abstract class Component extends LitElement { | |
@property({ reflect: true }) | |
public dir: 'ltr' | 'rtl' = 'ltr'; | |
static get styles(): CSSResult { | |
return css` | |
* {box-sizing: border-box;} | |
[hidden] {display: none !important;} | |
.horizontal {display: flex; flex-direction: row;} | |
.vertical {display: flex; flex-direction: column;} | |
.center {align-items: center;} | |
.center-center {justify-content: center; align-items: center;} | |
.spaced {justify-content: space-between;} | |
.flex {flex: 1;} | |
.wrap {flex-wrap: wrap;} | |
`; | |
} | |
connectedCallback(): void { | |
this.dir = document.documentElement.dir === 'rtl' ? 'rtl' : 'ltr'; | |
super.connectedCallback(); | |
} | |
fire(eventName: string, detail: any) { | |
this.dispatchEvent(new CustomEvent(eventName, { | |
composed: true, | |
bubbles: true, | |
detail | |
})); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment