blob: 8edc338dc707f66f047fd43fbcbc391d6c06ba17 [file] [log] [blame]
Derick Montaguee080a1a2019-12-04 16:30:08 -06001<template>
Yoshie Muranaka74f86872020-02-10 12:28:37 -08002 <div class="app-container">
3 <app-header ref="focusTarget" class="app-header" @refresh="refresh" />
4 <app-navigation class="app-navigation" />
5 <page-container class="app-content">
6 <router-view ref="routerView" :key="routerKey" />
7 </page-container>
Derick Montaguee080a1a2019-12-04 16:30:08 -06008 </div>
9</template>
10
11<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060012import AppHeader from '@/components/AppHeader';
13import AppNavigation from '@/components/AppNavigation';
14import PageContainer from '../components/Global/PageContainer';
Derick Montaguee080a1a2019-12-04 16:30:08 -060015export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060016 name: 'App',
Derick Montaguee080a1a2019-12-04 16:30:08 -060017 components: {
18 AppHeader,
Yoshie Muranaka8d129102019-12-19 09:51:55 -080019 AppNavigation,
20 PageContainer
Derick Montague75b48322019-12-06 01:24:41 -060021 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080022 data() {
23 return {
24 routerKey: 0
25 };
26 },
Derick Montague75b48322019-12-06 01:24:41 -060027 watch: {
28 $route: function() {
29 // $nextTick = DOM updated
30 this.$nextTick(function() {
31 // Get the focusTarget DOM element
32 let focusTarget = this.$refs.focusTarget.$el;
33
34 // Make focustarget programmatically focussable
Derick Montaguee2fd1562019-12-20 13:26:53 -060035 focusTarget.setAttribute('tabindex', '-1');
Derick Montague75b48322019-12-06 01:24:41 -060036
37 // Focus element
38 focusTarget.focus();
39
40 // Remove tabindex from focustarget
41 // Reason: https://axesslab.com/skip-links/#update-3-a-comment-from-gov-uk
Derick Montaguee2fd1562019-12-20 13:26:53 -060042 focusTarget.removeAttribute('tabindex');
Derick Montague75b48322019-12-06 01:24:41 -060043 });
44 }
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080045 },
46 methods: {
47 refresh() {
48 // Changing the component :key value will trigger
49 // a component re-rendering and 'refresh' the view
50 this.routerKey += 1;
51 }
Derick Montaguee080a1a2019-12-04 16:30:08 -060052 }
53};
54</script>
55
56<style lang="scss" scoped>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080057.app-container {
58 display: grid;
59 grid-template-columns: 100%;
60 grid-template-rows: auto;
61 grid-template-areas:
62 'header'
63 'content';
64
65 @include media-breakpoint-up($responsive-layout-bp) {
66 grid-template-columns: $navigation-width 1fr;
67 grid-template-areas:
68 'header header'
69 'navigation content';
70 }
71}
72
73.app-header {
74 grid-area: header;
75 position: sticky;
76 top: 0;
77 z-index: $zindex-fixed + 1;
78}
79
80.app-navigation {
81 grid-area: navigation;
82}
83
84.app-content {
85 grid-area: content;
86 background-color: $white;
Derick Montaguee080a1a2019-12-04 16:30:08 -060087}
88</style>