parent
9e453372b3
commit
3a16a59f37
@ -0,0 +1,11 @@
|
|||||||
|
export const filterNavigation = (list = [], { hasChats, isFederating, isPrivate, currentUser }) => {
|
||||||
|
return list.filter(({ criteria, anon, anonRoute }) => {
|
||||||
|
const set = new Set(criteria || [])
|
||||||
|
if (!isFederating && set.has('federating')) return false
|
||||||
|
if (isPrivate && set.has('!private')) return false
|
||||||
|
if (!currentUser && !(anon || anonRoute)) return false
|
||||||
|
if ((!currentUser || !currentUser.locked) && set.has('lockedUser')) return false
|
||||||
|
if (!hasChats && set.has('chats')) return false
|
||||||
|
return true
|
||||||
|
})
|
||||||
|
}
|
@ -0,0 +1,61 @@
|
|||||||
|
export const TIMELINES = {
|
||||||
|
home: {
|
||||||
|
route: 'friends',
|
||||||
|
anonRoute: 'public-timeline',
|
||||||
|
icon: 'home',
|
||||||
|
label: 'nav.home_timeline',
|
||||||
|
criteria: ['!private']
|
||||||
|
},
|
||||||
|
public: {
|
||||||
|
route: 'public-timeline',
|
||||||
|
anon: true,
|
||||||
|
icon: 'users',
|
||||||
|
label: 'nav.public_tl',
|
||||||
|
criteria: ['!private']
|
||||||
|
},
|
||||||
|
twkn: {
|
||||||
|
route: 'public-external-timeline',
|
||||||
|
anon: true,
|
||||||
|
icon: 'globe',
|
||||||
|
label: 'nav.twkn',
|
||||||
|
criteria: ['!private', 'federating']
|
||||||
|
},
|
||||||
|
bookmarks: {
|
||||||
|
route: 'bookmarks',
|
||||||
|
icon: 'bookmark',
|
||||||
|
label: 'nav.bookmarks'
|
||||||
|
},
|
||||||
|
dms: {
|
||||||
|
route: 'dms',
|
||||||
|
icon: 'envelope',
|
||||||
|
label: 'nav.dms'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export const ROOT_ITEMS = {
|
||||||
|
interactions: {
|
||||||
|
route: 'interactions',
|
||||||
|
icon: 'bell',
|
||||||
|
label: 'nav.interactions'
|
||||||
|
},
|
||||||
|
chats: {
|
||||||
|
route: 'chats',
|
||||||
|
icon: 'comments',
|
||||||
|
label: 'nav.chats',
|
||||||
|
badgeGetter: 'unreadChatCount',
|
||||||
|
criteria: ['chats']
|
||||||
|
},
|
||||||
|
friendRequests: {
|
||||||
|
route: 'friend-requests',
|
||||||
|
icon: 'user-plus',
|
||||||
|
label: 'nav.friend_requests',
|
||||||
|
criteria: ['lockedUser'],
|
||||||
|
badgeGetter: 'followRequestCount'
|
||||||
|
},
|
||||||
|
about: {
|
||||||
|
route: 'about',
|
||||||
|
anon: true,
|
||||||
|
icon: 'info-circle',
|
||||||
|
label: 'nav.about'
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
import { mapState } from 'vuex'
|
||||||
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
|
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
|
library.add(faThumbtack)
|
||||||
|
|
||||||
|
const NavigationEntry = {
|
||||||
|
props: ['item', 'showPin'],
|
||||||
|
methods: {
|
||||||
|
isPinned (value) {
|
||||||
|
return this.pinnedItems.has(value)
|
||||||
|
},
|
||||||
|
togglePin (value) {
|
||||||
|
if (this.isPinned(value)) {
|
||||||
|
this.$store.commit('removeCollectionPreference', { path: 'collections.pinnedNavItems', value })
|
||||||
|
} else {
|
||||||
|
this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value })
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
computed: {
|
||||||
|
getters () {
|
||||||
|
return this.$store.getters
|
||||||
|
},
|
||||||
|
...mapState({
|
||||||
|
currentUser: state => state.users.currentUser,
|
||||||
|
pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NavigationEntry
|
@ -0,0 +1,96 @@
|
|||||||
|
<template>
|
||||||
|
<li class="NavigationEntry">
|
||||||
|
<router-link
|
||||||
|
class="menu-item"
|
||||||
|
:to="item.routeObject || { name: (currentUser || item.anon) ? item.route : item.anonRoute, params: { username: currentUser.screen_name } }"
|
||||||
|
>
|
||||||
|
<FAIcon
|
||||||
|
v-if="item.icon"
|
||||||
|
fixed-width
|
||||||
|
class="fa-scale-110"
|
||||||
|
:icon="item.icon"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
class="icon iconLetter fa-scale-110"
|
||||||
|
v-if="item.iconLetter"
|
||||||
|
>{{ item.iconLetter }}
|
||||||
|
</span>{{ item.labelRaw || $t(item.label) }}
|
||||||
|
<button
|
||||||
|
type="button"
|
||||||
|
class="button-unstyled"
|
||||||
|
@click.stop.prevent="togglePin(item.name)"
|
||||||
|
>
|
||||||
|
<FAIcon
|
||||||
|
v-if="showPin"
|
||||||
|
fixed-width
|
||||||
|
class="fa-scale-110"
|
||||||
|
:class="{ 'veryfaint': !isPinned(item.name) }"
|
||||||
|
:transform="!isPinned(item.name) ? 'rotate-45' : ''"
|
||||||
|
icon="thumbtack"
|
||||||
|
/>
|
||||||
|
<div
|
||||||
|
v-if="item.badgeGetter && getters[item.badgeGetter]"
|
||||||
|
class="badge badge-notification"
|
||||||
|
>
|
||||||
|
{{ getters[item.badgeGetter] }}
|
||||||
|
</div>
|
||||||
|
</button>
|
||||||
|
</router-link>
|
||||||
|
</li>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./navigation_entry.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
|
||||||
|
.NavigationEntry {
|
||||||
|
.fa-scale-110 {
|
||||||
|
margin-right: 0.8em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.badge {
|
||||||
|
position: absolute;
|
||||||
|
right: 0.6rem;
|
||||||
|
top: 1.25em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.menu-item {
|
||||||
|
display: block;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 3.5em;
|
||||||
|
line-height: 3.5em;
|
||||||
|
padding: 0 1em;
|
||||||
|
width: 100%;
|
||||||
|
color: $fallback--link;
|
||||||
|
color: var(--link, $fallback--link);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
background-color: $fallback--lightBg;
|
||||||
|
background-color: var(--selectedMenu, $fallback--lightBg);
|
||||||
|
color: $fallback--link;
|
||||||
|
color: var(--selectedMenuText, $fallback--link);
|
||||||
|
--faint: var(--selectedMenuFaintText, $fallback--faint);
|
||||||
|
--faintLink: var(--selectedMenuFaintLink, $fallback--faint);
|
||||||
|
--lightText: var(--selectedMenuLightText, $fallback--lightText);
|
||||||
|
--icon: var(--selectedMenuIcon, $fallback--icon);
|
||||||
|
}
|
||||||
|
|
||||||
|
&.router-link-active {
|
||||||
|
font-weight: bolder;
|
||||||
|
background-color: $fallback--lightBg;
|
||||||
|
background-color: var(--selectedMenu, $fallback--lightBg);
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--selectedMenuText, $fallback--text);
|
||||||
|
--faint: var(--selectedMenuFaintText, $fallback--faint);
|
||||||
|
--faintLink: var(--selectedMenuFaintLink, $fallback--faint);
|
||||||
|
--lightText: var(--selectedMenuLightText, $fallback--lightText);
|
||||||
|
--icon: var(--selectedMenuIcon, $fallback--icon);
|
||||||
|
|
||||||
|
&:hover {
|
||||||
|
text-decoration: underline;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
@ -0,0 +1,68 @@
|
|||||||
|
import { getListEntries } from '../lists_menu/lists_menu_content.vue'
|
||||||
|
import { mapState } from 'vuex'
|
||||||
|
import { TIMELINES, ROOT_ITEMS } from 'src/components/navigation/navigation.js'
|
||||||
|
import { filterNavigation } from 'src/components/navigation/filter.js'
|
||||||
|
|
||||||
|
import { library } from '@fortawesome/fontawesome-svg-core'
|
||||||
|
import {
|
||||||
|
faUsers,
|
||||||
|
faGlobe,
|
||||||
|
faBookmark,
|
||||||
|
faEnvelope,
|
||||||
|
faComments,
|
||||||
|
faBell,
|
||||||
|
faInfoCircle,
|
||||||
|
faStream,
|
||||||
|
faList
|
||||||
|
} from '@fortawesome/free-solid-svg-icons'
|
||||||
|
|
||||||
|
library.add(
|
||||||
|
faUsers,
|
||||||
|
faGlobe,
|
||||||
|
faBookmark,
|
||||||
|
faEnvelope,
|
||||||
|
faComments,
|
||||||
|
faBell,
|
||||||
|
faInfoCircle,
|
||||||
|
faStream,
|
||||||
|
faList
|
||||||
|
)
|
||||||
|
const NavPanel = {
|
||||||
|
computed: {
|
||||||
|
getters () {
|
||||||
|
return this.$store.getters
|
||||||
|
},
|
||||||
|
...mapState({
|
||||||
|
lists: getListEntries,
|
||||||
|
currentUser: state => state.users.currentUser,
|
||||||
|
followRequestCount: state => state.api.followRequests.length,
|
||||||
|
privateMode: state => state.instance.private,
|
||||||
|
federating: state => state.instance.federating,
|
||||||
|
pleromaChatMessagesAvailable: state => state.instance.pleromaChatMessagesAvailable,
|
||||||
|
pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems)
|
||||||
|
}),
|
||||||
|
pinnedList () {
|
||||||
|
return filterNavigation(
|
||||||
|
[
|
||||||
|
...Object
|
||||||
|
.entries({ ...TIMELINES })
|
||||||
|
.filter(([k]) => this.pinnedItems.has(k))
|
||||||
|
.map(([k, v]) => ({ ...v, name: k })),
|
||||||
|
...this.lists.filter((k) => this.pinnedItems.has(k.name)),
|
||||||
|
...Object
|
||||||
|
.entries({ ...ROOT_ITEMS })
|
||||||
|
.filter(([k]) => this.pinnedItems.has(k))
|
||||||
|
.map(([k, v]) => ({ ...v, name: k }))
|
||||||
|
],
|
||||||
|
{
|
||||||
|
hasChats: this.pleromaChatMessagesAvailable,
|
||||||
|
isFederating: this.federating,
|
||||||
|
isPrivate: this.private,
|
||||||
|
currentUser: this.currentUser
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default NavPanel
|
@ -0,0 +1,64 @@
|
|||||||
|
<template>
|
||||||
|
<span class="NavigationPins">
|
||||||
|
<router-link
|
||||||
|
v-for="item in pinnedList" :key="item.name" class="pinned-item"
|
||||||
|
:to="item.routeObject || { name: (currentUser || item.anon) ? item.route : item.anonRoute, params: { username: currentUser.screen_name } }"
|
||||||
|
>
|
||||||
|
<FAIcon
|
||||||
|
v-if="item.icon"
|
||||||
|
fixed-width
|
||||||
|
:icon="item.icon"
|
||||||
|
/>
|
||||||
|
<span
|
||||||
|
v-if="item.iconLetter"
|
||||||
|
class="iconLetter fa-scale-110 fa-old-padding"
|
||||||
|
>{{ item.iconLetter }}</span>
|
||||||
|
<div
|
||||||
|
v-if="item.badgeGetter && getters[item.badgeGetter]"
|
||||||
|
class="alert-dot"
|
||||||
|
/>
|
||||||
|
</router-link>
|
||||||
|
</span>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script src="./navigation_pins.js"></script>
|
||||||
|
|
||||||
|
<style lang="scss">
|
||||||
|
@import '../../_variables.scss';
|
||||||
|
.NavigationPins {
|
||||||
|
display: flex;
|
||||||
|
overflow: hidden;
|
||||||
|
|
||||||
|
.alert-dot {
|
||||||
|
border-radius: 100%;
|
||||||
|
height: 0.5em;
|
||||||
|
width: 0.5em;
|
||||||
|
position: absolute;
|
||||||
|
right: calc(50% - 0.25em);
|
||||||
|
top: calc(50% - 0.25em);
|
||||||
|
margin-left: 6px;
|
||||||
|
margin-top: -6px;
|
||||||
|
background-color: $fallback--cRed;
|
||||||
|
background-color: var(--badgeNotification, $fallback--cRed);
|
||||||
|
}
|
||||||
|
|
||||||
|
.pinned-item {
|
||||||
|
position: relative;
|
||||||
|
flex: 0 0 3em;
|
||||||
|
min-width: 2em;
|
||||||
|
|
||||||
|
& .svg-inline--fa,
|
||||||
|
& .iconLetter {
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
&.router-link-active {
|
||||||
|
& .svg-inline--fa,
|
||||||
|
& .iconLetter {
|
||||||
|
color: $fallback--text;
|
||||||
|
color: var(--selectedMenuText, $fallback--text);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</style>
|
Loading…
Reference in new issue