Skip to content

Interactive interface for browsing global, full-resolution satellite imagery

WV-2093 Superscript the "2" in Surface Area Unit for Events Listings (#3833)

Jason Hurley1ea417041554
diff --git a/web/js/components/sidebar/event.js b/web/js/components/sidebar/event.js
index c36ae29d8..00c0b0101 100644
--- a/web/js/components/sidebar/event.js
+++ b/web/js/components/sidebar/event.js
@@ -52,6 +52,31 @@ function Event (props) {
}
}
+ /**
+ *
+ * @param {Object} geometry | Geometry object containing magnitude data
+ * @returns Magnitude data output
+ */
+ function magnitudeOutput({ magnitudeUnit = null, magnitudeValue = null }) {
+ const unit = magnitudeUnit || null;
+ let value = magnitudeValue ? magnitudeValue.toLocaleString() : null;
+ if (!unit && !value) return;
+
+ const formattedunit = unit === 'kts' ? ' kts' : ' NM';
+ value = value.toLocaleString();
+ return (
+ <p className="magnitude">
+
+ {formattedunit === ' NM' ? 'Surface Area: ' : 'Wind Speed: '}
+ {value}
+ {formattedunit}
+ {formattedunit === ' NM' && (
+ <sup>2</sup>
+ )}
+ </p>
+ );
+ }
+
/**
* Return date list for selected event
*/
@@ -64,39 +89,22 @@ function Event (props) {
>
{event.geometry.map((geometry, index) => {
const date = util.toISOStringDate(geometry.date);
- function magnitudeOutput() {
- const magnitudeUnit = geometry.magnitudeUnit ? geometry.magnitudeUnit : null;
- const magnitudeValue = geometry.magnitudeValue ? geometry.magnitudeValue.toLocaleString() : null;
- if (!magnitudeUnit && !magnitudeValue) return;
- const magnitudeDisplay = magnitudeUnit === 'kts' ? 'Wind Speed: ' : 'Surface Area: ';
- return `${magnitudeDisplay} ${magnitudeValue} ${magnitudeUnit}`;
- }
return (
- <li key={`${event.id}-${date}`} className="date">
-
- {selectedDate === date ? (
- <span
- className="active"
- onClick={(e) => e.stopPropagation()}
- >
- {formatDisplayDate(date)}
- </span>
- )
- : (
- <a
- className="'date item-selected"
- onClick={(e) => {
- e.stopPropagation();
- onEventSelect(date);
- }}
- >
- {formatDisplayDate(date)}
- </a>
- )}
-
- <p className="magnitude">
- {magnitudeOutput()}
- </p>
+ <li key={`${event.id}-${date}`} className="dates">
+ <a
+ onClick={(e) => {
+ e.stopPropagation();
+ onEventSelect(date);
+ }}
+ className={
+ selectedDate === date
+ ? 'date item-selected active'
+ : 'date item-selected '
+ }
+ >
+ {formatDisplayDate(date)}
+ </a>
+ {magnitudeOutput(geometry)}
</li>
);
})}