Skip to content

Commit a36f164

Browse files
Copilotbrunoborges
andcommitted
Fix expand/collapse issues: label positioning, icons, button state, and background colors
Co-authored-by: brunoborges <129743+brunoborges@users.noreply.github.com>
1 parent bf55433 commit a36f164

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

site/app.js

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,19 @@
174174
card.classList.add('filter-hidden');
175175
}
176176
});
177+
178+
// Update view toggle button state
179+
if (window.updateViewToggleState) {
180+
window.updateViewToggleState();
181+
}
177182
});
178183
});
184+
185+
// Auto-click "All" button on page load to show all cards
186+
const allButton = document.querySelector('.filter-pill[data-filter="all"]');
187+
if (allButton) {
188+
allButton.click();
189+
}
179190
};
180191

181192
/* ==========================================================
@@ -491,12 +502,26 @@
491502

492503
let isExpanded = false;
493504

505+
const updateButtonState = () => {
506+
const visibleCards = document.querySelectorAll('.tip-card:not(.filter-hidden)');
507+
const hasVisibleCards = visibleCards.length > 0;
508+
509+
toggleBtn.disabled = !hasVisibleCards;
510+
if (!hasVisibleCards) {
511+
toggleBtn.style.opacity = '0.5';
512+
toggleBtn.style.cursor = 'not-allowed';
513+
} else {
514+
toggleBtn.style.opacity = '1';
515+
toggleBtn.style.cursor = 'pointer';
516+
}
517+
};
518+
494519
toggleBtn.addEventListener('click', () => {
495520
isExpanded = !isExpanded;
496521

497522
if (isExpanded) {
498523
tipsGrid.classList.add('expanded');
499-
toggleBtn.querySelector('.view-toggle-icon').textContent = '';
524+
toggleBtn.querySelector('.view-toggle-icon').textContent = '';
500525
toggleBtn.querySelector('.view-toggle-text').textContent = 'Collapse All';
501526

502527
// Remove toggled class from all cards when expanding
@@ -505,10 +530,16 @@
505530
});
506531
} else {
507532
tipsGrid.classList.remove('expanded');
508-
toggleBtn.querySelector('.view-toggle-icon').textContent = '';
533+
toggleBtn.querySelector('.view-toggle-icon').textContent = '';
509534
toggleBtn.querySelector('.view-toggle-text').textContent = 'Expand All';
510535
}
511536
});
537+
538+
// Check initial state
539+
updateButtonState();
540+
541+
// Make updateButtonState available for filter to call
542+
window.updateViewToggleState = updateButtonState;
512543
};
513544

514545
/* ==========================================================

site/styles.css

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,8 @@ code, pre { font-family: 'JetBrains Mono', monospace; }
6363
--yellow: #fbbf24;
6464
--cyan: #22d3ee;
6565
--red-muted: #ef4444;
66-
--old-bg: #11100f;
67-
--modern-bg: #0f1117;
66+
--old-bg: #1a1412;
67+
--modern-bg: #0f1419;
6868
--radius: 16px;
6969
--radius-sm: 10px;
7070
--nav-bg: rgba(11, 11, 15, .8);
@@ -649,6 +649,13 @@ nav {
649649
border-top: none;
650650
}
651651

652+
.tips-grid.expanded .tip-card .mini-label {
653+
position: relative;
654+
top: 0;
655+
right: 0;
656+
margin-bottom: 8px;
657+
}
658+
652659
.tips-grid.expanded .tip-card .hover-hint {
653660
display: none;
654661
}

templates/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ <h2 class="section-title">All comparisons</h2>
242242
</div>
243243
<div class="view-toggle-wrap">
244244
<button class="view-toggle-btn" id="viewToggle" aria-label="Toggle view mode">
245-
<span class="view-toggle-icon"></span>
245+
<span class="view-toggle-icon"></span>
246246
<span class="view-toggle-text">Expand All</span>
247247
</button>
248248
</div>

0 commit comments

Comments
 (0)