Add icons corresponding to bookmarked page route

This commit is contained in:
Jason Henriquez 2024-06-11 14:42:10 -05:00
parent 039fce110d
commit 85e46b5bc5
3 changed files with 44 additions and 2 deletions

View File

@ -2,7 +2,7 @@ import { defineComponent } from 'vue'
import { mapActions } from 'vuex'
import FtTooltip from '../ft-tooltip/ft-tooltip.vue'
import { isKeyboardEventKeyPrintableChar, isNullOrEmpty } from '../../helpers/strings'
import { getIconForRoute, isKeyboardEventKeyPrintableChar, isNullOrEmpty } from '../../helpers/strings'
export default defineComponent({
name: 'FtInput',
@ -330,6 +330,17 @@ export default defineComponent({
this.inputData = text
},
iconForBookmarkedPage: (pageBookmark) => {
const routeSlashIndex = pageBookmark.route.indexOf('/', 2)
let route
if (routeSlashIndex === -1) {
route = pageBookmark.route
} else {
route = pageBookmark.route.substring(0, routeSlashIndex)
}
return getIconForRoute(route) ?? ['fas', 'magnifying-glass']
},
focus() {
this.$refs.input.focus()
},

View File

@ -87,7 +87,7 @@
>
<font-awesome-icon
v-if="entry.isBookmark"
:icon="['fas', 'star']"
:icon="iconForBookmarkedPage(entry)"
class="searchResultIcon bookmarkStarIcon"
/>
<font-awesome-icon

View File

@ -53,6 +53,37 @@ export function translateWindowTitle(title, i18n) {
}
}
export function getIconForRoute(path) {
switch (path) {
case '/subscriptions':
return ['fas', 'rss']
case '/subscribedchannels':
case '/channel':
return ['fas', 'list']
case '/trending':
return ['fas', 'fire']
case '/popular':
return ['fas', 'users']
case '/userplaylists':
return ['fas', 'bookmark']
case '/history':
return ['fas', 'history']
case '/settings':
return ['fas', 'sliders-h']
case '/about':
return ['fas', 'info-circle']
case '/search':
case '/hashtag':
return ['fas', 'magnifying-glass']
case '/playlist':
return ['fas', 'bars']
case '/watch':
return ['fas', 'play']
default:
return null
}
}
/**
* Returns an appropriate default bookmark name
* for a given route.