-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathSideBar.vue
91 lines (78 loc) · 2.91 KB
/
SideBar.vue
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<template>
<div>
<!-- Mini Sidebar (LHS) -->
<nav class="flex flex-col flex-shrink-0 h-full sm:px-4 px-2 py-4 border-r dark:border-black">
<!-- Brand -->
<div class="hidden sm:flex flex-shrink-0">
<RouterLink
to="/"
class="inline-block text-2xl font-bold font-disco tracking-wider cursor-pointer"
>
<DISCO />
</RouterLink>
</div>
<!-- Mini Sidebar content-->
<div class="flex flex-col items-center justify-center flex-1 space-y-4">
<SidebarButton to="/" text="Home" id="home-icon">
<HomeIcon />
</SidebarButton>
<SidebarButton to="/list" text="DISCOllaboratives">
<TasksIcon class="w-6 h-6" id="task-icon" />
</SidebarButton>
<SidebarButton to="/create" text="Create a new DISCOllaborative">
<CreateIcon id="create-icon" />
</SidebarButton>
<SidebarButton to="/evaluate" text="Evaluate models">
<EvaluateIcon id="evaluate-icon" />
</SidebarButton>
<SidebarButton to="/information" text="More on DISCO">
<InfoIcon />
</SidebarButton>
<SidebarButton
to=""
:text="currentTheme === 'light' ? 'Switch to Dark Mode' : 'Switch to Light Mode'"
@click="toggleDarkMode"
>
<MoonIcon v-if="currentTheme === 'light'" class="theme-button" />
<SunIcon v-else class="theme-button" />
</SidebarButton>
<SidebarButton text="Show tutorial" to="" @click="showGuide">
<QuestionMarkIcon id="help-icon" />
</SidebarButton>
</div>
</nav>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted } from 'vue';
import { RouterLink } from "vue-router";
import HomeIcon from "@/assets/svg/HomeIcon.vue";
import TasksIcon from "@/assets/svg/TasksIcon.vue";
import CreateIcon from "@/assets/svg/CreateIcon.vue";
import EvaluateIcon from "@/assets/svg/EvaluateIcon.vue";
import InfoIcon from "@/assets/svg/InfoIcon.vue";
import DISCO from "@/components/simple/DISCO.vue";
import SidebarButton from "./SidebarButton.vue";
import MoonIcon from "@/assets/svg/MoonIcon.vue";
import SunIcon from "@/assets/svg/SunIcon.vue";
import QuestionMarkIcon from "@/assets/svg/QuestionMarkIcon.vue";
import { useTutorialStore } from "@/store";
const currentTheme = ref(localStorage.getItem("theme") || "light");
const tutorialStore = useTutorialStore();
// Apply the initial theme on mount
onMounted(() => {
if (currentTheme.value === 'dark') {
document.documentElement.classList.add('dark');
}
});
// Function to toggle the dark mode
const toggleDarkMode = () => {
const newTheme = currentTheme.value === 'light' ? 'dark' : 'light';
document.documentElement.classList.toggle('dark', newTheme === 'dark');
localStorage.setItem('theme', newTheme);
currentTheme.value = newTheme;
};
const showGuide = () => {
tutorialStore.toggleGuide();
};
</script>