More accessibility things

This commit is contained in:
James Lyne 2021-05-26 20:09:00 +01:00
parent 364b765dd6
commit cc5b1afb3e
5 changed files with 36 additions and 18 deletions

View File

@ -308,7 +308,7 @@
<strong>LiveAtlas requires JavaScript to work.<br />Please enable it to continue.</strong> <strong>LiveAtlas requires JavaScript to work.<br />Please enable it to continue.</strong>
</noscript> </noscript>
<div id="app"></div> <main id="app"></main>
<script type="module" src="/src/main.ts"></script> <script type="module" src="/src/main.ts"></script>
</body> </body>
</html> </html>

View File

@ -15,24 +15,27 @@
--> -->
<template> <template>
<aside class="sidebar"> <section class="sidebar" role="none">
<header class="sidebar__buttons"> <header class="sidebar__buttons">
<button v-if="mapCount > 1" :class="{'button--maps': true, 'active':currentlyVisible.has('maps')}" <button v-if="mapCount > 1" :class="{'button--maps': true, 'active':currentlyVisible.has('maps')}"
@click="toggleElement('maps')" :title="messageWorlds" :aria-label="messageWorlds"> @click="toggleElement('maps')" :title="messageWorlds"
:aria-label="messageWorlds" :aria-expanded="currentlyVisible.has('maps')">
<SvgIcon name="maps"></SvgIcon> <SvgIcon name="maps"></SvgIcon>
</button> </button>
<button :class="{'button--players': true, 'active': currentlyVisible.has('players')}" <button :class="{'button--players': true, 'active': currentlyVisible.has('players')}"
@click="toggleElement('players')" :title="messagePlayers" :aria-label="messagePlayers"> @click="toggleElement('players')" :title="messagePlayers"
:aria-label="messagePlayers" :aria-expanded="currentlyVisible.has('players')">
<SvgIcon name="players"></SvgIcon> <SvgIcon name="players"></SvgIcon>
</button> </button>
</header> </header>
<div class="sidebar__content" @keydown="handleKeydown"> <div class="sidebar__content" @keydown="handleKeydown">
<ServerList v-if="serverCount > 1" v-show="currentlyVisible.has('maps')"></ServerList> <ServerList v-if="serverCount > 1" v-show="currentlyVisible.has('maps')"></ServerList>
<WorldList v-if="mapCount > 1" v-show="currentlyVisible.has('maps')"></WorldList> <WorldList v-if="mapCount > 1" v-show="currentlyVisible.has('maps')"></WorldList>
<PlayerList v-if="previouslyVisible.has('players')" v-show="currentlyVisible.has('players')"></PlayerList> <PlayerList id="players" v-if="previouslyVisible.has('players')"
v-show="currentlyVisible.has('players')"></PlayerList>
<FollowTarget v-if="following" v-show="followActive" :target="following"></FollowTarget> <FollowTarget v-if="following" v-show="followActive" :target="following"></FollowTarget>
</div> </div>
</aside> </section>
</template> </template>
<script lang="ts"> <script lang="ts">
@ -241,6 +244,7 @@ export default defineComponent({
text-align: left; text-align: left;
display: flex; display: flex;
align-items: center; align-items: center;
width: calc(100% + 3rem);
&:hover, &:focus-visible, &.focus-visible, &:active { &:hover, &:focus-visible, &.focus-visible, &:active {
background-color: transparent; background-color: transparent;

View File

@ -1,13 +1,15 @@
<template> <template>
<section :class="{'sidebar__section': true, 'section--collapsible': true, 'section--collapsed': collapsed}"> <section :class="{'sidebar__section': true, 'section--collapsible': true, 'section--collapsed': collapsed}">
<button :id="`${name}-heading`" type="button" class="section__heading" <h2>
@click.prevent="toggle" :title="title" <button :id="`${name}-heading`" type="button" class="section__heading"
:aria-expanded="!collapsed" :aria-controls="`${name}-content`"> @click.prevent="toggle" :title="title"
<span> :aria-expanded="!collapsed" :aria-controls="`${name}-content`">
<slot name="heading"></slot> <span>
</span> <slot name="heading"></slot>
<SvgIcon name="arrow"></SvgIcon> </span>
</button> <SvgIcon name="arrow"></SvgIcon>
</button>
</h2>
<div :id="`${name}-content`" role="region" :aria-labelledby="`${name}-heading`" :aria-hidden="collapsed"> <div :id="`${name}-content`" role="region" :aria-labelledby="`${name}-heading`" :aria-hidden="collapsed">
<slot></slot> <slot></slot>
</div> </div>

View File

@ -67,11 +67,11 @@ export class ClockControl extends Control {
this._moon.style.transform = 'translate(-150px, -150px)'; this._moon.style.transform = 'translate(-150px, -150px)';
this._sun!.innerHTML = ` this._sun!.innerHTML = `
<svg class="svg-icon"> <svg class="svg-icon" aria-hidden="true">
<use xlink:href="#clock_sun" /> <use xlink:href="#clock_sun" />
</svg>`; </svg>`;
this._moon!.innerHTML = ` this._moon!.innerHTML = `
<svg class="svg-icon"> <svg class="svg-icon" aria-hidden="true">
<use xlink:href="#clock_moon" /> <use xlink:href="#clock_moon" />
</svg>`; </svg>`;
@ -154,7 +154,7 @@ export class ClockControl extends Control {
_setSunIcon(icon: string) { _setSunIcon(icon: string) {
if(this._sun && this._currentSunIcon !== icon) { if(this._sun && this._currentSunIcon !== icon) {
this._sun!.innerHTML = ` this._sun!.innerHTML = `
<svg class="svg-icon"> <svg class="svg-icon" aria-hidden="true">
<use xlink:href="#${icon}" /> <use xlink:href="#${icon}" />
</svg>`; </svg>`;
this._currentSunIcon = icon; this._currentSunIcon = icon;
@ -164,7 +164,7 @@ export class ClockControl extends Control {
_setMoonIcon(icon: string) { _setMoonIcon(icon: string) {
if(this._moon && this._currentMoonIcon !== icon) { if(this._moon && this._currentMoonIcon !== icon) {
this._moon!.innerHTML = ` this._moon!.innerHTML = `
<svg class="svg-icon"> <svg class="svg-icon" aria-hidden="true">
<use xlink:href="#${icon}" /> <use xlink:href="#${icon}" />
</svg>`; </svg>`;
this._currentMoonIcon = icon; this._currentMoonIcon = icon;

View File

@ -54,6 +54,9 @@ export class DynmapLayerControl extends Control.Layers {
// @ts-ignore // @ts-ignore
const element = super.onAdd(map); const element = super.onAdd(map);
this._layersLink!.parentElement!.removeAttribute('aria-haspopup');
this._layersLink!.setAttribute('role', 'button');
this._layersLink!.setAttribute('aria-expanded', 'false');
this._layersLink!.innerHTML = ` this._layersLink!.innerHTML = `
<svg class="svg-icon" aria-hidden="true"> <svg class="svg-icon" aria-hidden="true">
<use xlink:href="#layers" /> <use xlink:href="#layers" />
@ -70,12 +73,21 @@ export class DynmapLayerControl extends Control.Layers {
expand() { expand() {
// @ts-ignore // @ts-ignore
DomUtil.addClass(this._container, 'leaflet-control-layers-expanded'); DomUtil.addClass(this._container, 'leaflet-control-layers-expanded');
this._layersLink!.setAttribute('aria-expanded', 'true');
// @ts-ignore // @ts-ignore
super._checkDisabledLayers(); super._checkDisabledLayers();
return this; return this;
} }
collapse() {
// @ts-ignore
DomUtil.removeClass(this._container, 'leaflet-control-layers-expanded');
this._layersLink!.setAttribute('aria-expanded', 'false');
return this;
}
addOverlayAtPosition(layer: Layer, name: string, position: number): this { addOverlayAtPosition(layer: Layer, name: string, position: number): this {
this._layerPositions.set(layer, position); this._layerPositions.set(layer, position);
return super.addOverlay(layer, name); return super.addOverlay(layer, name);