Skip to content

Commit 0881938

Browse files
committed
Enhance dark mode support and add alert detail styling
- Introduced new CSS variables for dark mode alert backgrounds to improve visual consistency. - Updated body styles to default to dark mode and added light mode styles for better user experience. - Implemented alert detail card styles with hover effects and risk badge indicators for different alert levels. - Enhanced dark mode styles for alert details to ensure readability and maintain contrast.
1 parent e7265f4 commit 0881938

1 file changed

Lines changed: 116 additions & 5 deletions

File tree

scripts/html_utils.py

Lines changed: 116 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,14 +24,24 @@ def html_header(title):
2424
--sev-bg-low: #e5f6fa;
2525
--sev-bg-info: #f0f0f0;
2626
--sev-bg-passed: #e6f9ed;
27+
/* Dark mode alert backgrounds */
28+
--sev-bg-critical-dark: #742a2a;
29+
--sev-bg-high-dark: #744210;
30+
--sev-bg-medium-dark: #744210;
31+
--sev-bg-low-dark: #2a4365;
32+
--sev-bg-info-dark: #4a5568;
2733
}}
2834
body {{
29-
background: var(--bg-light);
30-
color: var(--text-light);
35+
background: var(--bg-dark);
36+
color: var(--text-dark);
3137
font-family: 'Segoe UI', Arial, sans-serif;
3238
margin: 0; padding: 0;
3339
transition: background 0.2s, color 0.2s;
3440
}}
41+
body.lightmode {{
42+
background: var(--bg-light);
43+
color: var(--text-light);
44+
}}
3545
body.darkmode {{
3646
background: var(--bg-dark);
3747
color: var(--text-dark);
@@ -109,6 +119,108 @@ def html_header(title):
109119
.row-PASSED {{ background: var(--sev-bg-passed); }}
110120
.all-clear {{ background: var(--sev-bg-passed); color: var(--sev-passed); border-radius: 0.5em; padding: 1em; margin: 1em 0; font-weight: bold; display: flex; align-items: center; gap: 0.7em; font-size: 1.2em; }}
111121
.icon {{ font-size: 1.2em; vertical-align: middle; margin-right: 0.3em; }}
122+
/* --- Alert Detail Cards --- */
123+
.alert-detail {{
124+
margin: 1.5em 0;
125+
padding: 1.5em;
126+
border: 2px solid var(--sev-medium);
127+
background: var(--sev-bg-medium);
128+
border-radius: 12px;
129+
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
130+
transition: transform 0.2s, box-shadow 0.2s;
131+
}}
132+
.alert-detail:hover {{
133+
transform: translateY(-2px);
134+
box-shadow: 0 6px 12px rgba(0,0,0,0.15);
135+
}}
136+
.alert-detail.high {{
137+
border-color: var(--sev-high);
138+
background: var(--sev-bg-high);
139+
}}
140+
.alert-detail.medium {{
141+
border-color: var(--sev-medium);
142+
background: var(--sev-bg-medium);
143+
}}
144+
.alert-detail.low {{
145+
border-color: var(--sev-low);
146+
background: var(--sev-bg-low);
147+
}}
148+
.alert-detail.informational {{
149+
border-color: var(--sev-info);
150+
background: var(--sev-bg-info);
151+
}}
152+
.alert-detail h4 {{
153+
margin: 0 0 0.5em 0;
154+
font-size: 1.2em;
155+
font-weight: 600;
156+
}}
157+
.alert-meta {{
158+
display: flex;
159+
gap: 1em;
160+
margin-bottom: 1em;
161+
flex-wrap: wrap;
162+
}}
163+
.risk-badge {{
164+
padding: 0.3em 0.8em;
165+
border-radius: 20px;
166+
font-size: 0.9em;
167+
font-weight: 600;
168+
text-transform: uppercase;
169+
}}
170+
.risk-badge.high {{
171+
background: var(--sev-high);
172+
color: white;
173+
}}
174+
.risk-badge.medium {{
175+
background: var(--sev-medium);
176+
color: white;
177+
}}
178+
.risk-badge.low {{
179+
background: var(--sev-low);
180+
color: white;
181+
}}
182+
.risk-badge.informational {{
183+
background: var(--sev-info);
184+
color: white;
185+
}}
186+
.alert-count {{
187+
padding: 0.3em 0.8em;
188+
background: #f8f9fa;
189+
border-radius: 20px;
190+
font-size: 0.9em;
191+
font-weight: 500;
192+
}}
193+
body.darkmode .alert-count {{
194+
background: #343a40;
195+
color: var(--text-dark);
196+
}}
197+
body.darkmode .alert-detail {{
198+
background: var(--sev-bg-medium-dark);
199+
border-color: #4a5568;
200+
}}
201+
body.darkmode .alert-detail.high {{
202+
background: var(--sev-bg-high-dark);
203+
border-color: var(--sev-high);
204+
}}
205+
body.darkmode .alert-detail.medium {{
206+
background: var(--sev-bg-medium-dark);
207+
border-color: var(--sev-medium);
208+
}}
209+
body.darkmode .alert-detail.low {{
210+
background: var(--sev-bg-low-dark);
211+
border-color: var(--sev-low);
212+
}}
213+
body.darkmode .alert-detail.informational {{
214+
background: var(--sev-bg-info-dark);
215+
border-color: var(--sev-info);
216+
}}
217+
.alert-description, .alert-solution {{
218+
margin: 1em 0;
219+
}}
220+
.alert-description p, .alert-solution p {{
221+
margin: 0.5em 0;
222+
line-height: 1.6;
223+
}}
112224
/* --- Fix contrast in dark mode --- */
113225
body.darkmode .row-CRITICAL td, body.darkmode .row-CRITICAL th {{ color: #fff !important; background: #a94442 !important; }}
114226
body.darkmode .row-HIGH td, body.darkmode .row-HIGH th {{ color: #fff !important; background: #e67c00 !important; }}
@@ -121,9 +233,8 @@ def html_header(title):
121233
localStorage.setItem('SimpleSecCheck-darkmode', document.body.classList.contains('darkmode'));
122234
}}
123235
window.onload = function() {{
124-
if (localStorage.getItem('SimpleSecCheck-darkmode') === 'true') {{
125-
document.body.classList.add('darkmode');
126-
}}
236+
// Always default to dark mode
237+
document.body.classList.add('darkmode');
127238
}};
128239
</script>\n<script src="webui.js"></script>\n</head>\n<body>\n<div class="header">\n <h1>SimpleSecCheck Security Scan Summary</h1>\n <button class="toggle-btn" onclick="toggleDarkMode()">🌙/☀️ Toggle Dark/Light</button>\n</div>\n<div class="summary-box">'''
129240

0 commit comments

Comments
 (0)