diff --git a/ui/src/components/Metars/MapTiles.tsx b/ui/src/components/Metars/MapTiles.tsx index e1a490b..49ad0ed 100644 --- a/ui/src/components/Metars/MapTiles.tsx +++ b/ui/src/components/Metars/MapTiles.tsx @@ -14,6 +14,7 @@ export default function MapTiles() { const [isOpen, setIsOpen] = useState(false); const [airports, setAirports] = useState([]); const [selectedAirport, setSelectedAirport] = useState(); + // eslint-disable-next-line @typescript-eslint/no-unused-vars const [zoomLevel, setZoomLevel] = useState(8); // const [dragging, setDragging] = useState(false); const map = useMap(); @@ -59,70 +60,29 @@ export default function MapTiles() { setAirports(_airports); } - function iconSize() { - if (zoomLevel <= 5) { - return 'xs'; - } else { - return 'sm'; - } - } - function metarIcon(airport: Airport) { + function innerIcon({ tag, color, size = 'sm' }: { tag: string; color: string; size?: string }) { + return new DivIcon({ + html: ReactDOMServer.renderToString( + + + {tag} + + + ), + className: 'metar-marker-icon' + }); + } if (airport.metar?.flight_category == 'VFR') { - return new DivIcon({ - html: ReactDOMServer.renderToString( - - - V - - - ), - className: 'metar-marker-icon' - }); + return innerIcon({ tag: 'V', color: 'green' }); } else if (airport.metar?.flight_category == 'MVFR') { - return new DivIcon({ - html: ReactDOMServer.renderToString( - - - M - - - ), - className: 'metar-marker-icon' - }); + return innerIcon({ tag: 'M', color: 'blue' }); } else if (airport.metar?.flight_category == 'IFR') { - return new DivIcon({ - html: ReactDOMServer.renderToString( - - - I - - - ), - className: 'metar-marker-icon' - }); + return innerIcon({ tag: 'I', color: 'red' }); } else if (airport.metar?.flight_category == 'LIFR') { - return new DivIcon({ - html: ReactDOMServer.renderToString( - - - L - - - ), - className: 'metar-marker-icon' - }); + return innerIcon({ tag: 'L', color: 'purple' }); } else { - return new DivIcon({ - html: ReactDOMServer.renderToString( - - - U - - - ), - className: 'metar-marker-icon' - }); + return innerIcon({ tag: 'U', color: 'black', size: 'xs' }); } } diff --git a/ui/src/components/Metars/MetarModal.tsx b/ui/src/components/Metars/MetarModal.tsx index 76ed111..c8be480 100644 --- a/ui/src/components/Metars/MetarModal.tsx +++ b/ui/src/components/Metars/MetarModal.tsx @@ -85,15 +85,15 @@ export default function MetarModal({ airport, isOpen, onClose }: MetarModalProps function MetarInfo({ metar }: { metar: Metar }) { function metarBGColor(metar: Metar | undefined) { if (metar?.flight_category == 'VFR') { - return 'bg-emerald-600'; + return 'green'; } else if (metar?.flight_category == 'MVFR') { - return 'bg-blue-600'; + return 'blue'; } else if (metar?.flight_category == 'IFR') { - return 'bg-red-600'; + return 'red'; } else if (metar?.flight_category == 'LIFR') { - return 'bg-purple-600'; + return 'purple'; } else { - return 'bg-black'; + return 'black'; } } @@ -121,16 +121,23 @@ function MetarInfo({ metar }: { metar: Metar }) { return (
-

{metar.raw_text}

+

{metar.raw_text}

- + {metar.flight_category ? metar.flight_category : 'UNKN'} + + {metar.wind_speed_kt != undefined && metar.wind_speed_kt > 0 ? `${metar.wind_speed_kt} KT` : 'CALM'} + + {/* {metar.sky_condition != undefined && metar.sky_condition.map((skyCondition) => <>test)} */} {metar.wx_string && metar.wx_string.split(' ').map((wx) => )} diff --git a/ui/src/components/Topbar/index.tsx b/ui/src/components/Topbar/index.tsx index 7b190be..c1b98dc 100644 --- a/ui/src/components/Topbar/index.tsx +++ b/ui/src/components/Topbar/index.tsx @@ -4,14 +4,14 @@ import Link from 'next/link'; import { AiOutlineUser } from 'react-icons/ai'; import { useState } from 'react'; import { getAirports } from '@/api/airport'; -// import { useRouter } from 'next/navigation'; +import { useRouter } from 'next/navigation'; import { Autocomplete, Avatar } from '@mantine/core'; import './topbar.css'; export default function Topbar() { const [searchValue, setSearchValue] = useState(''); const [airports, setAirports] = useState<{ key: string; value: string; label: string }[]>([]); - // const router = useRouter(); + const router = useRouter(); async function onChange(value: string) { setSearchValue(value); @@ -25,9 +25,10 @@ export default function Topbar() { ); } - // function onClick(value: string) { - // router.push(`/airport/${value}`); - // } + function onClick(value: string) { + router.push(`/airport/${value}`); + setSearchValue(''); + } return (
- + diff --git a/ui/src/components/Topbar/topbar.css b/ui/src/components/Topbar/topbar.css index 62f7ed4..a89ff33 100644 --- a/ui/src/components/Topbar/topbar.css +++ b/ui/src/components/Topbar/topbar.css @@ -2,6 +2,8 @@ display: flex; justify-content: space-between; height: 46px; + background-color: #0057a3; + color: white; } .navbar .left { @@ -16,4 +18,10 @@ .navbar .left .search { margin: auto; +} + +.navbar .avatar { + padding-right: 2em; + margin-top: auto; + margin-bottom: auto; } \ No newline at end of file