blob: 228b25cd66ddbdc694c1728596a67e0ab03521c2 [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 },
51 methods: {
52 refresh() {
53 // Changing the component :key value will trigger
54 // a component re-rendering and 'refresh' the view
55 this.routerKey += 1;
Derick Montague602e98a2020-10-21 16:20:00 -050056 },
57 },
Derick Montaguee080a1a2019-12-04 16:30:08 -060058};
59</script>
60
61<style lang="scss" scoped>
Yoshie Muranaka74f86872020-02-10 12:28:37 -080062.app-container {
63 display: grid;
64 grid-template-columns: 100%;
65 grid-template-rows: auto;
66 grid-template-areas:
67 'header'
68 'content';
69
70 @include media-breakpoint-up($responsive-layout-bp) {
71 grid-template-columns: $navigation-width 1fr;
72 grid-template-areas:
73 'header header'
74 'navigation content';
75 }
76}
77
78.app-header {
79 grid-area: header;
80 position: sticky;
81 top: 0;
82 z-index: $zindex-fixed + 1;
83}
84
85.app-navigation {
86 grid-area: navigation;
87}
88
89.app-content {
90 grid-area: content;
91 background-color: $white;
Derick Montaguee080a1a2019-12-04 16:30:08 -060092}
93</style>