pleroma-fe/src/components/desktop_nav/desktop_nav.js

129 lines
3.1 KiB
JavaScript
Raw Normal View History

2026-01-08 17:26:52 +02:00
import SearchBar from 'components/search_bar/search_bar.vue'
2026-01-29 15:11:47 +02:00
import { mapActions, mapState } from 'pinia'
2026-01-08 17:26:52 +02:00
2026-01-29 20:40:00 +02:00
import ConfirmModal from '../confirm_modal/confirm_modal.vue'
import { useInstanceStore } from 'src/stores/instance.js'
2026-01-08 17:26:52 +02:00
import { useInterfaceStore } from 'src/stores/interface'
import { library } from '@fortawesome/fontawesome-svg-core'
import {
faBell,
faBullhorn,
faCog,
2026-01-06 16:23:17 +02:00
faComments,
faHome,
2026-01-06 16:22:52 +02:00
faInfoCircle,
2026-01-06 16:23:17 +02:00
faSearch,
faSignInAlt,
faSignOutAlt,
faTachometerAlt,
faUserPlus,
} from '@fortawesome/free-solid-svg-icons'
library.add(
faSignInAlt,
faSignOutAlt,
faHome,
faComments,
faBell,
faUserPlus,
faBullhorn,
faSearch,
faTachometerAlt,
faCog,
2026-01-06 16:22:52 +02:00
faInfoCircle,
)
export default {
components: {
2022-02-09 16:51:13 -05:00
SearchBar,
2026-01-06 16:22:52 +02:00
ConfirmModal,
},
data: () => ({
searchBarHidden: true,
2026-01-06 16:22:52 +02:00
supportsMask:
window.CSS &&
window.CSS.supports &&
(window.CSS.supports('mask-size', 'contain') ||
window.CSS.supports('-webkit-mask-size', 'contain') ||
window.CSS.supports('-moz-mask-size', 'contain') ||
window.CSS.supports('-ms-mask-size', 'contain') ||
2026-01-06 16:22:52 +02:00
window.CSS.supports('-o-mask-size', 'contain')),
showingConfirmLogout: false,
}),
computed: {
2026-01-06 16:22:52 +02:00
enableMask() {
2026-01-29 13:44:33 +02:00
return this.supportsMask && this.logoMask
2026-01-06 16:22:52 +02:00
},
logoStyle() {
return {
2026-01-06 16:22:52 +02:00
visibility: this.enableMask ? 'hidden' : 'visible',
}
},
2026-01-06 16:22:52 +02:00
logoMaskStyle() {
2022-07-31 12:35:48 +03:00
return this.enableMask
? {
2026-01-29 13:44:33 +02:00
'mask-image': `url(${this.logo})`,
2022-07-31 12:35:48 +03:00
}
: {
2026-01-06 16:22:52 +02:00
'background-color': this.enableMask ? '' : 'transparent',
2022-07-31 12:35:48 +03:00
}
},
2026-01-06 16:22:52 +02:00
logoBgStyle() {
return Object.assign(
{
2026-01-29 13:44:33 +02:00
margin: `${this.logoMargin} 0`,
2026-01-06 16:22:52 +02:00
opacity: this.searchBarHidden ? 1 : 0,
},
this.enableMask
? {}
: {
'background-color': this.enableMask ? '' : 'transparent',
},
)
},
2026-01-29 13:44:33 +02:00
...mapState(useInstanceStore, ['private']),
...mapState(useInstanceStore, {
logoMask: (store) => store.instanceIdentity.logoMask,
logo: (store) => store.instanceIdentity.logo,
logoLeft: (store) => store.instanceIdentity.logoLeft,
logoMargin: (store) => store.instanceIdentity.logoMargin,
2026-01-29 15:07:00 +02:00
sitename: (store) => store.instanceIdentity.name,
2026-01-29 13:44:33 +02:00
hideSitename: (store) => store.instanceIdentity.hideSitename,
}),
2026-01-06 16:22:52 +02:00
currentUser() {
return this.$store.state.users.currentUser
},
shouldConfirmLogout() {
2022-02-09 16:51:13 -05:00
return this.$store.getters.mergedConfig.modalOnLogout
2026-01-06 16:22:52 +02:00
},
},
methods: {
2026-01-06 16:22:52 +02:00
scrollToTop() {
window.scrollTo(0, 0)
},
2026-01-06 16:22:52 +02:00
showConfirmLogout() {
2022-02-09 16:51:13 -05:00
this.showingConfirmLogout = true
},
2026-01-06 16:22:52 +02:00
hideConfirmLogout() {
2022-02-09 16:51:13 -05:00
this.showingConfirmLogout = false
},
2026-01-06 16:22:52 +02:00
logout() {
2022-02-09 16:51:13 -05:00
if (!this.shouldConfirmLogout) {
this.doLogout()
} else {
this.showConfirmLogout()
}
},
2026-01-06 16:22:52 +02:00
doLogout() {
this.$router.replace('/main/public')
this.$store.dispatch('logout')
2022-02-09 16:51:13 -05:00
this.hideConfirmLogout()
},
2026-01-06 16:22:52 +02:00
onSearchBarToggled(hidden) {
this.searchBarHidden = hidden
},
2026-01-29 15:11:47 +02:00
...mapActions(useInterfaceStore, ['openSettingsModal']),
2026-01-06 16:22:52 +02:00
},
}