blob: cf168fd80b8d6298bd99a9932415ffa91c00fbea [file] [log] [blame]
Sean McCullough71941bd2025-04-18 13:31:48 -07001import { css, html, LitElement } from "lit";
2import { customElement, property } from "lit/decorators.js";
Sean McCullough86b56862025-04-18 13:04:03 -07003
Sean McCullough71941bd2025-04-18 13:31:48 -07004@customElement("sketch-network-status")
Sean McCullough86b56862025-04-18 13:04:03 -07005export class SketchNetworkStatus extends LitElement {
Sean McCullough86b56862025-04-18 13:04:03 -07006 @property()
7 connection: string;
Sean McCulloughb29f8912025-04-20 15:39:11 -07008
Sean McCullough86b56862025-04-18 13:04:03 -07009 @property()
Sean McCullough86b56862025-04-18 13:04:03 -070010 error: string;
Sean McCullough71941bd2025-04-18 13:31:48 -070011
Sean McCullough86b56862025-04-18 13:04:03 -070012 // See https://lit.dev/docs/components/styles/ for how lit-element handles CSS.
13 // Note that these styles only apply to the scope of this web component's
14 // shadow DOM node, so they won't leak out or collide with CSS declared in
15 // other components or the containing web page (...unless you want it to do that).
16
17 static styles = css`
Sean McCullough71941bd2025-04-18 13:31:48 -070018 .status-container {
19 display: flex;
20 align-items: center;
21 }
Sean McCullough86b56862025-04-18 13:04:03 -070022
Sean McCullough71941bd2025-04-18 13:31:48 -070023 .status-text {
24 font-size: 11px;
25 color: #666;
26 }
27 `;
Sean McCullough86b56862025-04-18 13:04:03 -070028
29 constructor() {
30 super();
31 }
32
33 // See https://lit.dev/docs/components/lifecycle/
34 connectedCallback() {
35 super.connectedCallback();
36 }
37
38 // See https://lit.dev/docs/components/lifecycle/
39 disconnectedCallback() {
Sean McCullough71941bd2025-04-18 13:31:48 -070040 super.disconnectedCallback();
Sean McCullough86b56862025-04-18 13:04:03 -070041 }
42
Sean McCullough86b56862025-04-18 13:04:03 -070043 render() {
Philip Zeyligerbce3a132025-04-30 22:03:39 +000044 // Only render if there's an error to display
45 if (!this.error) {
46 return html``;
47 }
48
Sean McCullough86b56862025-04-18 13:04:03 -070049 return html`
Sean McCullough71941bd2025-04-18 13:31:48 -070050 <div class="status-container">
Philip Zeyligerbce3a132025-04-30 22:03:39 +000051 <span id="statusText" class="status-text">${this.error}</span>
Sean McCullough71941bd2025-04-18 13:31:48 -070052 </div>
Sean McCullough86b56862025-04-18 13:04:03 -070053 `;
54 }
55}
56
57declare global {
58 interface HTMLElementTagNameMap {
59 "sketch-network-status": SketchNetworkStatus;
60 }
Sean McCullough71941bd2025-04-18 13:31:48 -070061}