2020-06-24 20:54:36 +00:00
|
|
|
<template>
|
2020-10-16 21:02:34 +00:00
|
|
|
<aside
|
|
|
|
id="sidebar"
|
2020-11-10 23:11:24 +00:00
|
|
|
class="top-0 left-0 flex flex-col h-screen bg-panels-bg text-foreground"
|
|
|
|
:class="{ 'w-12': isSlim, 'w-64': !isSlim }"
|
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"
|
2020-11-10 23:11:24 +00:00
|
|
|
:key="link.name"
|
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"
|
|
|
|
: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-11-10 23:11:24 +00:00
|
|
|
<span
|
|
|
|
class="ml-5 overflow-hidden capitalize whitespace-no-wrap main-tablinks-text"
|
|
|
|
:class="{ hidden: isSlim }"
|
|
|
|
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-11-10 23:11:24 +00:00
|
|
|
class="absolute 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-11-10 23:11:24 +00:00
|
|
|
<span
|
|
|
|
id="theme_selector"
|
|
|
|
class="flex h-12 mt-5"
|
|
|
|
role="link"
|
|
|
|
aria-label="theme selector"
|
|
|
|
:class="{ 'inline-grid gap-2': isSlim }"
|
|
|
|
>
|
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>
|
2020-11-10 23:11:24 +00:00
|
|
|
<div
|
|
|
|
id="theme_togglers"
|
|
|
|
class="relative flex items-center w-full justify-evenly"
|
|
|
|
:class="{ 'inline-grid gap-2': isSlim }"
|
|
|
|
>
|
2020-07-06 17:02:03 +00:00
|
|
|
<div
|
2020-11-10 23:11:24 +00:00
|
|
|
v-for="theme of THEMES"
|
2020-07-18 20:44:27 +00:00
|
|
|
:key="theme"
|
2020-11-10 23:11:24 +00:00
|
|
|
class="w-6 h-6 border rounded-full cursor-pointer theme_toggler border-grayscale-500 gap"
|
|
|
|
:class="[{ 'theme_toggler--active': currentTheme === theme }, `theme_toggler--${theme}`]"
|
|
|
|
@click="currentTheme = theme"
|
|
|
|
/>
|
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-10-13 19:07:56 +00:00
|
|
|
#update-notification {
|
|
|
|
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-11-10 23:11:24 +00:00
|
|
|
import { computed, defineComponent, reactive, toRefs } from '@vue/composition-api'
|
|
|
|
|
|
|
|
import { links } from '@/data/sidebar'
|
2020-10-13 17:31:51 +00:00
|
|
|
import { socket } from '@/utils/socket'
|
2020-11-10 23:11:24 +00:00
|
|
|
import { useTheme } from '@/use/theme'
|
2020-10-13 17:31:51 +00:00
|
|
|
|
2020-11-10 23:11:24 +00:00
|
|
|
export default defineComponent({
|
|
|
|
setup(props, ctx) {
|
|
|
|
const state = reactive({
|
2020-09-17 19:17:53 +00:00
|
|
|
activeTablink: 'home',
|
2020-10-13 19:07:56 +00:00
|
|
|
updateAvailable: false,
|
2020-11-10 23:11:24 +00:00
|
|
|
links
|
2020-09-17 19:17:53 +00:00
|
|
|
})
|
2020-11-10 23:11:24 +00:00
|
|
|
const { THEMES, currentTheme } = useTheme()
|
2020-10-13 17:31:51 +00:00
|
|
|
|
|
|
|
/* === Add update notification near info === */
|
2020-10-13 19:07:56 +00:00
|
|
|
socket.on('updateAvailable', () => {
|
2020-11-10 23:11:24 +00:00
|
|
|
state.updateAvailable = true
|
2020-10-13 17:31:51 +00:00
|
|
|
})
|
2020-07-06 17:02:03 +00:00
|
|
|
|
2020-11-10 23:11:24 +00:00
|
|
|
ctx.root.$router.afterEach((to, from) => {
|
|
|
|
const linkInSidebar = state.links.find(link => link.routerName === to.name)
|
2020-07-06 17:02:03 +00:00
|
|
|
|
2020-11-10 23:11:24 +00:00
|
|
|
if (!linkInSidebar) return
|
2020-07-06 17:02:03 +00:00
|
|
|
|
2020-11-10 23:11:24 +00:00
|
|
|
state.activeTablink = linkInSidebar.name
|
|
|
|
})
|
2020-07-06 17:02:03 +00:00
|
|
|
|
2020-11-10 23:11:24 +00:00
|
|
|
return {
|
|
|
|
...toRefs(state),
|
|
|
|
THEMES,
|
|
|
|
currentTheme,
|
|
|
|
isSlim: computed(() => ctx.root.$store.getters.getSlimSidebar)
|
2020-07-06 17:02:03 +00:00
|
|
|
}
|
2020-06-24 20:54:36 +00:00
|
|
|
}
|
2020-11-10 23:11:24 +00:00
|
|
|
})
|
2020-06-24 20:54:36 +00:00
|
|
|
</script>
|