Theme switch cooldown (#1188)

This commit is contained in:
Nerjal Nosk
2023-06-11 13:47:08 -04:00
committed by Emma Triphora
parent d9f8746438
commit 776c16cd49

View File

@@ -25,6 +25,7 @@
<button <button
class="control-button button-transparent" class="control-button button-transparent"
title="Switch theme" title="Switch theme"
:disabled="isThemeSwitchOnHold"
@click="changeTheme" @click="changeTheme"
> >
<MoonIcon v-if="$colorMode.value === 'light'" aria-hidden="true" /> <MoonIcon v-if="$colorMode.value === 'light'" aria-hidden="true" />
@@ -186,7 +187,7 @@
<SettingsIcon aria-hidden="true" /> <SettingsIcon aria-hidden="true" />
Settings Settings
</NuxtLink> </NuxtLink>
<button class="iconified-button" @click="changeTheme"> <button class="iconified-button" :disabled="isThemeSwitchOnHold" @click="changeTheme">
<MoonIcon v-if="$colorMode.value === 'light'" class="icon" /> <MoonIcon v-if="$colorMode.value === 'light'" class="icon" />
<SunIcon v-else class="icon" /> <SunIcon v-else class="icon" />
<span class="dropdown-item__text">Change theme</span> <span class="dropdown-item__text">Change theme</span>
@@ -318,7 +319,11 @@
</a> </a>
</div> </div>
<div class="buttons"> <div class="buttons">
<button class="iconified-button raised-button" @click="changeTheme"> <button
class="iconified-button raised-button"
:disabled="isThemeSwitchOnHold"
@click="changeTheme"
>
<MoonIcon v-if="$colorMode.value === 'light'" aria-hidden="true" /> <MoonIcon v-if="$colorMode.value === 'light'" aria-hidden="true" />
<SunIcon v-else aria-hidden="true" /> <SunIcon v-else aria-hidden="true" />
Change theme Change theme
@@ -380,6 +385,7 @@ export default defineNuxtComponent({
isDropdownOpen: false, isDropdownOpen: false,
isMobileMenuOpen: false, isMobileMenuOpen: false,
isBrowseMenuOpen: false, isBrowseMenuOpen: false,
isThemeSwitchOnHold: false,
registeredSkipLink: null, registeredSkipLink: null,
hideDropdown: false, hideDropdown: false,
navRoutes: [ navRoutes: [
@@ -488,7 +494,11 @@ export default defineNuxtComponent({
} }
}, },
changeTheme() { changeTheme() {
this.isThemeSwitchOnHold = true
updateTheme(this.$colorMode.value === 'dark' ? 'light' : 'dark', true) updateTheme(this.$colorMode.value === 'dark' ? 'light' : 'dark', true)
setTimeout(() => {
this.isThemeSwitchOnHold = false
}, 1000)
}, },
}, },
}) })