-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: implement option to save a user default config
Need to add tests and a button to apply user config to current sheet
- Loading branch information
1 parent
7af4efe
commit bfc8bd6
Showing
5 changed files
with
94 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<script lang="ts"> | ||
import { Button } from "carbon-components-svelte"; | ||
import CheckmarkOutline from "carbon-icons-svelte/lib/CheckmarkOutline.svelte"; | ||
import { type Config, configsEqual, getDefaultConfig } from "./sheet/Sheet"; | ||
import { config, userDefaultConfig } from "./stores"; | ||
import { set } from 'idb-keyval'; | ||
async function setDefaultConfig() { | ||
let saveError = false; | ||
try { | ||
await set('defaultConfig', $config); | ||
} catch (e) { | ||
saveError = true; | ||
} | ||
if (saveError) { | ||
$userDefaultConfig = getDefaultConfig(); | ||
} else { | ||
$userDefaultConfig = {...$config}; | ||
} | ||
} | ||
$: configsMatch = configsEqual($config, $userDefaultConfig) | ||
</script> | ||
|
||
<style> | ||
</style> | ||
|
||
<Button | ||
kind="tertiary" | ||
on:click={setDefaultConfig} | ||
icon={configsMatch ? CheckmarkOutline : null} | ||
> | ||
Use as Default Sheet Config | ||
</Button> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters