Skip to content

Commit

Permalink
feat: preview theme appearance
Browse files Browse the repository at this point in the history
  • Loading branch information
alexey-yarmosh committed Sep 7, 2024
1 parent 8e0d9bb commit 7a56862
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion pages/settings.vue
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
<h5 class="text-lg font-bold">Interface</h5>
</div>
<div class="grow">
<!-- TODO: P3: can we automatically "preview" the theme when I click a button here without saving? the setting should revert when I leave the page/reload -->
<p class="font-bold">Theme</p>
<SelectButton
v-model="appearance"
Expand All @@ -42,6 +41,7 @@
aria-labelledby="basic"
option-label="name"
option-value="value"
@update:model-value="auth.setAppearance"
>
<template #option="slotProps">
<i :class="slotProps.option.icon"/>
Expand Down Expand Up @@ -152,6 +152,8 @@
email: email.value,
}));
lastSavedAppearance = appearance.value;
await auth.refresh();
toast.add({ severity: 'success', summary: 'Saved', detail: 'All settings saved', life: 4000 });
Expand All @@ -162,6 +164,11 @@
saveLoading.value = false;
};
// APPEARANCE
let lastSavedAppearance = user.appearance;
onUnmounted(() => auth.setAppearance(lastSavedAppearance));
// SYNC WITH GITHUB
const loadingIconId = ref<number | null>(null);
Expand Down
3 changes: 3 additions & 0 deletions store/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,5 +79,8 @@ export const useAuth = defineStore('auth', {
console.error(error);
}
},
setAppearance (appearance: AuthState['user']['appearance']) {
this.user.appearance = appearance;
},
},
});

0 comments on commit 7a56862

Please sign in to comment.