2020-06-24 20:54:36 +00:00
|
|
|
<template>
|
2020-10-16 21:02:34 +00:00
|
|
|
<aside
|
|
|
|
id="sidebar"
|
2020-10-17 15:52:31 +00:00
|
|
|
class="top-0 left-0 flex flex-col w-64 h-screen bg-panels-bg text-foreground"
|
2020-11-10 20:55:35 +00:00
|
|
|
:class="{ slim: isSlim }"
|
2020-10-16 21:02:34 +00:00
|
|
|
role="navigation"
|
|
|
|
aria-label="sidebar"
|
2020-10-29 12:08:42 +00:00
|
|
|
ref="sidebar"
|
2020-10-16 21:02:34 +00:00
|
|
|
>
|
2020-08-31 21:07:52 +00:00
|
|
|
<router-link
|
2020-10-16 21:02:34 +00:00
|
|
|
tag="a"
|
2020-09-17 19:17:53 +00:00
|
|
|
v-for="link in links"
|
|
|
|
:key="link.id"
|
2020-10-17 15:52:31 +00:00
|
|
|
class="relative flex items-center h-16 no-underline group main_tablinks hover:bg-background-main text-foreground"
|
2020-09-17 19:17:53 +00:00
|
|
|
:id="link.id"
|
2020-10-17 15:52:31 +00:00
|
|
|
:class="{ 'bg-background-main': activeTablink === link.name }"
|
2020-09-17 19:17:53 +00:00
|
|
|
:aria-label="link.ariaLabel"
|
|
|
|
:to="{ name: link.routerName }"
|
|
|
|
@click.native="activeTablink = link.name"
|
2020-08-31 20:14:14 +00:00
|
|
|
>
|
2020-10-17 15:52:31 +00:00
|
|
|
<i
|
|
|
|
class="p-2 text-3xl material-icons side_icon group-hover:text-primary"
|
|
|
|
:class="{ 'text-primary': activeTablink === link.name }"
|
|
|
|
>
|
|
|
|
{{ link.icon }}
|
|
|
|
</i>
|
2020-10-16 21:56:53 +00:00
|
|
|
<span class="ml-5 overflow-hidden capitalize whitespace-no-wrap main_tablinks_text" style="letter-spacing: 1.3px">
|
2020-10-16 21:02:34 +00:00
|
|
|
{{ $t(link.label) }}
|
|
|
|
</span>
|
2020-10-13 19:07:56 +00:00
|
|
|
<span
|
|
|
|
v-if="link.name === 'about' && updateAvailable"
|
|
|
|
id="update-notification"
|
2020-10-16 19:42:28 +00:00
|
|
|
class="w-3 h-3 bg-red-600 rounded-full"
|
2020-10-13 19:07:56 +00:00
|
|
|
></span>
|
2020-08-31 21:07:52 +00:00
|
|
|
</router-link>
|
2020-09-17 19:17:53 +00:00
|
|
|
|
2020-10-20 16:10:29 +00:00
|
|
|
<span id="theme_selector" class="flex h-12 mt-5" role="link" aria-label="theme selector">
|
2020-10-16 21:02:34 +00:00
|
|
|
<i class="p-2 text-3xl transition-all duration-500 cursor-default material-icons side_icon side_icon--theme">
|
2020-10-17 15:52:31 +00:00
|
|
|
brush
|
2020-10-16 21:02:34 +00:00
|
|
|
</i>
|
|
|
|
<div id="theme_togglers" class="relative flex items-center w-full justify-evenly">
|
2020-07-06 17:02:03 +00:00
|
|
|
<div
|
2020-07-18 20:44:27 +00:00
|
|
|
v-for="theme of themes"
|
|
|
|
:key="theme"
|
2020-10-16 21:02:34 +00:00
|
|
|
class="w-6 h-6 border rounded-full cursor-pointer theme_toggler border-grayscale-500"
|
2020-07-18 20:44:27 +00:00
|
|
|
:class="[{ 'theme_toggler--active': activeTheme === theme }, `theme_toggler--${theme}`]"
|
|
|
|
@click="changeTheme(theme)"
|
|
|
|
></div>
|
2020-06-24 20:54:36 +00:00
|
|
|
</div>
|
|
|
|
</span>
|
|
|
|
</aside>
|
|
|
|
</template>
|
|
|
|
|
2020-10-17 15:52:31 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-11-10 20:55:35 +00:00
|
|
|
#sidebar.slim {
|
2020-10-20 16:10:29 +00:00
|
|
|
width: 46px;
|
|
|
|
}
|
2020-11-10 20:55:35 +00:00
|
|
|
|
|
|
|
#sidebar.slim .main_tablinks_text {
|
2020-10-20 16:10:29 +00:00
|
|
|
display: none;
|
|
|
|
}
|
2020-11-10 20:55:35 +00:00
|
|
|
|
|
|
|
#sidebar.slim #theme_selector,
|
|
|
|
#sidebar.slim #theme_togglers {
|
2020-10-20 16:10:29 +00:00
|
|
|
display: inline-grid;
|
|
|
|
grid-gap: 8px;
|
|
|
|
}
|
|
|
|
|
2020-10-13 19:07:56 +00:00
|
|
|
#update-notification {
|
|
|
|
position: absolute;
|
|
|
|
left: 30px;
|
|
|
|
top: 12px;
|
|
|
|
}
|
2020-10-17 15:52:31 +00:00
|
|
|
|
|
|
|
.theme_toggler {
|
|
|
|
transition: border 200ms ease-in-out;
|
|
|
|
|
|
|
|
&--active {
|
|
|
|
border-width: 3px;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--light {
|
|
|
|
background-color: #fff;
|
|
|
|
}
|
|
|
|
|
|
|
|
&--dark {
|
|
|
|
background-color: hsl(0, 0%, 8%);
|
|
|
|
}
|
|
|
|
|
|
|
|
&--purple {
|
|
|
|
background: hsl(261, 85%, 37%);
|
|
|
|
}
|
|
|
|
}
|
2020-07-07 20:04:26 +00:00
|
|
|
</style>
|
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
<script>
|
2020-10-13 17:31:51 +00:00
|
|
|
import { socket } from '@/utils/socket'
|
2020-11-10 20:55:35 +00:00
|
|
|
import { mapGetters } from 'vuex'
|
2020-10-13 17:31:51 +00:00
|
|
|
|
2020-06-24 20:54:36 +00:00
|
|
|
export default {
|
2020-09-17 19:17:53 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
activeTheme: 'light',
|
|
|
|
themes: ['purple', 'dark', 'light'],
|
|
|
|
activeTablink: 'home',
|
2020-10-13 19:07:56 +00:00
|
|
|
updateAvailable: false,
|
2020-09-17 19:17:53 +00:00
|
|
|
links: [
|
|
|
|
{
|
|
|
|
id: 'main_home_tablink',
|
|
|
|
name: 'home',
|
|
|
|
ariaLabel: 'home',
|
|
|
|
routerName: 'Home',
|
|
|
|
icon: 'home',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.home'
|
2020-09-17 19:17:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'main_search_tablink',
|
|
|
|
name: 'search',
|
|
|
|
ariaLabel: 'search',
|
|
|
|
routerName: 'Search',
|
|
|
|
icon: 'search',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.search'
|
2020-09-17 19:17:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'main_charts_tablink',
|
|
|
|
name: 'charts',
|
|
|
|
ariaLabel: 'charts',
|
|
|
|
routerName: 'Charts',
|
|
|
|
icon: 'show_chart',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.charts'
|
2020-09-17 19:17:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'main_favorites_tablink',
|
|
|
|
name: 'favorites',
|
|
|
|
ariaLabel: 'favorites',
|
|
|
|
routerName: 'Favorites',
|
|
|
|
icon: 'star',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.favorites'
|
2020-09-17 19:17:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'main_analyzer_tablink',
|
|
|
|
name: 'analyzer',
|
|
|
|
ariaLabel: 'link analyzer',
|
|
|
|
routerName: 'Link Analyzer',
|
|
|
|
icon: 'link',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.linkAnalyzer'
|
2020-09-17 19:17:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'main_settings_tablink',
|
|
|
|
name: 'settings',
|
|
|
|
ariaLabel: 'settings',
|
|
|
|
routerName: 'Settings',
|
|
|
|
icon: 'settings',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.settings'
|
2020-09-17 19:17:53 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
id: 'main_about_tablink',
|
|
|
|
name: 'about',
|
|
|
|
ariaLabel: 'info',
|
|
|
|
routerName: 'About',
|
|
|
|
icon: 'info',
|
2020-09-23 16:20:49 +00:00
|
|
|
label: 'sidebar.about'
|
2020-09-17 19:17:53 +00:00
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
},
|
2020-11-10 20:55:35 +00:00
|
|
|
computed: {
|
|
|
|
...mapGetters({
|
|
|
|
isSlim: 'getSlimSidebar'
|
|
|
|
})
|
|
|
|
},
|
2020-06-29 16:10:55 +00:00
|
|
|
mounted() {
|
2020-07-06 17:02:03 +00:00
|
|
|
/* === Current theme handling === */
|
2020-10-13 19:07:56 +00:00
|
|
|
this.activeTheme = localStorage.getItem('selectedTheme') || 'dark'
|
2020-09-17 19:17:53 +00:00
|
|
|
|
|
|
|
this.$router.afterEach((to, from) => {
|
|
|
|
const linkInSidebar = this.links.find(link => link.routerName === to.name)
|
|
|
|
|
|
|
|
if (!linkInSidebar) return
|
|
|
|
|
|
|
|
this.activeTablink = linkInSidebar.name
|
|
|
|
})
|
2020-10-13 17:31:51 +00:00
|
|
|
|
|
|
|
/* === Add update notification near info === */
|
2020-10-13 19:07:56 +00:00
|
|
|
socket.on('updateAvailable', () => {
|
|
|
|
this.updateAvailable = true
|
2020-10-13 17:31:51 +00:00
|
|
|
})
|
2020-07-06 17:02:03 +00:00
|
|
|
},
|
|
|
|
methods: {
|
|
|
|
changeTheme(newTheme) {
|
|
|
|
if (newTheme === this.activeTheme) return
|
|
|
|
|
|
|
|
this.activeTheme = newTheme
|
|
|
|
document.documentElement.setAttribute('data-theme', newTheme)
|
|
|
|
localStorage.setItem('selectedTheme', newTheme)
|
|
|
|
|
|
|
|
// Animating everything to have a smoother theme switch
|
2020-09-17 19:17:53 +00:00
|
|
|
const allElements = document.querySelectorAll('*')
|
|
|
|
|
|
|
|
allElements.forEach(el => {
|
|
|
|
el.classList.add('changing-theme')
|
2020-07-06 17:02:03 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
document.documentElement.addEventListener('transitionend', function transitionHandler() {
|
2020-09-17 19:17:53 +00:00
|
|
|
allElements.forEach(el => {
|
|
|
|
el.classList.remove('changing-theme')
|
2020-07-06 17:02:03 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
document.documentElement.removeEventListener('transitionend', transitionHandler)
|
|
|
|
})
|
|
|
|
}
|
2020-06-24 20:54:36 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|