From 19eddc198d4cd415c71167aa3da6d857593f0898 Mon Sep 17 00:00:00 2001 From: Denis Donici Date: Fri, 7 Mar 2025 21:41:57 +0200 Subject: [PATCH] Add C/F units --- bun.lock | 3 +++ package.json | 1 + src/lib/components/ComboBox.svelte | 17 ++++++--------- src/lib/components/Navbar.svelte | 34 ++++++++++++++++++++++++++++++ src/lib/helpers/stores.ts | 6 ++++++ src/lib/helpers/utils.ts | 3 +++ src/lib/types.ts | 7 +++++- src/routes/+page.server.ts | 8 +++---- src/routes/+page.svelte | 34 ++++++++++++++++++++++++------ 9 files changed, 92 insertions(+), 21 deletions(-) create mode 100644 src/lib/components/Navbar.svelte create mode 100644 src/lib/helpers/stores.ts diff --git a/bun.lock b/bun.lock index 5774b07..4959d24 100644 --- a/bun.lock +++ b/bun.lock @@ -29,6 +29,7 @@ "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.22.5", "svelte-check": "^4.1.5", + "svelte-persisted-store": "^0.12.0", "tailwindcss": "^4.0.11", "typescript": "^5.8.2", "typescript-eslint": "^8.26.0", @@ -561,6 +562,8 @@ "svelte-eslint-parser": ["svelte-eslint-parser@1.0.1", "", { "dependencies": { "eslint-scope": "^8.2.0", "eslint-visitor-keys": "^4.0.0", "espree": "^10.0.0", "postcss": "^8.4.49", "postcss-scss": "^4.0.9", "postcss-selector-parser": "^7.0.0" }, "peerDependencies": { "svelte": "^3.37.0 || ^4.0.0 || ^5.0.0" }, "optionalPeers": ["svelte"] }, "sha512-JjdEMXOJqy+dxeaElxbN+meTOtVpHfLnq9VGpiTAOLgM0uHO+ogmUsA3IFgx0x3Wl15pqTZWycCikcD7cAQN/g=="], + "svelte-persisted-store": ["svelte-persisted-store@0.12.0", "", { "peerDependencies": { "svelte": "^3.48.0 || ^4 || ^5" } }, "sha512-BdBQr2SGSJ+rDWH8/aEV5GthBJDapVP0GP3fuUCA7TjYG5ctcB+O9Mj9ZC0+Jo1oJMfZUd1y9H68NFRR5MyIJA=="], + "tailwindcss": ["tailwindcss@4.0.11", "", {}, "sha512-GZ6+tNwieqvpFLZfx2tkZpfOMAK7iumbOJOLmd6v8AcYuHbjUb+cmDRu6l+rFkIqarh5FfLbCSRJhegcVdoPng=="], "tapable": ["tapable@2.2.1", "", {}, "sha512-GNzQvQTOIP6RyTfE2Qxb8ZVlNmw0n88vp1szwWRimP02mnTsx3Wtn5qRdqY9w2XduFNUgvOwhNnQsjwCp+kqaQ=="], diff --git a/package.json b/package.json index aaf2d03..ce42dc9 100644 --- a/package.json +++ b/package.json @@ -24,6 +24,7 @@ "prettier-plugin-tailwindcss": "^0.6.11", "svelte": "^5.22.5", "svelte-check": "^4.1.5", + "svelte-persisted-store": "^0.12.0", "tailwindcss": "^4.0.11", "typescript": "^5.8.2", "typescript-eslint": "^8.26.0", diff --git a/src/lib/components/ComboBox.svelte b/src/lib/components/ComboBox.svelte index 7c83e18..e2bfdb0 100644 --- a/src/lib/components/ComboBox.svelte +++ b/src/lib/components/ComboBox.svelte @@ -14,19 +14,18 @@ }; let { options, onSelect, onClear, disabledItems, selectedOptionId }: ComboBoxProps = $props(); - $effect(() => console.log(selectedOptionId)); let focused = $state(false); let selectSet = $state(false); let inputElement: HTMLInputElement; let dropdownElement: HTMLUListElement | null = $state(null); let emoji: string = $state(''); - + const ifOptionSelected = (id: number | null) => { let textValue = ''; - if (id) { - const value = options.find((option) => option.id === id) - if(value) { + if (id) { + const value = options.find((option) => option.id === id); + if (value) { emoji = 'emoji' in value ? (value.emoji ?? '') : ''; textValue = 'name' in value ? value.name : ''; selectSet = true; @@ -34,9 +33,7 @@ } return textValue; }; - - - + let filterInput = $state(ifOptionSelected(selectedOptionId)); let searcher = $state(new FuzzySearch(options, ['name'], { caseSensitive: false, sort: true })); @@ -85,8 +82,8 @@ }); -