-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoticeOverview.ts
More file actions
97 lines (93 loc) · 3.6 KB
/
NoticeOverview.ts
File metadata and controls
97 lines (93 loc) · 3.6 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
import { html, nothing } from "lit";
import { customElement, state } from "lit/decorators.js";
import { Component } from "./Component";
import { Notice } from "../models/Notice";
import { EnumMappings } from "../EnumMappings";
import { Time } from "../Time";
import { UpdatesFeed } from "./UpdatesFeed";
import { Maintenance } from "../models/Maintenance";
@customElement("notice-overview")
export class NoticeOverview extends Component {
@state()
private notice: Notice;
public constructor(notice: Notice) {
super();
this.notice = notice;
}
public override render() {
const start = new Time.DateTime(this.notice.started);
const end = this.notice.ended === null
? null
: new Time.DateTime(this.notice.ended);
const duration = new Time.Duration(this.notice.duration());
return html`
<div class="relative">
<div class="flex items-center justify-between mb-2">
<div>
<div class="flex flex-row-reverse items-center justify-end gap-3">
<a
href="/notices/${this.notice.id}"
class="text-lg font-medium text-white"
>
${this.notice.name}<span class="absolute inset-0"></span>
</a>
<span class="group/indicator relative">
<svg
xmlns="http://www.w3.org/2000/svg"
class="size-5 ${EnumMappings
.SERVICE_STATUS_STYLES[
this.notice.impact
]
.color}"
viewBox="0 0 256 256"
aria-hidden="true"
.innerHTML="${EnumMappings
.SERVICE_STATUS_STYLES[
this.notice.impact
]
.icon}"
>
</svg>
<span
class="absolute top-full left-0 z-50 mt-1 block w-max rounded-lg bg-neutral-800 px-2 py-1 text-sm leading-normal font-medium text-white shadow-md ring-1 ring-white/10 ring-inset not-group-hover/indicator:sr-only lg:-top-1 lg:-left-1 lg:mt-0 lg:-translate-x-full"
>
${EnumMappings
.SERVICE_STATUS_STYLES[
this.notice.impact
]
.label}
</span>
</span>
</div>
${this.notice instanceof Maintenance && end !== null
? html`
<p class="text-sm leading-loose text-neutral-400">
Scheduled for
<time datetime="${start.toISOString()}">${start
.toString()}
</time>
– <time
datetime="${end.toISOString()}"
>${end.getDay().is(start.getDay())
? end.toTimeString()
: end.toString()}
</time>
<span
class="rounded-full bg-white/10 px-2 py-0.5 ring-1 ring-white/10 ring-inset"
><time datetime="${duration.toISOString()}">${duration
.toString()}</time></span>
</p>
`
: nothing}
</div>
<button
class="relative rounded-lg bg-white/5 px-3 py-2 text-sm font-medium text-white ring-1 ring-white/10 outline-offset-2 outline-blue-400 transition-colors select-none ring-inset hover:bg-white/15 focus-visible:outline-2"
>
Subscribe
</button>
</div>
${new UpdatesFeed(this.notice.updates)}
</div>
`;
}
}