Skip to content

Commit db8e10c

Browse files
committed
Improve accessibility
1 parent a56aa37 commit db8e10c

File tree

4 files changed

+35
-16
lines changed

4 files changed

+35
-16
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,7 @@ Interaktiver Kalender, der für jeden Tag den Anteil der Bevölkerung angibt, de
55

66
| https://eltos.github.io/holidense |
77
| --------------------------------- |
8+
9+
The tool uses
10+
holiday data from [OpenHolidays API](https://github.com/openpotato/openholidaysapi.data)
11+
and population data from [Eurostat](https://doi.org/10.2908/DEMO_R_GIND3).

app.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -129,9 +129,12 @@ function showTooltip(e, tooltip) {
129129
if (e.pageY + 20 < window.innerHeight - tooltipElement.getBoundingClientRect().height) {
130130
tooltipElement.style.top = e.pageY + 10 + "px";
131131
tooltipElement.style.bottom = '';
132-
} else {
132+
} else if (e.pageY - 20 > tooltipElement.getBoundingClientRect().height) {
133133
tooltipElement.style.top = '';
134134
tooltipElement.style.bottom = window.innerHeight - e.pageY + 10 + "px";
135+
} else {
136+
tooltipElement.style.top = 10 + "px";
137+
tooltipElement.style.bottom = '';
135138
}
136139
tooltipElement.style.opacity = 0.95;
137140
}
@@ -165,6 +168,7 @@ function registerTooptip(element, tooltip) {
165168
function populateYearSelect() {
166169
const now = new Date();
167170
const currentYear = now.getFullYear();
171+
yearSelect.childNodes.forEach(n => n.remove());
168172
for (let y = currentYear - 1; y <= currentYear + 2; y++) {
169173
const optCal = document.createElement("option");
170174
optCal.value = `${y}-01~${y}-12`;
@@ -192,27 +196,28 @@ function populateYearSelect() {
192196
* @return {void}
193197
*/
194198
function renderCountrySelection() {
199+
controls.querySelectorAll(".placeholder").forEach(c => c.remove())
195200
countries.forEach((code) => {
196201
const flag = code.toUpperCase().replace(/./g,
197202
char => String.fromCodePoint(127397 + char.charCodeAt()));
198-
const div = document.createElement("div");
199-
div.className = "country-item";
203+
const button = document.createElement("button");
204+
button.className = "country-item";
200205
if (selectedCountries.includes(code)) {
201-
div.className += " active";
206+
button.className += " active";
202207
}
203-
div.dataset.code = code;
204-
div.innerHTML = `<span>${flag}</span> <span>${formatCountryName(code)}</span>`;
205-
div.addEventListener("click", async () => {
208+
button.dataset.code = code;
209+
button.innerHTML = `<span>${flag}</span> <span>${formatCountryName(code)}</span>`;
210+
button.addEventListener("click", async () => {
206211
if (selectedCountries.includes(code)) {
207212
selectedCountries = selectedCountries.filter((x) => x !== code);
208-
div.classList.remove("active");
213+
button.classList.remove("active");
209214
} else {
210215
selectedCountries.push(code);
211-
div.classList.add("active");
216+
button.classList.add("active");
212217
}
213218
await updateCalendar();
214219
});
215-
controls.appendChild(div);
220+
controls.appendChild(button);
216221
});
217222
}
218223

index.html

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,19 +18,25 @@ <h1 data-i18n="title" onclick="document.location='.'">Holidense: Feriendichte Ka
1818
</p>
1919
<div class="option-icons">
2020
<button class="option-icon" id="languageSelector" title="Toggle language EN/DE &#013;Sprache wechseln DE/EN">🌐</button>
21-
<button class="option-icon" id="shareLink">🔗</button>
21+
<button class="option-icon" id="shareLink" title="Persistenter Link">🔗</button>
2222
</div>
2323
</header>
2424

2525
<div id="countryMap"></div>
2626

2727
<section id="controls">
28-
<select id="yearSelect"></select>
28+
<select id="yearSelect" aria-label="Jahr Auswahl"><option value="" selected>Jahr auswählen...</option></select>
29+
<button class="country-item placeholder">Deutschland</button>
30+
<button class="country-item placeholder">Österreich</button>
31+
<button class="country-item placeholder">Schweiz</button>
32+
<button class="country-item placeholder">Italien</button>
33+
<button class="country-item placeholder">Frankreich</button>
34+
<button class="country-item placeholder">Belgien</button>
35+
<button class="country-item placeholder">Niederlande</button>
2936
</section>
3037

31-
<section id="errorbar"></section>
32-
<section id="infobar"></section>
33-
</section>
38+
<section id="errorbar" role="alert"></section>
39+
<section id="infobar" role="alert">Daten werden geladen...</section>
3440
<main id="calendar">
3541
Lade Daten...
3642
</main>

styles.css

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ a:hover {
8383
}
8484

8585
#yearSelect {
86+
font-family: system-ui, Arial, sans-serif;
8687
font-size: 1rem;
8788
border: 1px solid #ccc;
8889
border-radius: 0.5rem;
@@ -91,6 +92,8 @@ a:hover {
9192
}
9293

9394
.country-item {
95+
font-family: system-ui, Arial, sans-serif;
96+
font-size: 1rem;
9497
display: flex;
9598
align-items: center;
9699
gap: 0.4rem;
@@ -99,7 +102,7 @@ a:hover {
99102
border-radius: 0.5rem;
100103
background-color: #f0f0f0;
101104
opacity: 0.7;
102-
height: 1.3rem;
105+
height: 2.2rem;
103106
padding: 0.4rem 0.6rem;
104107
transition: background-color 0.2s, opacity 0.2s;
105108
user-select: none;
@@ -189,6 +192,7 @@ td[data-code]:hover {
189192

190193
.tooltip {
191194
position: absolute;
195+
overflow: scroll;
192196
background: #333;
193197
color: #fff;
194198
padding: 0.4rem 0.6rem;

0 commit comments

Comments
 (0)