From 3dfc9cf9e2dabbca48f66bcd0d4dd0cf562aec35 Mon Sep 17 00:00:00 2001
From: Fuwn <contact@fuwn.me>
Date: Wed, 10 Jan 2024 23:59:45 -0800
Subject: feat(calculation): invert smart calculation option

---
 src/lib/Settings/SettingCheckboxToggle.svelte | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

(limited to 'src/lib/Settings/SettingCheckboxToggle.svelte')

diff --git a/src/lib/Settings/SettingCheckboxToggle.svelte b/src/lib/Settings/SettingCheckboxToggle.svelte
index 0cfbbd8e..87f5b330 100644
--- a/src/lib/Settings/SettingCheckboxToggle.svelte
+++ b/src/lib/Settings/SettingCheckboxToggle.svelte
@@ -14,6 +14,9 @@
 	export let onChange: () => void = () => {
 		return;
 	};
+	export let invert = false;
+
+	$: checked = invert ? !$settings[setting] : $settings[setting];
 
 	// const toggler = (key: keyof Settings) => [
 	// 	() =>
@@ -35,13 +38,14 @@
 	// ];
 
 	const check = (e: Event & { currentTarget: EventTarget & HTMLInputElement }): void => {
-		settings.setKey(setting, (e.target as HTMLInputElement).checked);
+		const checked = (e.target as HTMLInputElement).checked;
 
+		settings.setKey(setting, invert ? !checked : checked);
 		onChange();
 	};
 </script>
 
-<input type="checkbox" on:change={check} bind:checked={$settings[setting]} />
+<input type="checkbox" on:change={check} bind:checked />
 
 <span
 	on:click={() => ($settings[setting] = !$settings[setting])}
-- 
cgit v1.2.3

