refactor: Optimize sidebar data loading, update font to ExtraBold, and adjust blur effects for category cards and header.

This commit is contained in:
Ben
2026-03-08 19:20:53 -07:00
parent 1093208324
commit 3ae77e02a0
4 changed files with 31 additions and 7 deletions
+23 -2
View File
@@ -2,7 +2,18 @@
import { browser } from '$app/environment';
import { onMount } from 'svelte';
import { page } from '$app/stores';
import { categories, getCalculatorsByCategory, type CalculatorDef } from '$lib/data/calculators';
import { categories } from '$lib/data/stats';
import type { CalculatorDef } from '$lib/data/calculators';
let allCalculators: CalculatorDef[] = [];
let isLoaded = false;
async function loadData() {
if (isLoaded || !browser) return;
const module = await import('$lib/data/calculators');
allCalculators = module.calculators;
isLoaded = true;
}
let expandedCategory = '';
let expandedUnits: Record<string, string> = {};
@@ -76,7 +87,12 @@
$: categoryUnitGroups = Object.entries(categories).map(([key, meta]) => {
const buckets = new Map<string, UnitBucket>();
const calcs = getCalculatorsByCategory(key);
if (!isLoaded) {
return { key, meta, units: [] };
}
const calcs = allCalculators.filter(c => c.category === key && !c.hidden);
const canonicalByPair = new Map<string, CalculatorDef>();
calcs.forEach(calc => {
@@ -161,6 +177,11 @@
}
export let open = false;
$: if (browser && (isDesktop || open)) {
loadData();
}
$: isSidebarHidden = !isDesktop && !open;
function closeSidebar() {