blob: a4f73daff0d09c61a351d2a4d302b51c49ff3e95 [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';
SurenNeware61859092020-10-01 09:37:32 +053014import 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,
Derick Montague602e98a2020-10-21 16:20:00 -050020 PageContainer,
Derick Montague75b48322019-12-06 01:24:41 -060021 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080022 data() {
23 return {
Derick Montague602e98a2020-10-21 16:20:00 -050024 routerKey: 0,
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080025 };
26 },
Derick Montague75b48322019-12-06 01:24:41 -060027 watch: {
Derick Montague602e98a2020-10-21 16:20:00 -050028 $route: function () {
Derick Montague75b48322019-12-06 01:24:41 -060029 // $nextTick = DOM updated
Derick Montague602e98a2020-10-21 16:20:00 -050030 this.$nextTick(function () {
Derick Montague75b48322019-12-06 01:24:41 -060031 // 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 });
Derick Montague602e98a2020-10-21 16:20:00 -050044 },
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;
Derick Montague602e98a2020-10-21 16:20:00 -050051 },
52 },
Derick Montaguee080a1a2019-12-04 16:30:08 -060053};
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>