Skip to content

Commit 0537ff2

Browse files
committed
fix: added skip to main content button
1 parent de2b4e5 commit 0537ff2

File tree

6 files changed

+34
-4
lines changed

6 files changed

+34
-4
lines changed

components/skipToNavButton.vue

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<template>
2+
<button
3+
class="fixed p-4 text-gray-800 bg-gray-300 border border-gray-500 rounded-md w-52 z-11 top-6 left-6 dark:bg-gray-700 dark:text-gray-50"
4+
@click="focusOnMain"
5+
>
6+
Skip to main content
7+
</button>
8+
</template>
9+
<script>
10+
export default {
11+
methods: {
12+
focusOnMain() {
13+
document.getElementsByTagName('main')[0].focus()
14+
},
15+
},
16+
}
17+
</script>
18+
19+
<style scoped lang="scss">
20+
button {
21+
opacity: 0;
22+
pointer-events: none;
23+
}
24+
button:focus {
25+
opacity: 1;
26+
pointer-events: all;
27+
}
28+
</style>

layouts/main.vue

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
22
<div class="page-root">
3+
<SkipToNavButton />
34
<Toast />
45
<Nuxt />
56
<Footer />

pages/diff.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
</button>
4949
</template>
5050
</Navbar>
51-
<main>
51+
<main class="outline-none" tabindex="0">
5252
<div
5353
class="flex items-stretch w-full gap-4 font-mono text-gray-800 dark:text-gray-50"
5454
>

pages/index.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="page-contents">
33
<Navbar />
4-
<main class="text-gray-800 dark:text-gray-50">
4+
<main class="text-gray-800 outline-none dark:text-gray-50" tabindex="0">
55
<section>
66
<header>
77
<h1 class="w-full mb-2 text-xl text-center">

pages/v1/diff.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<template>
22
<div class="page-contents">
33
<Navbar :show-back-button="true" />
4-
<main>
4+
<main class="outline-none" tabindex="0">
55
<section
66
class="
77
flex

tailwind.config.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,8 @@ module.exports = {
1616
zIndex: {
1717
'1': 1,
1818
'2': 2,
19-
'10': 10
19+
'10': 10,
20+
'11': 11
2021
},
2122
minHeight: {
2223
'80': '20rem'

0 commit comments

Comments
 (0)