Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
6 KB
Referenced Files
None
Subscribers
None
diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js
index 1a7832afe0..fdbdcac3ce 100644
--- a/src/components/navigation/navigation_entry.js
+++ b/src/components/navigation/navigation_entry.js
@@ -1,66 +1,73 @@
import { mapState } from 'pinia'
import { routeTo } from 'src/components/navigation/navigation.js'
import OptionalRouterLink from 'src/components/optional_router_link/optional_router_link.vue'
import { useAnnouncementsStore } from 'src/stores/announcements.js'
import { useChatsStore } from 'src/stores/chats.js'
import { useDraftsStore } from 'src/stores/drafts.js'
import { useFollowRequestsStore } from 'src/stores/follow_requests.js'
import { useSyncConfigStore } from 'src/stores/sync_config.js'
import { useUsersStore } from 'src/stores/users.js'
import { library } from '@fortawesome/fontawesome-svg-core'
import { faThumbtack } from '@fortawesome/free-solid-svg-icons'
library.add(faThumbtack)
const NavigationEntry = {
- props: ['item', 'showPin'],
+ inheritAttrs: false,
+ props: {
+ item: {
+ type: Object,
+ required: true,
+ },
+ showPin: Boolean
+ },
components: {
OptionalRouterLink,
},
- methods: {
- isPinned(value) {
- return this.pinnedItems.has(value)
- },
- togglePin(value) {
- if (this.isPinned(value)) {
- useSyncConfigStore().removeCollectionPreference({
- path: 'collections.pinnedNavItems',
- value,
- })
- } else {
- useSyncConfigStore().addCollectionPreference({
- path: 'collections.pinnedNavItems',
- value,
- })
- }
- useSyncConfigStore().pushSyncConfig()
- },
- },
computed: {
routeTo() {
return routeTo(this.item, this.currentUser)
},
badges() {
return {
drafts: this.draftsCount,
unreadAnnouncements: this.unreadAnnouncementsCount,
followRequests: this.followRequestsCount,
unreadChats: this.unreadChatsCount,
}
},
...mapState(useAnnouncementsStore, ['unreadAnnouncementsCount']),
...mapState(useDraftsStore, ['draftsCount']),
...mapState(useUsersStore, ['currentUser']),
...mapState(useChatsStore, ['unreadChatsCount']),
...mapState(useFollowRequestsStore, ['followRequestsCount']),
...mapState(useSyncConfigStore, {
pinnedItems: (store) =>
new Set(store.prefsStorage.collections.pinnedNavItems),
}),
},
+ methods: {
+ isPinned(value) {
+ return this.pinnedItems.has(value)
+ },
+ togglePin(value) {
+ if (this.isPinned(value)) {
+ useSyncConfigStore().removeCollectionPreference({
+ path: 'collections.pinnedNavItems',
+ value,
+ })
+ } else {
+ useSyncConfigStore().addCollectionPreference({
+ path: 'collections.pinnedNavItems',
+ value,
+ })
+ }
+ useSyncConfigStore().pushSyncConfig()
+ },
+ },
}
export default NavigationEntry
diff --git a/src/components/navigation/navigation_entry.vue b/src/components/navigation/navigation_entry.vue
index 4b42e63cb9..d010e7c4cf 100644
--- a/src/components/navigation/navigation_entry.vue
+++ b/src/components/navigation/navigation_entry.vue
@@ -1,140 +1,140 @@
<template>
<OptionalRouterLink
v-slot="{ isActive, href, navigate } = {}"
:to="routeTo"
>
<li
class="NavigationEntry menu-item"
:class="{ '-active': isActive }"
:aria-label="item.labelRaw ?? $t(item.label)"
- v-bind="$attrs"
>
<component
:is="routeTo ? 'a' : 'button'"
class="main-link"
:href="href"
@click="navigate"
+ v-bind="$attrs"
>
<span>
<FAIcon
v-if="item.icon"
fixed-width
class="fa-scale-110 menu-icon"
:icon="item.icon"
/>
</span>
<img
v-if="item.iconEmojiUrl"
class="menu-icon iconEmoji iconEmoji-image"
:src="item.iconEmojiUrl"
:alt="item.iconEmoji"
:title="item.iconEmoji"
>
<span
v-else-if="item.iconEmoji"
class="menu-icon iconEmoji"
>
<span>
{{ item.iconEmoji }}
</span>
</span>
<span
v-else-if="item.iconLetter"
class="icon iconLetter fa-scale-110 menu-icon"
>{{ item.iconLetter }}</span>
<span class="label">
{{ item.labelRaw || $t(item.label) }}
</span>
</component>
<slot />
<div
v-if="item.badgeGetter && badges[item.badgeGetter]"
class="badge"
:class="[`-${item.badgeStyle}`]"
>
{{ badges[item.badgeGetter] }}
</div>
<button
v-if="showPin && currentUser"
type="button"
class="button-unstyled extra-button"
:title="$t(isPinned ? 'general.unpin' : 'general.pin' )"
:aria-pressed="!!isPinned"
@click.stop.prevent="togglePin(item.name)"
>
<FAIcon
v-if="showPin && currentUser"
fixed-width
class="fa-scale-110"
:class="{ 'veryfaint': !isPinned(item.name) }"
:transform="!isPinned(item.name) ? 'rotate-45' : ''"
icon="thumbtack"
/>
</button>
</li>
</OptionalRouterLink>
</template>
<script src="./navigation_entry.js"></script>
<style lang="scss">
.NavigationEntry.menu-item {
--__line-height: 2.5em;
--__horizontal-gap: 0.5em;
--__vertical-gap: 0.4em;
padding: var(--__vertical-gap) var(--__horizontal-gap);
display: grid;
grid-template-columns: 1fr;
grid-auto-columns: var(--__line-height);
grid-auto-flow: column;
gap: var(--__horizontal-gap);
align-items: baseline;
&[aria-expanded] {
padding-right: var(--__horizontal-gap);
}
.main-link {
line-height: var(--__line-height);
box-sizing: border-box;
}
.menu-icon {
line-height: var(--__line-height);
padding: 0;
width: var(--__line-height);
margin-right: var(--__horizontal-gap);
}
.timelines-chevron,
.extra-button {
line-height: var(--__line-height);
width: 100%;
padding: 0;
text-align: center;
}
.badge {
justify-self: center;
}
.iconEmoji {
display: inline-block;
text-align: center;
object-fit: contain;
vertical-align: middle;
height: var(--__line-height);
width: var(--__line-height);
> span {
font-size: 1.5rem;
}
}
img.iconEmoji {
padding: 0.25rem;
box-sizing: border-box;
}
}
</style>

File Metadata

Mime Type
text/x-diff
Expires
Sun, Nov 1, 9:16 PM (13 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1803339
Default Alt Text
(6 KB)

Event Timeline