Skip to content

Commit 9ca93ec

Browse files
committed
feat: handle full width viewport with css for admin views
1 parent 8ec0427 commit 9ca93ec

File tree

2 files changed

+22
-6
lines changed

2 files changed

+22
-6
lines changed

src/App.vue

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<ProvideAuth>
44
<ProvideWebsocket>
55
<ProvideBreadcrumbs>
6-
<div id="wrapper">
6+
<div id="wrapper" :class="{ 'admin': adminMode }">
77
<Header></Header>
88
<main>
99
<div id="public-content">
@@ -23,10 +23,19 @@ import ProvidePreferences from '@/composables/stores/prefs'
2323
import ProvideAuth from '@/composables/stores/auth'
2424
import ProvideWebsocket from '@/composables/services/websocket'
2525
import ProvideBreadcrumbs from '@/composables/stores/breadcrumbs'
26+
import { reactive, toRefs, watch } from 'vue'
27+
import { useRoute } from 'vue-router'
2628
2729
export default {
2830
name: 'Epochtalk',
29-
components: { Header, ProvidePreferences, ProvideWebsocket, ProvideBreadcrumbs, ProvideAuth }
31+
components: { Header, ProvidePreferences, ProvideWebsocket, ProvideBreadcrumbs, ProvideAuth },
32+
setup() {
33+
const v = reactive({ adminMode: false })
34+
const $route = useRoute()
35+
// Modify css when in admin routes
36+
watch(() => $route.path, p => v.adminMode = p.indexOf('/admin') === 0)
37+
return { ...toRefs(v) }
38+
}
3039
}
3140
</script>
3241

@@ -44,7 +53,7 @@ export default {
4453
min-height: calc(100vh - (#{$header-offset} + 1rem));
4554
position:relative;
4655
margin-top: calc(#{$header-offset} + 1rem);
47-
56+
&.admin { margin-top: calc(#{$header-height} + 2rem); }
4857
.motd-visible & {
4958
margin-top: calc(#{$header-offset} + 4rem);
5059

src/components/layout/Header.vue

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
<div class="header-contents">
7070
<!-- Menu -->
7171
<div id="menu-wrap" :class="{ 'mobile-expanded' : focusSearch }">
72-
<nav id="menu">
72+
<nav id="menu" :class="{ 'admin' : adminMode }">
7373
<!-- Logo Section -->
7474
<h1>
7575
<router-link to="/" v-if="logo"><img :src="logo" id="logo" /></router-link>
@@ -227,7 +227,7 @@
227227
</div>
228228

229229
<!-- Breadcrumbs -->
230-
<breadcrumbs></breadcrumbs>
230+
<breadcrumbs v-if="!adminMode"></breadcrumbs>
231231

232232
<!-- Alerts -->
233233
<alert></alert>
@@ -341,6 +341,7 @@ export default {
341341
showLogin: false,
342342
hideAnnnouncement: false,
343343
motdData: null,
344+
adminMode: false,
344345
loggedIn: $auth.loggedIn,
345346
logo: '',
346347
scrollDownPos: 95,
@@ -358,7 +359,12 @@ export default {
358359
})
359360
360361
watch(() => $auth.user, u => v.currentUser = u, { deep: true })
361-
watch(() => $route.path, p => v.hideAnnnouncement = v.motdData?.main_view_only && p !== '' && p !== '/')
362+
watch(() => $route.path, p => {
363+
// Only show announcement on main view if setting is set in admin panel
364+
v.hideAnnnouncement = v.motdData?.main_view_only && p !== '' && p !== '/'
365+
//Switch header style to full width for admin views
366+
v.adminMode = p.indexOf('/admin') === 0
367+
})
362368
watch(() => NotificationsStore.messages, c => v.notificationMessages = c)
363369
watch(() => NotificationsStore.mentions, c => v.notificationMentions = c)
364370
watch(() => NotificationsStore.mentionsList, l => v.mentionsList = l)
@@ -576,6 +582,7 @@ header {
576582
577583
#menu {
578584
@include base-layout-width;
585+
&.admin { max-width: unset; }
579586
h1 {
580587
float: left;
581588
font-family: $base-font-sans;

0 commit comments

Comments
 (0)