-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathapp.vue
195 lines (179 loc) · 4.78 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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
<script setup>
import { useLayoutState } from './composables/useLayoutState'
provide('theme', computed(() => ''))
const { enabled, state } = usePreviewMode()
// console.log('App.vue', enabled.value, state.token)
const route = useRoute()
const globalStore = useGlobalStore()
const { header, footerPrimary, footerSock, setLayoutData } = useLayoutState()
setLayoutData(globalStore)
const classes = ref(['layout',
'layout-default'])
const libraryAlert = computed(() => {
/* console.log(
'in library alert computed property',
globalStore.header,
) */
if (globalStore.globals) {
const alert = globalStore.globals?.libraryAlert
if (
alert
&& alert.title
&& alert.title.length > 0
&& alert.text
&& alert.text.length > 0
)
return alert
else
return null
}
})
// on mounted I want to want to check if visiblity change event is triggered and use $fetch or $graghql to fetch data from api
// I want to use this data to update the global store
// const { $graphql } = useNuxtApp()
const { $alerts } = useNuxtApp()
const { $layoutData } = useNuxtApp()
watch(globalStore.header, (newVal, oldVal) => {
console.log('Global store changed for draft previews', newVal, oldVal)
setLayoutData(globalStore)
})
onMounted(async () => {
// globalstore state is lost due to 404 error for draft previews, this is hack to repopulate state on client side
console.log('No layout query', route.query, 'preview enabled', enabled.value, 'state?.token', state?.token)
if (process.env.NODE_ENV !== 'development' && (route.query?.preview === 'true' || enabled.value) && (route.query?.token !== undefined || state?.token !== undefined)) {
await $layoutData()
}
await $alerts()
})
const shouldIncludeExtraScript = computed(() => {
if (useRuntimeConfig().public.hostName.includes('stage'))
return true
return false
})
const shouldIncludeProductionScript = computed(() => {
if (!useRuntimeConfig().public.hostName.includes('stage') && !useRuntimeConfig().public.hostName.includes('test'))
return true
return false
})
useHead({
titleTemplate: title =>
title === 'Homepage' ? 'UCLA Library' : `${title}` + ' | UCLA Library',
script: [
{
hid: 'libanswers',
src: 'https://ucla.libanswers.com/load_chat.php?hash=5a44dfe7cc29aaee5bba635ab13fa753',
defer: true
},
...(shouldIncludeExtraScript.value
? [{
hid: 'gsurvey',
src: 'https://test-librarystudy.library.ucla.edu/gsurvey.js',
defer: true
}
]
: []),
...(shouldIncludeProductionScript.value
? [{
hid: 'gsurvey',
src: 'https://librarystudy.library.ucla.edu/gsurvey.js',
defer: true
}
]
: [])
]
})
</script>
<template>
<div>
<NuxtLoadingIndicator
color="#ffe800"
:height="3"
/>
<vue-skip-to
to="#main"
label="Skip to main content"
/>
<div :class="classes">
<HeaderSmart v-if="header && !$route.path.includes('/impact/')" />
<SectionWrapper
v-if="!$route.path.includes('/impact/')"
class="
section-alert"
theme="divider"
>
<site-notification-alert
v-if="
libraryAlert"
class="library-alert"
v-bind="libraryAlert"
/>
</SectionWrapper>
<nav-primary
v-if="header && $route.path.includes('/impact/')"
class="primary"
/>
<NuxtPage />
<footer>
<FooterPrimary
v-if="footerPrimary && !$route.path.includes('/impact/')"
:form="true"
/>
<FooterPrimary
v-if="footerPrimary && $route.path.includes('/impact/')"
:form="false"
/>
<FooterSock v-if="footerSock && !$route.path.includes('/impact/')" />
</footer>
<div
v-if="!$route.path.includes('/impact/')"
id="libchat_5a44dfe7cc29aaee5bba635ab13fa753"
/>
</div>
<!--NuxtLayout>
<NuxtPage />
</NuxtLayout-->
</div>
</template>
<style lang="scss" scoped>
.layout-default {
min-height: 100vh;
display: flex;
flex-direction: column;
flex-wrap: nowrap;
justify-content: space-between;
align-content: center;
align-items: center;
flex: 1 1 auto;
:deep(>*) {
width: 100%;
}
.section-alert {
height: 0;
position: relative;
.library-alert {
position: absolute;
z-index: 100;
top: 32px;
right: var(--unit-gutter);
}
}
}
.vue-skip-to {
z-index: 300;
}
.skip-link {
position: absolute;
transform: translateY(-100%);
display: inline-block;
background: var(--color-primary-yellow-01);
color: var(--color-black);
@include step-0;
padding: 4px 16px;
transition: transform 0.3s;
width: auto;
left: 0;
}
.skip-link:focus {
transform: translateY(0%);
}
</style>