Skip to content

Commit 630d879

Browse files
committed
added greyed out old points
1 parent eb032b7 commit 630d879

2 files changed

Lines changed: 40 additions & 11 deletions

File tree

frontend/src/components/MapComponent.jsx

Lines changed: 35 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -191,34 +191,58 @@ export default function MapComponent() {
191191
const t = item.temp || item.Result;
192192
const name = item.siteName || item.Label || `User Point ${i + 1}`;
193193

194-
// Get current unit and format temperature
194+
// determine age (fallback to createdAt for user‐points)
195+
const rawTime = item.timestamp || item.createdAt || item.created_at;
196+
const ts = new Date(rawTime).getTime();
197+
const isStale = !isNaN(ts) && (Date.now() - ts) > 2 * 24 * 60 * 60 * 1000; // older than 2 days
198+
195199
const currentUnit = UnitManager.getUnit();
196200
const formattedTemp = formatTemperature(t, currentUnit);
197-
const tempColor = getAccessibleTemperatureColor(t, 'C'); // Use accessible color function
201+
const tempColor = getAccessibleTemperatureColor(t, 'C');
198202
const tempCategory = getTemperatureCategory(t);
199-
const tempSymbol = getTemperatureSymbol(t);
200203

201-
console.log(`Plotting [${i}]: ${name} @ ${lat},${lon} = ${formattedTemp}`);
204+
// outline for stale, grey text for stale
205+
const outlineStyle = isStale ? 'border: 2px solid grey;' : '';
206+
const valueColor = isStale ? 'color: grey;' : '';
207+
208+
// determine stale styling
209+
const bgColor = isStale ? '#ffffff20' : tempColor;
210+
const staleFilter = isStale
211+
? 'backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);'
212+
: '';
202213

203214
const icon = L.divIcon({
204215
className: 'custom-temp-marker',
205216
html: `
206217
<div
207-
class="temp-label accessible-marker"
208-
style="background-color: ${tempColor};"
218+
class="temp-label accessible-marker${isStale ? ' stale' : ''}"
219+
style="
220+
background-color: ${bgColor};
221+
${outlineStyle}
222+
${staleFilter}
223+
"
209224
role="button"
210225
tabindex="0"
211-
aria-label="Water temperature ${formattedTemp} at ${name}. Category: ${tempCategory}. Press Enter or Space to view details."
212-
data-temp-category="${tempCategory.toLowerCase().replace(' ', '-')}"
226+
aria-label="Water temperature ${formattedTemp} at ${name}. ${isStale ? 'Data older than 2 days.' : `Category: ${tempCategory}. Press Enter or Space to view details.`}"
227+
data-temp-category="${tempCategory.toLowerCase().replace(/ /g,'-')}"
213228
>
214-
<span class="temp-value">${formattedTemp}</span>
229+
<span class="temp-value" style="${valueColor}">${formattedTemp}</span>
215230
</div>
216231
`,
217-
iconSize: [50, 40], // Slightly larger for better touch targets
232+
iconSize: [50, 40],
218233
iconAnchor: [25, 20],
219234
});
220235

221-
const marker = L.marker([lat, lon], { icon }).addTo(map);
236+
const marker = L.marker([lat, lon], { icon }).addTo(mapInstanceRef.current);
237+
238+
// bump this marker to the top on hover
239+
marker.on('mouseover', () => {
240+
marker.setZIndexOffset(1000);
241+
});
242+
// reset when mouse leaves
243+
marker.on('mouseout', () => {
244+
marker.setZIndexOffset(0);
245+
});
222246

223247
// Add function to announce to screen readers (this was missing)
224248
function announceToScreenReader(message) {

frontend/src/styles/MapView.css

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,8 @@
280280
max-height: 60vh !important;
281281
}
282282
}
283+
284+
/* at the end of the file, override any data-temp-category borders on stale points */
285+
.temp-label.stale {
286+
border-left: none !important;
287+
}

0 commit comments

Comments
 (0)