Skip to content

Instantly share code, notes, and snippets.

@pshihn
Created May 14, 2021 00:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pshihn/cd012312eaf6ae4ac16984b9b417efb4 to your computer and use it in GitHub Desktop.
Save pshihn/cd012312eaf6ae4ac16984b9b417efb4 to your computer and use it in GitHub Desktop.
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