web/settings: add "erase all settings" button

This commit is contained in:
dumbmoron 2024-07-20 14:01:13 +00:00
parent 720b3c5f68
commit def6e26b9f
No known key found for this signature in database
5 changed files with 46 additions and 2 deletions

View file

@ -92,5 +92,6 @@
"advanced.debug": "debug", "advanced.debug": "debug",
"advanced.debug.title": "enable debug features", "advanced.debug.title": "enable debug features",
"advanced.debug.description": "gives you access to a page with app & device info useful for debugging." "advanced.debug.description": "gives you access to a page with app & device info useful for debugging.",
"advanced.reset": "erase all settings"
} }

View file

@ -0,0 +1,22 @@
<script lang="ts">
import { t } from '$lib/i18n/translations';
import IconTrash from '@tabler/icons-svelte/IconTrash.svelte';
import { resetSettings } from '$lib/state/settings';
</script>
<button id="setting-button-reset" class="button" on:click={resetSettings}>
<IconTrash /> { $t('settings.advanced.reset') }
</button>
<style>
button {
background-color: var(--red);
color: var(--white);
width: max-content;
text-align: left;
}
button:hover {
background-color: var(--dark-red);
}
</style>

View file

@ -88,6 +88,13 @@ export function updateSetting(partial: PartialSettings) {
}); });
} }
export function resetSettings() {
update(() => {
localStorage.removeItem('settings');
return {};
});
}
export default derived( export default derived(
storedSettings, storedSettings,
$settings => mergeWithDefaults($settings) $settings => mergeWithDefaults($settings)

View file

@ -60,8 +60,10 @@
--white: #ffffff; --white: #ffffff;
--gray: #75757e; --gray: #75757e;
--blue: #2f8af9; --red: #f92f2f;
--dark-red: #df0707;
--green: #51cf5e; --green: #51cf5e;
--blue: #2f8af9;
--button: #f4f4f4; --button: #f4f4f4;
--button-hover: #e8e8e8; --button-hover: #e8e8e8;
@ -111,6 +113,13 @@
rgba(0, 0, 0, 0) 96%, rgba(0, 0, 0, 0) 96%,
rgba(0, 0, 0, 0.9) 100% rgba(0, 0, 0, 0.9) 100%
); );
--skeleton-gradient: linear-gradient(
90deg,
var(--button),
var(--button-hover),
var(--button)
);
} }
:global([data-theme="dark"]) { :global([data-theme="dark"]) {

View file

@ -3,6 +3,7 @@
import SettingsCategory from "$components/settings/SettingsCategory.svelte"; import SettingsCategory from "$components/settings/SettingsCategory.svelte";
import SettingsToggle from "$components/buttons/SettingsToggle.svelte"; import SettingsToggle from "$components/buttons/SettingsToggle.svelte";
import ResetSettingsButton from "$components/buttons/ResetSettingsButton.svelte";
</script> </script>
<SettingsCategory sectionId="debug" title={$t("settings.advanced.debug")}> <SettingsCategory sectionId="debug" title={$t("settings.advanced.debug")}>
@ -13,3 +14,7 @@
description={$t("settings.advanced.debug.description")} description={$t("settings.advanced.debug.description")}
/> />
</SettingsCategory> </SettingsCategory>
<SettingsCategory sectionId="settings" title={$t("tabs.settings")}>
<ResetSettingsButton />
</SettingsCategory>