-
-
Notifications
You must be signed in to change notification settings - Fork 289
Expand file tree
/
Copy pathconnection-indicator.html
More file actions
104 lines (90 loc) · 2.41 KB
/
connection-indicator.html
File metadata and controls
104 lines (90 loc) · 2.41 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
<template id="connection-indicator-template">
<style>
@import "css/style.css";
:host {
position: relative;
}
.status-bar-tooltip {
/* Slightly tweak the tooltip width, so that the “disconnected” text will
break in an optimal way, without creating extra space on the right. */
max-width: 23em;
}
:host(:hover) .status-bar-tooltip {
display: block;
}
.status {
display: flex;
flex-direction: row;
align-items: center;
}
.status-dot {
height: 1rem;
width: 1rem;
margin-right: 0.5rem;
border-radius: 50%;
display: inline-block;
/* Disconnected state */
background-color: var(--brand-red-bright);
}
:host([connected="true"]) .status-dot {
background-color: var(--brand-green-bright);
}
.connected-text,
.label-connected {
display: none;
}
:host([connected="true"]) .connected-text,
:host([connected="true"]) .label-connected {
display: block;
}
.disconnected-text,
.label-disconnected {
display: block;
}
:host([connected="true"]) .disconnected-text,
:host([connected="true"]) .label-disconnected {
display: none;
}
</style>
<div class="status">
<span class="status-dot"></span>
<div>
<span class="label-connected">Connected</span>
<span class="label-disconnected">Disconnected</span>
</div>
</div>
<div class="status-bar-tooltip">
<p class="connected-text">
Your browser is connected to your TinyPilot device.
</p>
<p class="disconnected-text">
Your browser is currently unable to connect to your TinyPilot device over
the network.
</p>
<p>
See “System” > “Networking” > “Status” for more
information.
</p>
</div>
</template>
<script type="module">
(function () {
const template = document.querySelector("#connection-indicator-template");
customElements.define(
"connection-indicator",
class extends HTMLElement {
connectedCallback() {
this.attachShadow({ mode: "open" }).appendChild(
template.content.cloneNode(true)
);
}
get connected() {
return this.getAttribute("connected");
}
set connected(isConnected) {
this.setAttribute("connected", isConnected);
}
}
);
})();
</script>