Skip to content

Commit

Permalink
feat: add button to apply user default config to current sheet
Browse files Browse the repository at this point in the history
  • Loading branch information
mgreminger committed Nov 18, 2024
1 parent 28f3691 commit 37077a9
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -2820,7 +2820,7 @@ Please include a link to this sheet in the email to assist in debugging the prob
<Tabs>
<Tab label="Number Format" />
<Tab label="Default Units" />
<Tab label="Set Default" />
<Tab label="Set User Default" />
<svelte:fragment slot="content">
<TabContent>
<Checkbox
Expand Down
40 changes: 31 additions & 9 deletions src/SetDefaultConfigDialog.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import { type Config, configsEqual, getDefaultConfig, normalizeConfig } from "./sheet/Sheet";
import { config } from "./stores";
const defaultConfig = getDefaultConfig();
let userDefaultConfig: Config = getDefaultConfig();
onMount(async () => {
Expand Down Expand Up @@ -34,18 +35,39 @@
}
}
$: configsMatch = configsEqual($config, userDefaultConfig)
function useDefaultConfig() {
$config = JSON.parse(JSON.stringify(userDefaultConfig));
}
$: configsMatch = configsEqual($config, userDefaultConfig);
$: userConfigIsDefaultConfig = configsEqual(userDefaultConfig, defaultConfig);
</script>

<style>
div.container {
display: flex;
flex-direction: column;
gap: 20px;
}
</style>

<Button
kind="tertiary"
on:click={setDefaultConfig}
icon={configsMatch ? CheckmarkOutline : null}
>
Use as Default Sheet Config
</Button>
<div class="container">
<Button
kind="tertiary"
on:click={setDefaultConfig}
icon={configsMatch ? CheckmarkOutline : null}
>
Use This Sheet's Config as User Default Config
</Button>

{#if !configsMatch && !userConfigIsDefaultConfig}
<Button
kind="tertiary"
on:click={useDefaultConfig}
icon={configsMatch ? CheckmarkOutline : null}
>
Apply User Default Config to This Sheet
</Button>
{/if}
</div>

0 comments on commit 37077a9

Please sign in to comment.