-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathApp.vue
110 lines (101 loc) · 2.91 KB
/
App.vue
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
98
99
100
101
102
103
104
105
106
107
108
109
110
<template>
<div
id="app"
v-bind:class="{
'c-a11yapp--enhanced-focus': enhancedFocus,
'user-prefers-reduced-motion-reduce': reducedMotion
}"
>
<vue-announcer />
<div id="wrapper">
<header role="banner">
<div class="c-top-bar">
<div class="o-layout-inner c-top-bar__wrapper">
<Logo />
<Navigation ref="navMain" />
</div>
</div>
<div class="o-layout-inner c-top-bar__footer">
<UserActions />
<Logline />
</div>
</header>
<div class="o-layout-inner">
<main role="main" class="c-content">
<keep-alive>
<router-view ref="routerView"></router-view>
</keep-alive>
</main>
</div>
<AccessibleAppInfo />
<footer role="contentinfo"></footer>
</div>
<portal-target name="dialog" multiple></portal-target>
</div>
</template>
<script>
import store from "./store";
import Logo from "./components/Logo.vue";
import Navigation from "./components/Navigation";
import UserActions from "./components/UserActions";
import Logline from "./components/Logline";
import AccessibleAppInfo from "./components/accessibleapp/AccessibleAppInfo";
export default {
store,
computed: {
enhancedFocus() {
return store.getters.getEnhancedFocus;
},
reducedMotion() {
return store.getters.getReducedMotion;
}
},
components: { Logline, Navigation, Logo, UserActions, AccessibleAppInfo },
watch: {
$route: function(to) {
// $nextTick = DOM updated
this.$nextTick(function() {
// Change document title
document.title = to.meta.title;
// Focus management on route change
setTimeout(() => {
// Get component's "routeFocusTarget" ref.
// If not existent, use router view container
let focusTarget =
this.$refs.routerView.$refs.componentFocusTarget !== undefined
? this.$refs.routerView.$refs.componentFocusTarget
: this.$refs.routerView.$el;
// Make focustarget programmatically focussable
focusTarget.setAttribute("tabindex", "-1");
// Focus element
focusTarget.focus();
// setAriaCurrent in navigation only after focus management
this.setAriaCurrent();
}, 0);
});
}
},
mounted() {
this.setAriaCurrent();
},
methods: {
setAriaCurrent() {
this.$nextTick(function() {
let app = this.$el,
currents = app.querySelectorAll("[aria-current]");
if (currents) {
currents.forEach(current => {
current.removeAttribute("aria-current");
});
}
app.querySelectorAll(".router-link-exact-active").forEach(current => {
current.setAttribute("aria-current", "page");
});
});
}
}
};
</script>
<style lang="scss">
@import "@/scss/base.scss";
</style>