aboutsummaryrefslogtreecommitdiff
path: root/src/components/timeline_menu
diff options
context:
space:
mode:
authorHenry Jameson <me@hjkos.com>2022-08-11 21:00:27 +0300
committerHenry Jameson <me@hjkos.com>2022-08-11 21:00:27 +0300
commit77127e2a588abb5bf329506ff7e006021b086e90 (patch)
tree77e89d3e89fe1cc687bf7c3044dbe63732c0030a /src/components/timeline_menu
parent04f8c2d29d0e9c5e0341b067e5e783b90c95064b (diff)
you can now pin lists
Diffstat (limited to 'src/components/timeline_menu')
-rw-r--r--src/components/timeline_menu/timeline_menu.js16
-rw-r--r--src/components/timeline_menu/timeline_menu.vue8
-rw-r--r--src/components/timeline_menu/timeline_menu_content.js52
-rw-r--r--src/components/timeline_menu/timeline_menu_content.vue31
4 files changed, 18 insertions, 89 deletions
diff --git a/src/components/timeline_menu/timeline_menu.js b/src/components/timeline_menu/timeline_menu.js
index 5a67b0a5..d74fbf4e 100644
--- a/src/components/timeline_menu/timeline_menu.js
+++ b/src/components/timeline_menu/timeline_menu.js
@@ -1,6 +1,8 @@
import Popover from '../popover/popover.vue'
-import TimelineMenuContent from './timeline_menu_content.vue'
+import NavigationEntry from 'src/components/navigation/navigation_entry.vue'
+import { ListsMenuContent } from '../lists_menu/lists_menu_content.vue'
import { library } from '@fortawesome/fontawesome-svg-core'
+import { TIMELINES } from 'src/components/navigation/navigation.js'
import {
faChevronDown
} from '@fortawesome/free-solid-svg-icons'
@@ -22,11 +24,13 @@ export const timelineNames = () => {
const TimelineMenu = {
components: {
Popover,
- TimelineMenuContent
+ NavigationEntry,
+ ListsMenuContent
},
data () {
return {
- isOpen: false
+ isOpen: false,
+ timelinesList: Object.entries(TIMELINES).map(([k, v]) => ({ ...v, name: k }))
}
},
created () {
@@ -34,6 +38,12 @@ const TimelineMenu = {
this.$store.dispatch('setLastTimeline', this.$route.name)
}
},
+ computed: {
+ useListsMenu () {
+ const route = this.$route.name
+ return route === 'lists-timeline'
+ }
+ },
methods: {
openMenu () {
// $nextTick is too fast, animation won't play back but
diff --git a/src/components/timeline_menu/timeline_menu.vue b/src/components/timeline_menu/timeline_menu.vue
index 5ef96328..9acaff46 100644
--- a/src/components/timeline_menu/timeline_menu.vue
+++ b/src/components/timeline_menu/timeline_menu.vue
@@ -10,7 +10,10 @@
@close="() => isOpen = false"
>
<template #content>
- <TimelineMenuContent :content="timelinesList" />
+ <ListsMenuContent v-if="useListsMenu" :showPin="false" class="timelines" />
+ <ul v-else>
+ <NavigationEntry v-for="item in timelinesList" :key="item.name" :show-pin="false" :item="item" />
+ </ul>
</template>
<template #trigger>
<span class="button-unstyled title timeline-menu-title">
@@ -138,8 +141,7 @@
background-color: $fallback--lightBg;
background-color: var(--selectedMenu, $fallback--lightBg);
color: $fallback--text;
- color: var(--selectedMenuText, $fallback--text);
- --faint: var(--selectedMenuFaintText, $fallback--faint);
+ 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);
diff --git a/src/components/timeline_menu/timeline_menu_content.js b/src/components/timeline_menu/timeline_menu_content.js
deleted file mode 100644
index c5b1cff2..00000000
--- a/src/components/timeline_menu/timeline_menu_content.js
+++ /dev/null
@@ -1,52 +0,0 @@
-import { mapState } from 'vuex'
-import { library } from '@fortawesome/fontawesome-svg-core'
-import {
- faUsers,
- faGlobe,
- faBookmark,
- faEnvelope,
- faHome
-} from '@fortawesome/free-solid-svg-icons'
-
-library.add(
- faUsers,
- faGlobe,
- faBookmark,
- faEnvelope,
- faHome
-)
-
-const TimelineMenuContent = {
- props: ['content'],
- methods: {
- isPinned (item) {
- return this.pinnedItems.has(item)
- },
- togglePin (item) {
- if (this.isPinned(item)) {
- this.$store.commit('removeCollectionPreference', { path: 'collections.pinnedNavItems', value: item })
- } else {
- this.$store.commit('addCollectionPreference', { path: 'collections.pinnedNavItems', value: item })
- }
- }
- },
- computed: {
- ...mapState({
- currentUser: state => state.users.currentUser,
- privateMode: state => state.instance.private,
- federating: state => state.instance.federating,
- pinnedItems: state => new Set(state.serverSideStorage.prefsStorage.collections.pinnedNavItems)
- }),
- list () {
- return (this.content || []).filter(({ criteria, anon, anonRoute }) => {
- const set = new Set(criteria || [])
- if (!this.federating && set.has('federating')) return false
- if (this.private && set.has('!private')) return false
- if (!this.currentUser && !(anon || anonRoute)) return false
- return true
- })
- }
- }
-}
-
-export default TimelineMenuContent
diff --git a/src/components/timeline_menu/timeline_menu_content.vue b/src/components/timeline_menu/timeline_menu_content.vue
deleted file mode 100644
index 7dc76b62..00000000
--- a/src/components/timeline_menu/timeline_menu_content.vue
+++ /dev/null
@@ -1,31 +0,0 @@
-<template>
- <ul>
- <li v-for="item in list" :key="item.name">
- <router-link
- class="menu-item"
- :to="{ name: (currentUser || item.anon) ? item.route : item.anonRoute, params: { username: currentUser.screen_name } }"
- >
- <FAIcon
- fixed-width
- class="fa-scale-110 fa-old-padding "
- :icon="item.icon"
- />{{ $t(item.label) }}
- <button
- type="button"
- class="button-unstyled"
- @click.stop.prevent="togglePin(item.name)"
- >
- <FAIcon
- fixed-width
- class="fa-scale-110 fa-old-padding "
- :class="{ 'veryfaint': !isPinned(item.name) }"
- :transform="!isPinned(item.name) ? 'rotate-45' : ''"
- icon="thumbtack"
- />
- </button>
- </router-link>
- </li>
- </ul>
-</template>
-
-<script src="./timeline_menu_content.js"></script>