@@ -12,7 +12,6 @@ import React from "react";
1212import { notEmpty } from "../../../helpers/array" ;
1313import { capitalizeFirstLetter } from "../../../helpers/string" ;
1414import {
15- determineCeilingFromClouds ,
1615 FlightCategory ,
1716 formatDescriptive ,
1817 formatHeight ,
@@ -26,12 +25,15 @@ import {
2625} from "../../../helpers/taf" ;
2726import { useAppSelector } from "../../../hooks" ;
2827import { timeZoneSelector } from "../weatherSlice" ;
29- import Cloud from "./Cloud" ;
3028import Wind from "./cells/Wind" ;
3129import WindShear from "./cells/WindShear" ;
3230import { TimeFormat } from "../../user/userSlice" ;
31+ import Clouds from "./cells/Clouds" ;
32+ import Ceiling from "./cells/Ceiling" ;
3333
34- const Container = styled . div < { type : WeatherChangeType | undefined } > `
34+ export const Container = styled . div < {
35+ type : WeatherChangeType | undefined | "METAR" ;
36+ } > `
3537 padding: 1rem;
3638 display: flex;
3739 flex-direction: column;
@@ -54,22 +56,26 @@ const Container = styled.div<{ type: WeatherChangeType | undefined }>`
5456 return css `
5557 border-left-color: #0095ff5d;
5658 ` ;
59+ case "METAR" :
60+ return css `
61+ border-left-color: #6d0050;
62+ ` ;
5763 }
5864 } }
5965` ;
6066
61- const Header = styled . div `
67+ export const Header = styled . div `
6268 display: flex;
6369 justify-content: space-between;
6470 align-items: flex-start;
6571 margin-bottom: -0.25rem;
6672` ;
6773
68- const Text = styled . p `
74+ export const Text = styled . p `
6975 margin: 0;
7076` ;
7177
72- const Category = styled . div < { category : FlightCategory } > `
78+ export const Category = styled . div < { category : FlightCategory } > `
7379 display: inline-block;
7480 padding: 2px 8px;
7581
@@ -79,7 +85,7 @@ const Category = styled.div<{ category: FlightCategory }>`
7985 ${ ( { category } ) => getFlightCategoryCssColor ( category ) }
8086` ;
8187
82- const Table = styled . table `
88+ export const Table = styled . table `
8389 width: 100%;
8490 table-layout: fixed;
8591
@@ -95,7 +101,7 @@ const Table = styled.table`
95101 }
96102` ;
97103
98- const Raw = styled . div `
104+ export const Raw = styled . div `
99105 padding: 0.5rem;
100106
101107 background: rgba(0, 0, 0, 0.5);
@@ -114,7 +120,6 @@ export default function Forecast({ data }: ForecastProps) {
114120
115121 if ( ! timeZone ) throw new Error ( "timezone undefined" ) ;
116122
117- const ceiling = determineCeilingFromClouds ( data . clouds ) ;
118123 const category = getFlightCategory (
119124 data . visibility ,
120125 data . clouds ,
@@ -201,15 +206,10 @@ export default function Forecast({ data }: ForecastProps) {
201206 < tr >
202207 < td > Clouds</ td >
203208 < td >
204- { data . clouds . map ( ( cloud , index ) => (
205- < React . Fragment key = { index } >
206- < Cloud data = { cloud } />
207- < br />
208- </ React . Fragment >
209- ) ) }
210- { data . verticalVisibility != null ? (
211- < > Obscured sky</ >
212- ) : undefined }
209+ < Clouds
210+ clouds = { data . clouds }
211+ verticalVisibility = { data . verticalVisibility }
212+ />
213213 </ td >
214214 </ tr >
215215 ) : (
@@ -230,14 +230,10 @@ export default function Forecast({ data }: ForecastProps) {
230230 < tr >
231231 < td > Ceiling</ td >
232232 < td >
233- { ceiling ?. height != null
234- ? `${ formatHeight ( ceiling . height , heightUnit ) } AGL`
235- : data . verticalVisibility
236- ? `Vertical visibility ${ formatHeight (
237- data . verticalVisibility ,
238- heightUnit
239- ) } AGL`
240- : `At least ${ formatHeight ( 12_000 , heightUnit ) } AGL` }
233+ < Ceiling
234+ clouds = { data . clouds }
235+ verticalVisibility = { data . verticalVisibility }
236+ />
241237 </ td >
242238 </ tr >
243239 ) : (
@@ -306,15 +302,17 @@ export default function Forecast({ data }: ForecastProps) {
306302 ) ) }
307303 </ td >
308304 </ tr >
309- ) : undefined }
305+ ) : (
306+ ""
307+ ) }
310308 </ tbody >
311309 </ Table >
312310 < Raw > { data . raw } </ Raw >
313311 </ Container >
314312 ) ;
315313}
316314
317- function formatWeather ( weather : IWeatherCondition [ ] ) : React . ReactNode {
315+ export function formatWeather ( weather : IWeatherCondition [ ] ) : React . ReactNode {
318316 return (
319317 < >
320318 { capitalizeFirstLetter (
0 commit comments