teleport bread
This commit is contained in:
parent
4a068483ed
commit
6a319154d9
7 changed files with 90 additions and 76 deletions
|
@ -1,6 +1,5 @@
|
||||||
import UserPanel from './components/user_panel/user_panel.vue'
|
import UserPanel from './components/user_panel/user_panel.vue'
|
||||||
import NavPanel from './components/nav_panel/nav_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 InstanceSpecificPanel from './components/instance_specific_panel/instance_specific_panel.vue'
|
||||||
import FeaturesPanel from './components/features_panel/features_panel.vue'
|
import FeaturesPanel from './components/features_panel/features_panel.vue'
|
||||||
import WhoToFollowPanel from './components/who_to_follow_panel/who_to_follow_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 GlobalNoticeList from './components/global_notice_list/global_notice_list.vue'
|
||||||
import { windowWidth, windowHeight } from './services/window_utils/window_utils'
|
import { windowWidth, windowHeight } from './services/window_utils/window_utils'
|
||||||
import { mapGetters } from 'vuex'
|
import { mapGetters } from 'vuex'
|
||||||
|
import { defineAsyncComponent } from 'vue'
|
||||||
|
|
||||||
export default {
|
export default {
|
||||||
name: 'app',
|
name: 'app',
|
||||||
components: {
|
components: {
|
||||||
UserPanel,
|
UserPanel,
|
||||||
NavPanel,
|
NavPanel,
|
||||||
Notifications,
|
Notifications: defineAsyncComponent(() => import('./components/notifications/notifications.vue')),
|
||||||
InstanceSpecificPanel,
|
InstanceSpecificPanel,
|
||||||
FeaturesPanel,
|
FeaturesPanel,
|
||||||
WhoToFollowPanel,
|
WhoToFollowPanel,
|
||||||
|
|
10
src/App.scss
10
src/App.scss
|
@ -64,10 +64,10 @@ nav {
|
||||||
|
|
||||||
#sidebar {
|
#sidebar {
|
||||||
grid-area: sidebar;
|
grid-area: sidebar;
|
||||||
|
}
|
||||||
|
|
||||||
@media all and (max-width: 800px) {
|
#notifs-column {
|
||||||
display: none;
|
grid-area: notifs;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#main-scroller {
|
#main-scroller {
|
||||||
|
@ -177,6 +177,10 @@ nav {
|
||||||
.underlay {
|
.underlay {
|
||||||
display: none;
|
display: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#sidebar {
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,23 +9,21 @@
|
||||||
/>
|
/>
|
||||||
<MobileNav v-if="layoutType === 'mobile'" />
|
<MobileNav v-if="layoutType === 'mobile'" />
|
||||||
<DesktopNav v-else />
|
<DesktopNav v-else />
|
||||||
|
<notifications v-if="currentUser" />
|
||||||
<div
|
<div
|
||||||
id="content"
|
id="content"
|
||||||
class="app-layout container"
|
class="app-layout container"
|
||||||
:class="[{ '-reverse': reverseLayout }, '-' + layoutType]"
|
:class="[{ '-reverse': reverseLayout }, '-' + layoutType]"
|
||||||
>
|
>
|
||||||
<div class="underlay"/>
|
<div class="underlay"/>
|
||||||
<div
|
<div id="sidebar" class="column -scrollable">
|
||||||
id="sidebar"
|
|
||||||
class="column -scrollable -mini mobile-hidden"
|
|
||||||
>
|
|
||||||
<user-panel />
|
<user-panel />
|
||||||
<template v-if="layoutType !== 'mobile'">
|
<template v-if="layoutType !== 'mobile'">
|
||||||
<nav-panel />
|
<nav-panel />
|
||||||
<instance-specific-panel v-if="showInstanceSpecificPanel" />
|
<instance-specific-panel v-if="showInstanceSpecificPanel" />
|
||||||
<features-panel v-if="!currentUser && showFeaturesPanel" />
|
<features-panel v-if="!currentUser && showFeaturesPanel" />
|
||||||
<who-to-follow-panel v-if="currentUser && suggestionsEnabled" />
|
<who-to-follow-panel v-if="currentUser && suggestionsEnabled" />
|
||||||
<notifications v-if="currentUser" />
|
<div id="notifs-sidebar" />
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
<div id="main-scroller" class="column main">
|
<div id="main-scroller" class="column main">
|
||||||
|
@ -42,6 +40,7 @@
|
||||||
</div>
|
</div>
|
||||||
<router-view />
|
<router-view />
|
||||||
</div>
|
</div>
|
||||||
|
<div id="notifs-column" class="column -scrollable"/>
|
||||||
<media-modal />
|
<media-modal />
|
||||||
</div>
|
</div>
|
||||||
<shout-panel
|
<shout-panel
|
||||||
|
|
|
@ -78,7 +78,8 @@ const MobileNav = {
|
||||||
this.$store.dispatch('logout')
|
this.$store.dispatch('logout')
|
||||||
},
|
},
|
||||||
markNotificationsAsSeen () {
|
markNotificationsAsSeen () {
|
||||||
this.$refs.notifications.markAsSeen()
|
// this.$refs.notifications.markAsSeen()
|
||||||
|
this.$store.dispatch('markNotificationsAsSeen')
|
||||||
},
|
},
|
||||||
onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
|
onScroll ({ target: { scrollTop, clientHeight, scrollHeight } }) {
|
||||||
if (scrollTop + clientHeight >= scrollHeight) {
|
if (scrollTop + clientHeight >= scrollHeight) {
|
||||||
|
|
|
@ -69,12 +69,9 @@
|
||||||
</div>
|
</div>
|
||||||
<div
|
<div
|
||||||
class="mobile-notifications"
|
class="mobile-notifications"
|
||||||
|
id="mobile-notifications"
|
||||||
@scroll="onScroll"
|
@scroll="onScroll"
|
||||||
>
|
>
|
||||||
<Notifications
|
|
||||||
ref="notifications"
|
|
||||||
:no-heading="true"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<SideDrawer
|
<SideDrawer
|
||||||
|
|
|
@ -23,8 +23,6 @@ const Notifications = {
|
||||||
NotificationFilters
|
NotificationFilters
|
||||||
},
|
},
|
||||||
props: {
|
props: {
|
||||||
// Disables display of panel header
|
|
||||||
noHeading: Boolean,
|
|
||||||
// Disables panel styles, unread mark, potentially other notification-related actions
|
// Disables panel styles, unread mark, potentially other notification-related actions
|
||||||
// meant for "Interactions" timeline
|
// meant for "Interactions" timeline
|
||||||
minimalMode: Boolean,
|
minimalMode: Boolean,
|
||||||
|
@ -65,6 +63,19 @@ const Notifications = {
|
||||||
loading () {
|
loading () {
|
||||||
return this.$store.state.statuses.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 () {
|
notificationsToDisplay () {
|
||||||
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
|
return this.filteredNotifications.slice(0, this.unseenCount + this.seenToDisplayCount)
|
||||||
},
|
},
|
||||||
|
|
|
@ -1,69 +1,71 @@
|
||||||
<template>
|
<template>
|
||||||
<div
|
<teleport :to="teleportTarget">
|
||||||
:class="{ minimal: minimalMode }"
|
<div
|
||||||
class="Notifications"
|
:class="{ minimal: minimalMode }"
|
||||||
>
|
class="Notifications"
|
||||||
<div :class="mainClass">
|
>
|
||||||
<div
|
<div :class="mainClass">
|
||||||
v-if="!noHeading"
|
|
||||||
class="notifications-heading panel-heading -sticky"
|
|
||||||
>
|
|
||||||
<div class="title">
|
|
||||||
{{ $t('notifications.notifications') }}
|
|
||||||
<span
|
|
||||||
v-if="unseenCount"
|
|
||||||
class="badge badge-notification unseen-count"
|
|
||||||
>{{ unseenCount }}</span>
|
|
||||||
</div>
|
|
||||||
<button
|
|
||||||
v-if="unseenCount"
|
|
||||||
class="button-default read-button"
|
|
||||||
@click.prevent="markAsSeen"
|
|
||||||
>
|
|
||||||
{{ $t('notifications.read') }}
|
|
||||||
</button>
|
|
||||||
<NotificationFilters />
|
|
||||||
</div>
|
|
||||||
<div class="panel-body">
|
|
||||||
<div
|
<div
|
||||||
v-for="notification in notificationsToDisplay"
|
v-if="!noHeading"
|
||||||
:key="notification.id"
|
class="notifications-heading panel-heading -sticky"
|
||||||
class="notification"
|
|
||||||
:class="{"unseen": !minimalMode && !notification.seen}"
|
|
||||||
>
|
>
|
||||||
<div class="notification-overlay" />
|
<div class="title">
|
||||||
<notification :notification="notification" />
|
{{ $t('notifications.notifications') }}
|
||||||
</div>
|
<span
|
||||||
</div>
|
v-if="unseenCount"
|
||||||
<div class="panel-footer notifications-footer">
|
class="badge badge-notification unseen-count"
|
||||||
<div
|
>{{ unseenCount }}</span>
|
||||||
v-if="bottomedOut"
|
</div>
|
||||||
class="new-status-notification text-center faint"
|
<button
|
||||||
>
|
v-if="unseenCount"
|
||||||
{{ $t('notifications.no_more_notifications') }}
|
class="button-default read-button"
|
||||||
</div>
|
@click.prevent="markAsSeen"
|
||||||
<button
|
>
|
||||||
v-else-if="!loading"
|
{{ $t('notifications.read') }}
|
||||||
class="button-unstyled -link -fullwidth"
|
</button>
|
||||||
@click.prevent="fetchOlderNotifications()"
|
<NotificationFilters />
|
||||||
>
|
</div>
|
||||||
<div class="new-status-notification text-center">
|
<div class="panel-body">
|
||||||
{{ minimalMode ? $t('interactions.load_older') : $t('notifications.load_older') }}
|
<div
|
||||||
|
v-for="notification in notificationsToDisplay"
|
||||||
|
:key="notification.id"
|
||||||
|
class="notification"
|
||||||
|
:class="{"unseen": !minimalMode && !notification.seen}"
|
||||||
|
>
|
||||||
|
<div class="notification-overlay" />
|
||||||
|
<notification :notification="notification" />
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<div class="panel-footer notifications-footer">
|
||||||
|
<div
|
||||||
|
v-if="bottomedOut"
|
||||||
|
class="new-status-notification text-center faint"
|
||||||
|
>
|
||||||
|
{{ $t('notifications.no_more_notifications') }}
|
||||||
|
</div>
|
||||||
|
<button
|
||||||
|
v-else-if="!loading"
|
||||||
|
class="button-unstyled -link -fullwidth"
|
||||||
|
@click.prevent="fetchOlderNotifications()"
|
||||||
|
>
|
||||||
|
<div class="new-status-notification text-center">
|
||||||
|
{{ minimalMode ? $t('interactions.load_older') : $t('notifications.load_older') }}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
<div
|
||||||
|
v-else
|
||||||
|
class="new-status-notification text-center"
|
||||||
|
>
|
||||||
|
<FAIcon
|
||||||
|
icon="circle-notch"
|
||||||
|
spin
|
||||||
|
size="lg"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</button>
|
|
||||||
<div
|
|
||||||
v-else
|
|
||||||
class="new-status-notification text-center"
|
|
||||||
>
|
|
||||||
<FAIcon
|
|
||||||
icon="circle-notch"
|
|
||||||
spin
|
|
||||||
size="lg"
|
|
||||||
/>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</teleport>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script src="./notifications.js"></script>
|
<script src="./notifications.js"></script>
|
||||||
|
|
Loading…
Reference in a new issue