@@ -8,6 +8,16 @@ const description = 'Free online calculators for everyday math problems. Calcula
88
99// All calculators with categories
1010const calculators = [
11+ {
12+ title: ' UK £100k Tax Trap' ,
13+ description: ' Calculate how the 60% marginal rate affects you and find optimal pension contributions.' ,
14+ href: ' /calculators/uk-100k-tax-trap-calculator' ,
15+ icon: ' chart' ,
16+ color: ' coral' ,
17+ category: ' Finance' ,
18+ country: ' UK' ,
19+ mostUsed: true ,
20+ },
1121 {
1222 title: ' Go Full-Time Calculator' ,
1323 description: ' Calculate when you can quit your job to pursue freelancing or side hustle full-time.' ,
@@ -372,16 +382,6 @@ const calculators = [
372382 category: ' Everyday' ,
373383 mostUsed: false ,
374384 },
375- {
376- title: ' UK £100k Tax Trap' ,
377- description: ' Calculate how the 60% marginal rate affects you and find optimal pension contributions.' ,
378- href: ' /calculators/uk-100k-tax-trap-calculator' ,
379- icon: ' chart' ,
380- color: ' coral' ,
381- category: ' Finance' ,
382- country: ' UK' ,
383- mostUsed: false ,
384- },
385385 {
386386 title: ' UK Stamp Duty Calculator' ,
387387 description: ' Calculate SDLT, LBTT, or LTT with first-time buyer relief and additional property surcharge.' ,
@@ -1139,19 +1139,6 @@ const categoryColors: Record<string, string> = {
11391139 </div >
11401140 </div >
11411141
1142- <!-- Mobile Quick Access - Popular calculators for instant access -->
1143- <div class =" md:hidden mt-3 animate-slide-up delay-100" >
1144- <div class =" flex gap-2 overflow-x-auto pb-2 -mx-2 px-2 scrollbar-hide" >
1145- { calculators .filter (c => c .mostUsed ).slice (0 , 5 ).map (calc => (
1146- <a
1147- href = { calc .href }
1148- class = " flex-shrink-0 px-3 py-2 rounded-xl bg-[var(--color-charcoal)] border border-white/10 hover:border-[var(--color-accent)]/50 transition-colors"
1149- >
1150- <span class = " text-xs font-medium text-[var(--color-cream)] whitespace-nowrap" >{ calc .title .replace (' Calculator' , ' ' )} </span >
1151- </a >
1152- ))}
1153- </div >
1154- </div >
11551142 </div >
11561143 </section >
11571144
@@ -1469,7 +1456,7 @@ const categoryColors: Record<string, string> = {
14691456
14701457<script >
14711458 // Calculator filtering, search, favorites, and recently used functionality
1472- document.addEventListener('DOMContentLoaded', () => {
1459+ function initCalculatorPage() {
14731460 const filterButtons = document.querySelectorAll('.category-btn');
14741461 const calculatorCards = document.querySelectorAll('.calculator-card');
14751462 const emptyState = document.getElementById('empty-state');
@@ -1488,6 +1475,60 @@ const categoryColors: Record<string, string> = {
14881475 const activeFilterBadge = document.getElementById('active-filter-badge');
14891476 let filtersExpanded = false;
14901477
1478+ // Reset filter panel state on page load (fixes back navigation issue)
1479+ function resetFilterState() {
1480+ filtersExpanded = false;
1481+ filterPanel?.classList.add('hidden');
1482+ filterPanel?.classList.remove('flex', 'flex-wrap');
1483+ regionFilterPanel?.classList.add('hidden');
1484+ regionFilterPanel?.classList.remove('flex', 'flex-wrap');
1485+ filterChevron?.classList.remove('rotate-180');
1486+
1487+ // Reset all filter buttons to default state
1488+ filterButtons.forEach(btn => {
1489+ const category = btn.getAttribute('data-category');
1490+ if (category === 'All') {
1491+ btn.classList.remove('text-[var(--color-subtle)]', 'bg-transparent', 'border-white/10');
1492+ btn.classList.add('text-[var(--color-void)]', 'bg-[var(--color-accent)]', 'border-transparent');
1493+ } else if (category !== 'Favorites') {
1494+ btn.classList.add('text-[var(--color-subtle)]', 'bg-transparent', 'border-white/10');
1495+ btn.classList.remove('text-[var(--color-void)]', 'bg-[var(--color-accent)]', 'bg-violet-500', 'border-transparent');
1496+ }
1497+ });
1498+
1499+ // Reset favorites button
1500+ if (favoritesFilter) {
1501+ favoritesFilter.classList.add('text-[var(--color-subtle)]', 'bg-transparent', 'border-white/10');
1502+ favoritesFilter.classList.remove('text-[var(--color-void)]', 'bg-[var(--color-accent)]', 'border-transparent');
1503+ }
1504+
1505+ // Reset active filter badge
1506+ activeFilterBadge?.classList.add('hidden');
1507+
1508+ // Clear search input
1509+ if (searchInput) {
1510+ searchInput.value = '';
1511+ }
1512+ clearSearch?.classList.add('hidden');
1513+
1514+ // Show all calculator cards
1515+ calculatorCards.forEach(card => {
1516+ card.classList.remove('hidden');
1517+ });
1518+
1519+ // Show all ads
1520+ document.querySelectorAll('.ad-in-grid').forEach(ad => {
1521+ (ad as HTMLElement).classList.remove('hidden');
1522+ (ad as HTMLElement).style.display = '';
1523+ });
1524+
1525+ // Hide empty state
1526+ emptyState?.classList.add('hidden');
1527+ }
1528+
1529+ // Initialize with reset state
1530+ resetFilterState();
1531+
14911532 function toggleMobileFilters() {
14921533 filtersExpanded = !filtersExpanded;
14931534 if (filtersExpanded) {
@@ -1871,6 +1912,16 @@ const categoryColors: Record<string, string> = {
18711912 searchInput .focus ();
18721913 }
18731914 } );
1915+ }
1916+
1917+ // Initialize on DOMContentLoaded
1918+ document.addEventListener('DOMContentLoaded', initCalculatorPage);
1919+
1920+ // Re-initialize on back/forward navigation (fixes filter state)
1921+ window.addEventListener('pageshow', (event) => {
1922+ if (event .persisted ) {
1923+ initCalculatorPage ();
1924+ }
18741925 } );
18751926</script >
18761927
0 commit comments