Skip to content

Commit 819523e

Browse files
committed
mobile no sidebar
1 parent 548ee3e commit 819523e

File tree

3 files changed

+59
-44
lines changed

3 files changed

+59
-44
lines changed

script.js

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,33 +207,44 @@ function handleNodeClick(d) {
207207
*/
208208
function displayNodeInfo(data) {
209209
const statisticsDiv = document.getElementById('statistics');
210-
const isAllResidents = data.eligibility === "All Residents"; // For all services file, some services this is not applicable
211210
const eligibility = data.eligibility && typeof data.eligibility === 'object';
212211

212+
let eligibilityHtml = '';
213+
if (eligibility) {
214+
if (data.eligibility.Income) {
215+
eligibilityHtml += `<p>Max Income: ${data.eligibility.Income}</p>`;
216+
}
217+
if (data.eligibility.Age) {
218+
eligibilityHtml += `<p>Age: ${data.eligibility.Age}</p>`;
219+
}
220+
if (data.eligibility.Other) {
221+
eligibilityHtml += `<p>Other: ${data.eligibility.Other}</p>`;
222+
}
223+
}
224+
213225
statisticsDiv.innerHTML = `
214226
<h2>${data.name}</h2>
215227
<h3><a href="${data.site}" target="_blank">${data.description}</a></h3>
216228
217-
<p>People: ${data.roundSize}</p>
218-
<p>Spend: $${data.roundSpend}</p>
219-
<p>Department: ${data.department}</p>
229+
${data.roundSize ? `<p>People: ${data.roundSize}</p>` : ''}
230+
${data.roundSpend ? `<p>Spend: $${data.roundSpend}</p>` : ''}
231+
${data.department ? `<p>Department: ${data.department}</p>` : ''}
220232
221-
${!isAllResidents && eligibility ? `
222-
<h3>Eligibility Criteria</h3>
223-
<p>Max Income: ${data.eligibility.Income}</p>
224-
<p>Age: ${data.eligibility.Age}</p>
225-
<p>Other: ${data.eligibility.Other}</p>
226-
` : ''}
233+
${eligibilityHtml ? `<h3>Eligibility Criteria</h3>${eligibilityHtml}` : ''}
227234
`;
235+
statisticsDiv.classList.add('visible'); // for mobile
228236
}
229237

238+
239+
230240
/**
231241
* clearSidebar()
232242
* Clears the content of the sidebar.
233243
*/
234244
function clearSidebar() {
235245
const statisticsDiv = document.getElementById('statistics');
236246
statisticsDiv.innerHTML = '';
247+
statisticsDiv.classList.remove('visible');
237248
}
238249

239250
/**

services.json

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,7 @@
5959
"Description": "The Massachusetts Low Income Home Energy Assistance Program",
6060
"Elig": {
6161
"Income": "x",
62-
"Age": "x",
63-
"Other": "N/A"
62+
"Age": "x"
6463
}
6564
},
6665
"SSI": {
@@ -74,9 +73,6 @@
7473
"RoundSpend": "200M",
7574
"Description": "Supplemental Security Income",
7675
"Elig": {
77-
"Income": "x",
78-
"Age": "x",
79-
"Other": "N/A"
8076
}
8177
},
8278
"Education": {

style.css

Lines changed: 37 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
padding: 0;
55
box-sizing: border-box;
66
}
7-
8-
/* Variables for reuse */
7+
/* Variables */
98
:root {
109
--font-family: 'Open Sans', sans-serif;
1110
--header-bg: #f8f8f8;
@@ -22,6 +21,13 @@
2221
--table-hover-bg: #f1f1f1;
2322
--table-alt-bg: #f9f9f9;
2423
--link-color: #007385;
24+
--sidebar-height-mobile: 40%; /* New variable for sidebar height on mobile */
25+
}
26+
27+
28+
/* Add this to your existing CSS for sidebar */
29+
.sidebar {
30+
display: none !important; /* Hide sidebar on mobile */
2531
}
2632

2733
/* Body styling */
@@ -301,10 +307,6 @@ h2 {
301307
padding: 20px;
302308
}
303309

304-
.sidebar {
305-
width: 25%; /* 1 out of 4 columns */
306-
}
307-
308310
#d3_chart_div {
309311
flex: 1;
310312
width: 75%; /* 3 out of 4 columns */
@@ -360,45 +362,51 @@ h2 {
360362

361363
/* Sidebar only shows on desktop */
362364
.sidebar {
365+
display: flex !important; /* Show sidebar on tablet and desktop */
363366
width: 25%; /* 1 out of 4 columns */
364367
padding: 10px;
365-
background: white; /* Set background to white */
368+
background: white;
366369
border-left: var(--header-border);
367370
overflow-y: auto;
368-
display: flex;
369371
flex-direction: column;
372+
align-items: flex-start !important;
370373
}
371-
374+
372375
.sidebar h2 {
373-
text-align: left;
374-
font-size: 24px;
375-
margin-bottom: 18px;
376-
padding: 10px;
376+
text-align: left !important;
377+
width: 100% !important;
378+
font-size: 24px !important;
379+
margin-bottom: 10px !important;
380+
padding: 10px !important;
377381
}
378382

379383
.sidebar h3 {
380-
text-align: left;
381-
font-size: 16px;
382-
margin-top: 18px;
383-
padding: 10px;
384-
font-weight: bold;
384+
text-align: left !important;
385+
width: 100% !important;
386+
font-size: 16px !important;
387+
margin-top: 18px !important;
388+
margin-bottom: 10px !important;
389+
padding: 10px !important;
390+
font-weight: bold !important;
385391
}
386-
387-
.sidebar p{
388-
text-align: left;
389-
padding: 10px;
390-
font-size: 16px;
391-
line-height: 10px;
392+
393+
.sidebar p {
394+
text-align: left !important;
395+
width: 100% !important;
396+
padding: 10px !important;
397+
font-size: 16px !important;
398+
line-height: 1.0 !important;
399+
392400
}
393401

394402
.sidebar a {
395-
color: black;
396-
text-decoration: none;
403+
color: black !important;
404+
text-decoration: none !important;
397405
}
398-
406+
399407
.sidebar a:hover {
400-
color: var(--link-color);
401-
text-decoration: underline;
408+
color: var(--link-color) !important;
409+
text-decoration: underline !important;
402410
}
403411

404412
}

0 commit comments

Comments
 (0)