Full-width desktop layout, improved light/dark mode theming across all pages#1309
Full-width desktop layout, improved light/dark mode theming across all pages#1309
Conversation
🏷️ Automatic Labeling SummaryThis PR has been automatically labeled based on the files changed and PR metadata. Applied Labels: size-xs Label Categories
For more information, see |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…ling - Remove max-width: 1200px constraint from body (use full viewport width) - Update all container elements to max-width: 100% - Improve light theme: better card elevation, background, borders - Improve dark theme: better card hover effects, backdrop blur, footer styling - Dashboard: full-width container, improved metric card hover effects - Cards grid: use auto-fit with 1fr for natural full-width expansion Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…, consistent hover effects - Restore vertical padding on body (var(--spacing-md)) - Cap cards grid max column width to 480px to prevent ultra-wide cards - Cap value-metrics grid max column width to 420px - Add consistent translateY hover effect to dark theme metric cards Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
… article dark/light mode - Tighten breadcrumb spacing (padding, margin, font-size) - Reduce header bottom margin for better vertical rhythm - Reduce dashboard section margins for tighter layout - Add smooth theme transition for body, header, footer, cards, breadcrumb, nav - Add light mode subtle section backgrounds for visual hierarchy - Add comprehensive news article dark/light mode overrides - Add light mode AI newsroom section and footer overrides - Improve mobile body padding for small screens - Optimize footer padding/margins - Reduce dashboard metrics-grid margin Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
…ard border transition, simplify dark gradients Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Fixed in 33e75a8. The |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
| it('adds theme-transition class on toggle', () => { | ||
| buildButton(); | ||
| applyTheme('light', false, storage); | ||
| const current = document.documentElement.getAttribute('data-theme') || LIGHT; | ||
| const next = current === DARK ? LIGHT : DARK; | ||
| document.documentElement.classList.add('theme-transition'); | ||
| applyTheme(next, undefined, storage); | ||
| updateButton(next); | ||
| expect(document.documentElement.classList.contains('theme-transition')).toBe(true); | ||
| }); |
There was a problem hiding this comment.
This test doesn't verify that the toggle behavior adds the theme-transition class because it adds the class manually (line 358) and never invokes the toggle/click handler. As written, it will pass even if the production code stops adding the class. Suggested fix: start with the class absent, trigger the same path users do (e.g., dispatch a click on the toggle button or call the toggle handler), and then assert that theme-transition is present.
| setTimeout(function () { | ||
| document.documentElement.classList.remove('theme-transition'); | ||
| }, 350); | ||
|
|
||
| // After 350ms from second toggle, class should be removed | ||
| vi.advanceTimersByTime(350); |
There was a problem hiding this comment.
This test can't fail if the clearTimeout guard is removed from production code: even if the first timer fires at t=350ms and removes the class prematurely, the final assertion still passes because the second timer also removes the class before the final check. Suggested fix: add an assertion at the moment the first timer would have fired (e.g., advance to ~350ms total time and assert the class is still present), then advance to 350ms after the second toggle and assert removal. Also consider assigning the second setTimeout(...) handle to timer so it mirrors the implementation and remains extensible for additional rapid toggles.
| setTimeout(function () { | |
| document.documentElement.classList.remove('theme-transition'); | |
| }, 350); | |
| // After 350ms from second toggle, class should be removed | |
| vi.advanceTimersByTime(350); | |
| timer = setTimeout(function () { | |
| document.documentElement.classList.remove('theme-transition'); | |
| timer = null; | |
| }, 350); | |
| // After 350ms from first toggle (i.e. 250ms after the second), class should still be present | |
| vi.advanceTimersByTime(250); | |
| expect(document.documentElement.classList.contains('theme-transition')).toBe(true); | |
| // After 350ms from second toggle, class should be removed | |
| vi.advanceTimersByTime(100); |
| const STORAGE_KEY = 'riksdagsmonitor-theme'; | ||
| const DARK = 'dark'; | ||
| const LIGHT = 'light'; | ||
| var _transitionTimer = null; |
There was a problem hiding this comment.
In this file the surrounding declarations use const, but the new timer uses var. Using let _transitionTimer = null; avoids function-scope hoisting pitfalls and keeps the scoping consistent with modern JS patterns used elsewhere in the file.
| var _transitionTimer = null; | |
| let _transitionTimer = null; |
|
@copilot apply changes based on the comments in this thread |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Implemented in 45ec8fa. Applied all requested fixes from the review thread:
Validation run:
Screenshot (dashboard light mode): https://github.com/user-attachments/assets/7cc6de80-0ca0-464a-8372-9e2be59d997c |
| it('adds theme-transition class on toggle', () => { | ||
| buildButton(); | ||
| applyTheme('light', false, storage); | ||
| const toggle = createToggleHandler(); | ||
|
|
||
| expect(document.documentElement.classList.contains('theme-transition')).toBe(false); | ||
| toggle(); | ||
| expect(document.documentElement.classList.contains('theme-transition')).toBe(true); | ||
| }); |
There was a problem hiding this comment.
The "adds theme-transition class on toggle" test schedules a real setTimeout (350ms) without using fake timers or clearing it afterward. That leaves a pending timer that can keep the event loop alive and/or mutate documentElement during later tests, causing flakiness/open-handle warnings. Use vi.useFakeTimers() for this test too (and advance/flush timers), or cancel any outstanding transition timer in an afterEach for this describe block.
| it('removes theme-transition class after timeout', () => { | ||
| vi.useFakeTimers(); | ||
| buildButton(); | ||
| applyTheme('light', false, storage); | ||
| const toggle = createToggleHandler(); | ||
|
|
||
| toggle(); | ||
| expect(document.documentElement.classList.contains('theme-transition')).toBe(true); | ||
| vi.advanceTimersByTime(350); | ||
| expect(document.documentElement.classList.contains('theme-transition')).toBe(false); | ||
| vi.useRealTimers(); | ||
| }); |
There was a problem hiding this comment.
These tests switch to fake timers and then manually call vi.useRealTimers() at the end. If an assertion throws before that line, the suite can stay in fake-timer mode and cascade failures into later tests. Prefer moving timer restore/cleanup into an afterEach (and consider vi.clearAllTimers()/vi.runOnlyPendingTimers()) within this describe block to guarantee cleanup even on failure.
|
@copilot apply changes based on the comments in this thread |
Co-authored-by: pethers <1726836+pethers@users.noreply.github.com>
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
Implemented in 03ba07b. Updated
Validation run:
Screenshot: https://github.com/user-attachments/assets/7cc6de80-0ca0-464a-8372-9e2be59d997c |
🔍 Lighthouse Performance Audit
📥 Download full Lighthouse report Budget Compliance: Performance budgets enforced via |
tests/theme-toggle.test.jsto guarantee timer cleanup (afterEach) and remove potential pending timers💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.