diff options
| author | Henry Jameson <me@hjkos.com> | 2022-08-11 21:56:30 +0300 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2022-08-11 21:56:30 +0300 |
| commit | 3a16a59f37b9b637bb4cbc1c3575810a65515cbc (patch) | |
| tree | 291021eaf0c3630c7b29b97481ae3fe5f24a0547 /src/components/navigation/navigation_entry.js | |
| parent | 9e453372b37dde652c054c13febb97bb40bc1814 (diff) | |
navigation refactored, used in mobile nav as well
Diffstat (limited to 'src/components/navigation/navigation_entry.js')
| -rw-r--r-- | src/components/navigation/navigation_entry.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/components/navigation/navigation_entry.js b/src/components/navigation/navigation_entry.js new file mode 100644 index 00000000..09c216ed --- /dev/null +++ b/src/components/navigation/navigation_entry.js @@ -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 |
