Skip to content

Commit 041498c

Browse files
authored
Merge pull request #1309 from Hack23/copilot/improve-css-light-dark-mode
Full-width desktop layout, improved light/dark mode theming across all pages
2 parents a4adcb4 + 96bb42f commit 041498c

6 files changed

Lines changed: 359 additions & 51 deletions

File tree

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,3 +66,4 @@ scripts/__pycache__/
6666
/sitemap*
6767
dashboard-initial.png
6868
api/
69+
current-*.png

dashboard/styles.css

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/* Dashboard Container */
66
.cia-dashboard {
7-
max-width: 1400px;
7+
max-width: 100%;
88
margin: 0 auto;
99
padding: var(--spacing-md);
1010
}
@@ -64,7 +64,7 @@
6464
.rankings-section,
6565
.heatmap-section,
6666
.network-section {
67-
margin: var(--spacing-3xl) 0;
67+
margin: var(--spacing-xl) 0;
6868
padding: var(--spacing-xl);
6969
background: var(--card-bg);
7070
border-radius: var(--border-radius-lg);
@@ -74,20 +74,20 @@
7474
.section-heading {
7575
font-size: var(--h2-size);
7676
color: var(--primary-color);
77-
margin-bottom: var(--spacing-lg);
77+
margin-bottom: var(--spacing-md);
7878
border-bottom: 2px solid var(--border-color);
7979
padding-bottom: var(--spacing-sm);
8080
}
8181

8282
.section-description {
8383
color: var(--text-secondary);
84-
margin-bottom: var(--spacing-lg);
84+
margin-bottom: var(--spacing-md);
8585
font-size: var(--font-size-base);
8686
}
8787

8888
/* Metrics Grid */
8989
.metrics-grid {
90-
margin: var(--spacing-2xl) 0;
90+
margin: var(--spacing-lg) 0;
9191
padding: var(--spacing-xl);
9292
background: var(--card-bg);
9393
border-radius: var(--border-radius-lg);
@@ -108,7 +108,7 @@
108108
border-radius: var(--border-radius);
109109
text-align: center;
110110
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
111-
transition: transform 0.3s ease, box-shadow 0.3s ease;
111+
transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s ease;
112112
}
113113

114114
.metric-card:hover {
@@ -791,6 +791,7 @@ html[data-theme="dark"] .metrics-grid {
791791
background: var(--card-bg);
792792
border: 1px solid var(--card-border, var(--border-color));
793793
box-shadow: 0 0 12px rgba(0, 204, 102, 0.15);
794+
border-radius: var(--border-radius-lg, 12px);
794795
}
795796

796797
html[data-theme="dark"] .section-heading {
@@ -799,13 +800,21 @@ html[data-theme="dark"] .section-heading {
799800
}
800801

801802
html[data-theme="dark"] .metric-card {
802-
background: linear-gradient(135deg, rgba(0, 204, 102, 0.2) 0%, rgba(0, 187, 119, 0.2) 100%);
803+
background: linear-gradient(135deg, rgba(0, 204, 102, 0.15) 0%, rgba(0, 187, 119, 0.15) 100%);
803804
border: 1px solid rgba(0, 204, 102, 0.3);
805+
box-shadow: 0 2px 8px rgba(0, 204, 102, 0.1);
806+
}
807+
808+
html[data-theme="dark"] .metric-card:hover {
809+
border-color: rgba(0, 204, 102, 0.5);
810+
box-shadow: 0 4px 16px rgba(0, 204, 102, 0.2);
811+
transform: translateY(-2px);
804812
}
805813

806814
html[data-theme="dark"] .chart-container {
807815
background: rgba(0, 26, 26, 0.6);
808816
border: 1px solid rgba(0, 204, 102, 0.15);
817+
border-radius: var(--border-radius, 8px);
809818
}
810819

811820
html[data-theme="dark"] .risk-alerts {
@@ -821,13 +830,25 @@ html[data-theme="light"] .network-section,
821830
html[data-theme="light"] .metrics-grid {
822831
background: var(--card-bg);
823832
box-shadow: var(--card-shadow-resting);
824-
border: 1px solid var(--card-border, #dee2e6);
833+
border: 1px solid var(--card-border, rgba(0, 0, 0, 0.08));
834+
border-radius: var(--border-radius-lg, 12px);
825835
}
826836

827837
html[data-theme="light"] .chart-container {
828838
background: var(--bg-color);
839+
border-radius: var(--border-radius, 8px);
829840
}
830841

831842
html[data-theme="light"] .metric-card {
832843
background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-light) 100%);
844+
box-shadow: 0 2px 8px rgba(0, 102, 51, 0.15);
845+
}
846+
847+
html[data-theme="light"] .metric-card:hover {
848+
box-shadow: 0 4px 16px rgba(0, 102, 51, 0.25);
849+
transform: translateY(-2px);
850+
}
851+
852+
html[data-theme="light"] .section-heading {
853+
color: var(--primary-color);
833854
}

js/theme-toggle.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
var STORAGE_KEY = 'riksdagsmonitor-theme';
1313
var DARK = 'dark';
1414
var LIGHT = 'light';
15+
var _transitionTimer = null;
1516

1617
var button = document.getElementById('theme-toggle');
1718
if (!button) {
@@ -67,11 +68,19 @@
6768

6869
button.addEventListener('click', function () {
6970
currentTheme = currentTheme === DARK ? LIGHT : DARK;
71+
document.documentElement.classList.add('theme-transition');
7072
applyTheme(currentTheme, button);
7173
try {
7274
window.localStorage.setItem(STORAGE_KEY, currentTheme);
7375
} catch (_e) {
7476
// Ignore storage errors
7577
}
78+
// Remove transition class after animations complete; clear any pending timer
79+
// to avoid races when the user clicks rapidly.
80+
if (_transitionTimer) { clearTimeout(_transitionTimer); }
81+
_transitionTimer = setTimeout(function () {
82+
document.documentElement.classList.remove('theme-transition');
83+
_transitionTimer = null;
84+
}, 350);
7685
});
7786
}());

public/js/theme-toggle.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
const STORAGE_KEY = 'riksdagsmonitor-theme';
2424
const DARK = 'dark';
2525
const LIGHT = 'light';
26+
let _transitionTimer = null;
2627

2728
/* ── Helpers ──────────────────────────────────────────────────────────── */
2829

@@ -77,8 +78,16 @@
7778
function toggle() {
7879
const current = document.documentElement.getAttribute('data-theme') || LIGHT;
7980
const next = current === DARK ? LIGHT : DARK;
81+
document.documentElement.classList.add('theme-transition');
8082
applyTheme(next);
8183
updateButton(next);
84+
// Remove transition class after animations complete; clear any pending timer
85+
// to avoid races when the user clicks rapidly.
86+
if (_transitionTimer) { clearTimeout(_transitionTimer); }
87+
_transitionTimer = setTimeout(function () {
88+
document.documentElement.classList.remove('theme-transition');
89+
_transitionTimer = null;
90+
}, 350);
8291
}
8392

8493
/* ── Boot ─────────────────────────────────────────────────────────────── */

0 commit comments

Comments
 (0)