Skip to content

Commit 45a1f8a

Browse files
authored
Improved accessibility (#22)
2 parents 069ff6e + fafce68 commit 45a1f8a

5 files changed

Lines changed: 56 additions & 26 deletions

File tree

src/components/AppRoot.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,23 @@ export class AppRoot extends Component {
6666
}
6767

6868
private setupRouter() {
69+
let initial = true;
6970
this.router
7071
.on("/", () => {
7172
this.home = true;
7273
this.page = new HomePage(this.api, this.services);
7374
})
75+
.on("*", () => {
76+
this.router.navigate("/");
77+
})
78+
.hooks({
79+
after: () => {
80+
if (!initial) {
81+
this.page.focus();
82+
}
83+
initial = false;
84+
},
85+
})
7486
.resolve();
7587
}
7688

src/components/ServiceDayTooltip.ts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ export class ServiceDayTooltip extends Component {
7676
<div
7777
class="grid grid-cols-3 items-center border-b border-white/10 px-3 py-2 leading-none"
7878
>
79-
<span class="text-xs text-neutral-500">
79+
<span class="text-xs text-neutral-500" aria-hidden="true">
8080
<time datetime="${days(30)}" class="sm:hidden">30 days ago</time>
8181
<time datetime="${days(
8282
60,
@@ -95,9 +95,10 @@ export class ServiceDayTooltip extends Component {
9595
day: "numeric",
9696
year: "numeric",
9797
})}</time>
98-
<time datetime="${days(
99-
0,
100-
)}" class="text-right text-xs text-neutral-500"
98+
<time
99+
datetime="${days(0)}"
100+
aria-hidden="true"
101+
class="text-right text-xs text-neutral-500"
101102
>Today</time>
102103
</div>
103104
${this.notices.length > 0
@@ -124,21 +125,22 @@ export class ServiceDayTooltip extends Component {
124125
>${style.label}</span>
125126
</div>
126127
<a
127-
href="/notices/${n
128-
.id}"
128+
href="/notices/${n.id}"
129129
class="font-medium text-white focus-visible:outline-none"
130-
>${n
131-
.name}<span
132-
class="absolute inset-0"
133-
></span></a>
130+
>
131+
${n.name}
132+
<span class="absolute inset-0"></span>
133+
</a>
134134
135135
<div class="mx-2 flex-1 border-t border-white/10"></div>
136136
<p class="text-sm text-neutral-400">${n.ended === null ||
137-
n.started.getTime() > now.getTime()
137+
n.started.getTime() > now.getTime() ||
138+
n.ended.getTime() > now.getTime()
138139
? ServiceDayTooltip.STATUS_NAMES[n.status]
139140
: html`
140-
Resolved after <time datetime="${duration
141-
.iso}">${duration.human}</time>
141+
Resolved after <time datetime="${duration.iso}">
142+
${duration.human}
143+
</time>
142144
`}</p>
143145
</li>
144146
`;

src/components/ServiceRow.ts

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -210,19 +210,20 @@ export class ServiceRow extends Component {
210210
</div>
211211
${this.service.description === null ? nothing : html`
212212
<div class="group/description relative">
213-
<svg
214-
xmlns="http://www.w3.org/2000/svg"
215-
class="size-4 fill-neutral-400"
216-
viewBox="0 0 256 256"
217-
aria-hidden="true"
218-
>
219-
<path
220-
d="M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"
213+
<button aria-hidden="true" class="focus:outline-none">
214+
<svg
215+
xmlns="http://www.w3.org/2000/svg"
216+
class="size-4 fill-neutral-400"
217+
viewBox="0 0 256 256"
221218
>
222-
</path>
223-
</svg>
219+
<path
220+
d="M108,84a16,16,0,1,1,16,16A16,16,0,0,1,108,84Zm128,44A108,108,0,1,1,128,20,108.12,108.12,0,0,1,236,128Zm-24,0a84,84,0,1,0-84,84A84.09,84.09,0,0,0,212,128Zm-72,36.68V132a20,20,0,0,0-20-20,12,12,0,0,0-4,23.32V168a20,20,0,0,0,20,20,12,12,0,0,0,4-23.32Z"
221+
>
222+
</path>
223+
</svg>
224+
</button>
224225
<div
225-
class="prose prose-neutral prose-invert prose-sm top-full left-0 absolute z-50 block w-max rounded-lg bg-neutral-800 px-2 py-1 text-white font-medium shadow-md ring-1 ring-white/10 ring-inset not-group-hover/description:sr-only lg:-top-2 lg:left-full lg:mt-0 lg:translate-x-1 max-w-sm"
226+
class="prose prose-neutral prose-invert prose-sm top-full left-0 absolute z-50 block w-max rounded-lg bg-neutral-800 px-2 py-1 text-white font-medium shadow-md ring-1 ring-white/10 ring-inset not-group-hover/description:not-group-focus-within/description:sr-only lg:-top-2 lg:left-full lg:mt-0 lg:translate-x-1 max-w-sm"
226227
>
227228
${unsafeHTML(
228229
ServiceRow.MD.render(this.service.description),

src/components/StatusOverview.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { html } from "lit";
1+
import { html, nothing } from "lit";
22
import { customElement, property, state } from "lit/decorators.js";
33
import { Component } from "./Component";
44
import { MainStatus } from "../models/MainStatus";
@@ -169,9 +169,13 @@ export class StatusOverview extends Component {
169169
const status = StatusOverview.parseMainStatus(this.mainStatus);
170170
const style = StatusOverview.STYLES[status];
171171
const message = typeof style.message === "function"
172-
? (this.resolvedService ? style.message(this.resolvedService) : "")
172+
? (this.resolvedService ? style.message(this.resolvedService) : null)
173173
: style.message;
174174

175+
if (message === null) {
176+
return nothing;
177+
}
178+
175179
return html`
176180
<div class="flex items-center justify-center gap-2 p-6 md:px-8 md:py-10">
177181
<div class="p-2 ${style.bg} rounded-full ring-1 ring-inset">

src/components/pages/Page.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,15 @@
11
import { Component } from "../Component";
22

33
export abstract class Page extends Component {
4+
public override connectedCallback() {
5+
super.connectedCallback();
6+
this.tabIndex = -1;
7+
this.classList.add("focus:outline-none");
8+
}
9+
10+
public focus() {
11+
this.updateComplete.then(() => {
12+
super.focus();
13+
});
14+
}
415
}

0 commit comments

Comments
 (0)