teleport bread

This commit is contained in:
Henry Jameson 2022-04-05 19:22:15 +03:00
parent 4a068483ed
commit 6a319154d9
7 changed files with 90 additions and 76 deletions

View file

@ -1,6 +1,5 @@
import UserPanel from './components/user_panel/user_panel.vue'
import NavPanel from './components/nav_panel/nav_panel.vue'
import Notifications from './components/notifications/notifications.vue'
import InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
import FeaturesPanel from './components/features_panel/features_panel.vue'
import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_panel.vue'
@ -16,13 +15,14 @@ import PostStatusModal from './components/post_status_modal/post_status_modal.vu
import GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
import { windowWidth, windowHeight } from './services/window_utils/window_utils'
import { mapGetters } from 'vuex'
import { defineAsyncComponent } from 'vue'
export default {
name: 'app',
components: {
UserPanel,
NavPanel,
Notifications,
Notifications: defineAsyncComponent(() => import('./components/notifications/notifications.vue')),
InstanceSpecificPanel,
FeaturesPanel,
WhoToFollowPanel,

View file

@ -64,10 +64,10 @@ nav {
#sidebar {
grid-area: sidebar;
@media all and (max-width: 800px) {
display: none;
}
#notifs-column {
grid-area: notifs;
}
#main-scroller {
@ -177,6 +177,10 @@ nav {
.underlay {
display: none;
}
#sidebar {
display: none;
}
}
}

View file

@ -9,23 +9,21 @@
/>
<MobileNav v-if="layoutType === 'mobile'" />
<DesktopNav v-else />
<notifications v-if="currentUser" />
<div
id="content"
class="app-layout container"
:class="[{ '-reverse': reverseLayout }, '-' + layoutType]"
>
<div class="underlay"/>
<div
id="sidebar"
class="column -scrollable -mini mobile-hidden"
>
<div id="sidebar" class="column -scrollable">
<user-panel />
<template v-if="layoutType !== 'mobile'">
<nav-panel />
<instance-specific-panel v-if="showInstanceSpecificPanel" />
<features-panel v-if="!currentUser && showFeaturesPanel" />
<who-to-follow-panel v-if="currentUser && suggestionsEnabled" />
<notifications v-if="currentUser" />
<div id="notifs-sidebar" />
</template>
</div>
<div id="main-scroller" class="column main">
@ -42,6 +40,7 @@
</div>
<router-view />
</div>
<div id="notifs-column" class="column -scrollable"/>
<media-modal />
</div>
<shout-panel

View file

@ -78,7 +78,8 @@ const MobileNav = {
this.$store.dispatch('logout')
},
markNotificationsAsSeen () {
this.$refs.notifications.markAsSeen()
// this.$refs.notifications.markAsSeen()
this.$store.dispatch('markNotificationsAsSeen')
},
onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
if (scrollTop + clientHeight >= scrollHeight) {

View file

@ -69,12 +69,9 @@
</div>
<div
class="mobile-notifications"
id="mobile-notifications"
@scroll="onScroll"
>
<Notifications
ref="notifications"
:no-heading="true"
/>
</div>
</div>
<SideDrawer

View file

@ -23,8 +23,6 @@ const Notifications = {
NotificationFilters
},
props: {
// Disables display of panel header
noHeading: Boolean,
// Disables panel styles, unread mark, potentially other notification-related actions
// meant for "Interactions" timeline
minimalMode: Boolean,
@ -65,6 +63,19 @@ const Notifications = {
loading () {
return this.$store.state.statuses.notifications.loading
},
noHeading () {
const { layoutType } = this.$store.state.interface
console.log(layoutType)
return layoutType === 'mobile'
},
teleportTarget () {
const { layoutType } = this.$store.state.interface
const map = {
wide: '#notifs-column',
mobile: '#mobile-notifications'
}
return map[layoutType] || '#notifs-sidebar'
},
notificationsToDisplay () {
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
},

View file

@ -1,4 +1,5 @@
<template>
<teleport :to="teleportTarget">
<div
:class="{ minimal: minimalMode }"
class="Notifications"
@ -64,6 +65,7 @@
</div>
</div>
</div>
</teleport>
</template>
<script src="./notifications.js"></script>