Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
oeyoews committed Jul 7, 2024
1 parent 8a862cb commit 08012d4
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions entrypoints/sidepanel/Sidepanel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -266,17 +266,16 @@ async function saveAuth(option: { username: string; password: string }) {
}
}
async function toggleDarkMode() {
isDarkMode.value = !isDarkMode.value;
await isDarkModeStorage.setValue(isDarkMode.value);
const DARK = 'dark';
if (isDarkMode.value) {
document.documentElement.classList.add(DARK);
} else {
document.documentElement.classList.remove(DARK);
}
}
// async function toggleDarkMode() {
// isDarkMode.value = !isDarkMode.value;
// await isDarkModeStorage.setValue(isDarkMode.value);
// const DARK = 'dark';
// if (isDarkMode.value) {
// document.documentElement.classList.add(DARK);
// } else {
// document.documentElement.classList.remove(DARK);
// }
// }
const isAppearanceTransition =
// @ts-ignore
Expand All @@ -303,6 +302,11 @@ async function toggleDark(event?: MouseEvent) {
// @ts-expect-error: Transition API
const transition = document.startViewTransition(async () => {
isDarkMode.value = !isDarkMode.value;
if (isDarkMode.value) {
document.documentElement.classList.add(DARK);
} else {
document.documentElement.classList.remove(DARK);
}
await nextTick();
});
transition.ready.then(() => {
Expand All @@ -315,19 +319,13 @@ async function toggleDark(event?: MouseEvent) {
clipPath: isDarkMode.value ? [...clipPath].reverse() : clipPath,
},
{
duration: 400,
duration: 250,
easing: 'ease-in',
pseudoElement: isDarkMode.value
? '::view-transition-old(root)'
: '::view-transition-new(root)',
}
);
if (isDarkMode.value) {
document.documentElement.classList.add(DARK);
} else {
document.documentElement.classList.remove(DARK);
}
});
}
Expand Down

0 comments on commit 08012d4

Please sign in to comment.