blob: c2023dfb8e69099b882307cdfc861ffbc20f9703 [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" />
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -06007 <!-- Scroll to top button -->
8 <button-back-to-top />
Yoshie Muranaka74f86872020-02-10 12:28:37 -08009 </page-container>
Derick Montaguee080a1a2019-12-04 16:30:08 -060010 </div>
11</template>
12
13<script>
Derick Montaguee2fd1562019-12-20 13:26:53 -060014import AppHeader from '@/components/AppHeader';
15import AppNavigation from '@/components/AppNavigation';
SurenNeware61859092020-10-01 09:37:32 +053016import PageContainer from '@/components/Global/PageContainer';
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -060017import ButtonBackToTop from '@/components/Global/ButtonBackToTop';
18
Derick Montaguee080a1a2019-12-04 16:30:08 -060019export default {
Derick Montaguee2fd1562019-12-20 13:26:53 -060020 name: 'App',
Derick Montaguee080a1a2019-12-04 16:30:08 -060021 components: {
22 AppHeader,
Yoshie Muranaka8d129102019-12-19 09:51:55 -080023 AppNavigation,
Derick Montague602e98a2020-10-21 16:20:00 -050024 PageContainer,
Dixsie Wolmers970ea7d2020-11-16 16:46:01 -060025 ButtonBackToTop,
Derick Montague75b48322019-12-06 01:24:41 -060026 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080027 data() {
28 return {
Derick Montague602e98a2020-10-21 16:20:00 -050029 routerKey: 0,
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080030 };
31 },
Derick Montague75b48322019-12-06 01:24:41 -060032 watch: {
Derick Montague602e98a2020-10-21 16:20:00 -050033 $route: function () {
Derick Montague75b48322019-12-06 01:24:41 -060034 // $nextTick = DOM updated
Derick Montague602e98a2020-10-21 16:20:00 -050035 this.$nextTick(function () {
Derick Montague75b48322019-12-06 01:24:41 -060036 // Get the focusTarget DOM element
37 let focusTarget = this.$refs.focusTarget.$el;
38
39 // Make focustarget programmatically focussable
Derick Montaguee2fd1562019-12-20 13:26:53 -060040 focusTarget.setAttribute('tabindex', '-1');
Derick Montague75b48322019-12-06 01:24:41 -060041
42 // Focus element
43 focusTarget.focus();
44
45 // Remove tabindex from focustarget
46 // Reason: https://axesslab.com/skip-links/#update-3-a-comment-from-gov-uk
Derick Montaguee2fd1562019-12-20 13:26:53 -060047 focusTarget.removeAttribute('tabindex');
Derick Montague75b48322019-12-06 01:24:41 -060048 });
Derick Montague602e98a2020-10-21 16:20:00 -050049 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080050 },
Yoshie Muranaka6f712842021-02-04 11:23:03 -080051 mounted() {
52 this.$root.$on('refresh-application', () => this.refresh());
53 },
Yoshie Muranakaeb154bb2020-02-07 12:18:45 -080054 methods: {
55 refresh() {
56 // Changing the component :key value will trigger
57 // a component re-rendering and 'refresh' the view
58 this.routerKey += 1;
Derick Montague602e98a2020-10-21 16:20:00 -050059 },
60 },
Derick Montaguee080a1a2019-12-04 16:30:08 -060061};
62</script>
63
64<style lang="scss" scoped>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080065.app-container {
66 display: grid;
67 grid-template-columns: 100%;
68 grid-template-rows: auto;
69 grid-template-areas:
70 'header'
71 'content';
72
73 @include media-breakpoint-up($responsive-layout-bp) {
74 grid-template-columns: $navigation-width 1fr;
75 grid-template-areas:
76 'header header'
77 'navigation content';
78 }
79}
80
81.app-header {
82 grid-area: header;
83 position: sticky;
84 top: 0;
85 z-index: $zindex-fixed + 1;
86}
87
88.app-navigation {
89 grid-area: navigation;
90}
91
92.app-content {
93 grid-area: content;
94 background-color: $white;
Derick Montaguee080a1a2019-12-04 16:30:08 -060095}
96</style>