Skip to content

Commit ebb8465

Browse files
frozenheliumsamshara
authored andcommitted
Add label to windspeed chart on wfp adam risk
1 parent 33a5ded commit ebb8465

File tree

3 files changed

+66
-27
lines changed

3 files changed

+66
-27
lines changed

src/components/domain/RiskImminentEvents/WfpAdam/EventDetails/i18n.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"wfpExposed90": "Exposed (90km/h)",
2525
"wfpExposed120": "Exposed (120km/h)",
2626
"wfpFloodArea": "Flood Area",
27-
"wfpFloodCropland": "Flood Cropland"
27+
"wfpFloodCropland": "Flood Cropland",
28+
"wfpChartLabel": "Windspeed over time"
2829
}
2930
}

src/components/domain/RiskImminentEvents/WfpAdam/EventDetails/index.tsx

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@ import Link from '#components/Link';
1010
import BlockLoading from '#components/BlockLoading';
1111
import Container from '#components/Container';
1212
import TextOutput from '#components/TextOutput';
13+
import Tooltip from '#components/Tooltip';
14+
import useTranslation from '#hooks/useTranslation';
1315
import { getPercentage, maxSafe, roundSafe } from '#utils/common';
1416
import { type RiskApiResponse } from '#utils/restRequest';
15-
import useTranslation from '#hooks/useTranslation';
1617
import { isValidFeatureCollection, isValidPointFeature } from '#utils/domain/risk';
1718
import { resolveToString } from '#utils/translation';
1819

@@ -167,23 +168,33 @@ function EventDetails(props: Props) {
167168
{stormPoints && stormPoints.length > 0 && isDefined(maxWindSpeed) && (
168169
/* TODO: use proper svg charts */
169170
<div className={styles.windSpeedChart}>
170-
{stormPoints.map(
171-
(point) => (
172-
<div
173-
key={point.id}
174-
className={styles.bar}
175-
// FIXME: Use percent function
176-
style={{ height: `${getPercentage(point.windSpeed, maxWindSpeed)}%` }}
177-
title={resolveToString(
178-
strings.wfpEventDetailsKm,
179-
{
180-
point: point.windSpeed,
181-
pontDate: point.date.toLocaleString(),
182-
},
183-
)}
184-
/>
185-
),
186-
)}
171+
<div className={styles.barListContainer}>
172+
{stormPoints.map(
173+
(point) => (
174+
<div
175+
key={point.id}
176+
className={styles.barContainer}
177+
>
178+
<Tooltip
179+
description={resolveToString(
180+
strings.wfpEventDetailsKm,
181+
{
182+
point: point.windSpeed ?? '--',
183+
pointDate: point.date.toLocaleString() ?? '--',
184+
},
185+
)}
186+
/>
187+
<div
188+
style={{ height: `${getPercentage(point.windSpeed, maxWindSpeed)}%` }}
189+
className={styles.bar}
190+
/>
191+
</div>
192+
),
193+
)}
194+
</div>
195+
<div className={styles.chartLabel}>
196+
{strings.wfpChartLabel}
197+
</div>
187198
</div>
188199
)}
189200
{isDefined(eventDetails)

src/components/domain/RiskImminentEvents/WfpAdam/EventDetails/styles.module.css

Lines changed: 35 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,42 @@
66

77
.wind-speed-chart {
88
display: flex;
9-
align-items: flex-end;
10-
justify-content: space-around;
11-
height: 10rem;
9+
flex-direction: column;
10+
gap: var(--go-ui-spacing-xs);
1211

13-
.bar {
14-
border-top-left-radius: 2pt;
15-
border-top-right-radius: 2pt;
16-
background-color: var(--go-ui-color-primary-red);
17-
width: 4pt;
12+
.bar-list-container {
13+
display: flex;
14+
align-items: stretch;
15+
height: 10rem;
16+
17+
.bar-container {
18+
display: flex;
19+
align-items: flex-end;
20+
flex-basis: 0;
21+
flex-grow: 1;
22+
justify-content: center;
23+
transition: var(--go-ui-duration-transition-medium) background-color ease-in-out;
24+
border-top-left-radius: 2pt;
25+
border-top-right-radius: 2pt;
26+
background-color: transparent;
27+
28+
.bar {
29+
background-color: var(--go-ui-color-primary-red);
30+
width: 4pt;
31+
height: 100%;
32+
}
33+
34+
&:hover {
35+
background-color: var(--go-ui-color-background-hover);
36+
}
37+
}
38+
}
39+
40+
.chart-label {
41+
text-align: center;
42+
color: var(--go-ui-color-text-light);
43+
font-size: var(--go-ui-font-size-sm);
44+
font-weight: var(--go-ui-font-weight-medium);
1845
}
1946
}
2047

0 commit comments

Comments
 (0)