Skip to content

Commit

Permalink
Merge pull request #32 from SafeExamBrowser/darkmodelogintoggle
Browse files Browse the repository at this point in the history
SEBSP-99 persistent theme toggle state, some theme color fixes
  • Loading branch information
NadimETH authored Mar 12, 2024
2 parents 05d416e + 4fbc699 commit a80b25d
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 21 deletions.
12 changes: 3 additions & 9 deletions client/src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,7 @@
</script>

<style>
.subtitle-color{
color: black;
}
.text-decoration-underline a:visited {
color: #2196F3 !important;
}
.text-decoration-underline a:visited {
color: #2196F3 !important;
}
</style>
25 changes: 20 additions & 5 deletions client/src/components/layout/ContainerLayout.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<template>

<v-navigation-drawer v-model="drawer" class="d-none d-sm-flex">

<!--page title with logo-->
<v-sheet class="pa-4">
<a href="/start" class="text-decoration-none text-black">
<v-img max-height="100" src="/img/seb-logo-no-border.png" alt="Logo ETH Zürich"></v-img>
<div class="app-title text-h6">{{ $t("navigation.title") }}</div>
<div class="app-title text-h6 text-title">{{ $t("navigation.title") }}</div>
</a>
</v-sheet>

Expand Down Expand Up @@ -110,6 +109,13 @@
</v-btn-toggle>
</v-list-item>

<v-list-item>
<v-btn-toggle v-model="themeToggle" variant="text" mandatory>
<v-btn icon="mdi-white-balance-sunny"></v-btn>
<v-btn icon="mdi-weather-night"></v-btn>
</v-btn-toggle>
</v-list-item>

<v-divider></v-divider>

<v-list-item class="text-decoration-underline text-blue mx-auto" @click="authStore.logout()">
Expand Down Expand Up @@ -138,6 +144,7 @@
import { useAppBarStore, useAuthStore, useUserAccountStore } from "@/store/app";
import * as userAccountViewService from "@/services/component-services/userAccountViewService";
import { useRoute } from "vue-router";
import { useTheme } from "vuetify";
import { useI18n } from "vue-i18n";
//navigation
Expand All @@ -152,6 +159,11 @@
const authStore = useAuthStore();
const userAccountStore = useUserAccountStore();
//theme
const theme = useTheme();
const localstorageTheme: string | null = localStorage.getItem("theme");
theme.global.name.value = localstorageTheme ?? theme.global.name.value ?? "light";
const themeToggle = ref<number>(theme.global.name.value === "dark" ? 1 : 0);
//gallery view
const gridSizes: GridSize[] = [
Expand All @@ -165,16 +177,20 @@
//i18n
const { locale } = useI18n();
const localStorageLocale: string | null = localStorage.getItem("locale");
locale.value = localStorageLocale ?? "en";
const languageToggle = ref<number>(locale.value === "en" ? 0 : 1);
//watchers
watch(languageToggle, () => {
locale.value = languageToggle.value === 0 ? "en" : "de";
localStorage.setItem("locale", locale.value);
});
watch(themeToggle, () => {
theme.global.name.value = themeToggle.value === 0 ? "light" : "dark";
localStorage.setItem("theme", theme.global.name.value);
});
//methods
function changeGridSize(gridSize: GridSize){
Expand All @@ -184,7 +200,6 @@
async function userMenuOpened(){
await userAccountViewService.setPersonalUserAccount();
}
</script>

<style scoped>
Expand Down
19 changes: 14 additions & 5 deletions client/src/components/views/LoginPage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<v-card class="pa-10">
<div class="d-flex ml-15 mr-15">
<img src="/img/logo.svg" alt="Logo ETH Zürich" />
<img src="/img/logo.svg" :class="isDark ? 'invert' : ''" alt="Logo ETH Zürich" />
</div>

<div class="mt-10">
Expand All @@ -22,7 +22,7 @@
Sign in
</v-card-title>
<v-card-subtitle>
<span class="subtitle-color">
<span class="text-subtitle">
Please fill the form to sign in to your SEB screen proctoring account.
</span>
</v-card-subtitle>
Expand Down Expand Up @@ -88,10 +88,11 @@
</template>

<script setup lang="ts">
import { ref } from "vue";
import { ref, computed } from "vue";
import * as authenticationService from "@/services/api-services/authenticationService";
import {navigateTo} from "@/router/navigation";
import { useLoadingStore, useAuthStore, useSettingsStore } from "@/store/app";
import { useTheme } from "vuetify";
const username = ref("");
const password = ref("");
Expand All @@ -104,6 +105,13 @@
const loadingStore = useLoadingStore();
const settingsStore = useSettingsStore();
//theme
const theme = useTheme();
const localStorageTheme: string | null = localStorage.getItem("theme");
theme.global.name.value = localStorageTheme ?? theme.global.name.value ?? "light";
const isDark = computed<boolean>(() => theme.global.current.value.dark);
async function signIn(){
loadingStore.isLoading = true;
Expand Down Expand Up @@ -133,7 +141,8 @@
</script>


<style scoped>
.invert{
filter: invert(1);
}
</style>
8 changes: 6 additions & 2 deletions client/src/plugins/vuetify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,18 @@ export default createVuetify({
colors: {
primary: "#215CAF",
secondary: "#5CBBF6",
blue: "#2196F3"
blue: "#2196F3",
title: "#000000",
subtitle: "#000000",
// background: "#eef5f9",
// surface: "#4D7DBF"
},
},
dark: {
colors: {
primary: "#ffff00",
primary: "#2196F3",
title: "#ffffff",
subtitle: "#ffffff",
}
},
tableTheme: {
Expand Down

0 comments on commit a80b25d

Please sign in to comment.