feat: Add keyboard shortcut to swap color scheme

This commit is contained in:
Jesse Wierzbinski 2024-12-25 17:39:22 +01:00
parent 14c1dea7a5
commit 38c2ed37ec
No known key found for this signature in database

View file

@ -38,7 +38,9 @@ import { SettingIds } from "~/settings";
const appData = useAppData();
const signInAction = () => signIn(appData);
const { n } = useMagicKeys();
const colorMode = useColorMode();
const themeSetting = useSetting(SettingIds.Theme);
const { n, d } = useMagicKeys();
const activeElement = useActiveElement();
const notUsingInput = computed(
() =>
@ -57,5 +59,16 @@ watchEffect(async () => {
await new Promise((resolve) => setTimeout(resolve, 50));
useEvent("composer:open");
}
if (d?.value && !colorMode.forced) {
// Swap theme from dark to light or vice versa
if (colorMode.value === "dark") {
colorMode.preference = "light";
themeSetting.value.value = "light";
} else {
colorMode.preference = "dark";
themeSetting.value.value = "dark";
}
}
});
</script>
</script>