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-10-16 21:02:34 +00:00
|
|
|
role="navigation"
|
|
|
|
aria-label="sidebar"
|
|
|
|
>
|
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>
|
2020-06-29 16:10:55 +00:00
|
|
|
<div id="network-status" :class="{ online: appOnline, offline: !appOnline }">
|
|
|
|
<i v-if="appOnline" class="material-icons">wifi</i>
|
|
|
|
<i v-else class="material-icons">
|
2020-06-29 16:49:33 +00:00
|
|
|
<!-- wifi_off icon not working, maybe need to include it? -->
|
2020-06-29 16:10:55 +00:00
|
|
|
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24">
|
|
|
|
<path d="M24 .01c0-.01 0-.01 0 0L0 0v24h24V.01zM0 0h24v24H0V0zm0 0h24v24H0V0z" fill="none" />
|
|
|
|
<path
|
|
|
|
d="M22.99 9C19.15 5.16 13.8 3.76 8.84 4.78l2.52 2.52c3.47-.17 6.99 1.05 9.63 3.7l2-2zm-4 4c-1.29-1.29-2.84-2.13-4.49-2.56l3.53 3.53.96-.97zM2 3.05L5.07 6.1C3.6 6.82 2.22 7.78 1 9l1.99 2c1.24-1.24 2.67-2.16 4.2-2.77l2.24 2.24C7.81 10.89 6.27 11.73 5 13v.01L6.99 15c1.36-1.36 3.14-2.04 4.92-2.06L18.98 20l1.27-1.26L3.29 1.79 2 3.05zM9 17l3 3 3-3c-1.65-1.66-4.34-1.66-6 0z"
|
|
|
|
/>
|
|
|
|
</svg>
|
|
|
|
</i>
|
|
|
|
</div>
|
2020-06-24 20:54:36 +00:00
|
|
|
</aside>
|
|
|
|
</template>
|
|
|
|
|
2020-10-17 15:52:31 +00:00
|
|
|
<style lang="scss" scoped>
|
2020-10-20 16:10:29 +00:00
|
|
|
#sidebar.slim{
|
|
|
|
width: 46px;
|
|
|
|
}
|
|
|
|
#sidebar.slim .main_tablinks_text{
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
#sidebar.slim #theme_selector, #sidebar.slim #theme_togglers{
|
|
|
|
display: inline-grid;
|
|
|
|
grid-gap: 8px;
|
|
|
|
}
|
|
|
|
|
2020-07-07 20:04:26 +00:00
|
|
|
#network-status {
|
|
|
|
display: flex;
|
|
|
|
justify-content: center;
|
|
|
|
align-items: center;
|
|
|
|
position: relative;
|
|
|
|
margin-top: auto;
|
|
|
|
bottom: 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
#network-status.online i.material-icons {
|
2020-10-16 19:42:28 +00:00
|
|
|
color: hsl(150, 76%, 34%);
|
2020-07-07 20:04:26 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#network-status.offline i.material-icons svg {
|
|
|
|
fill: red;
|
|
|
|
width: 1em;
|
|
|
|
height: 1em;
|
|
|
|
}
|
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-06-24 20:54:36 +00:00
|
|
|
export default {
|
2020-09-17 19:17:53 +00:00
|
|
|
data() {
|
|
|
|
return {
|
|
|
|
appOnline: null,
|
|
|
|
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-06-29 16:10:55 +00:00
|
|
|
mounted() {
|
2020-07-06 17:02:03 +00:00
|
|
|
/* === Online status handling === */
|
2020-06-29 16:10:55 +00:00
|
|
|
this.appOnline = navigator.onLine
|
|
|
|
|
|
|
|
window.addEventListener('online', () => {
|
|
|
|
this.appOnline = true
|
|
|
|
})
|
|
|
|
|
|
|
|
window.addEventListener('offline', () => {
|
|
|
|
this.appOnline = false
|
|
|
|
})
|
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>
|