From 66345091a79218944b640e27f5b30bf2bdb8ba07 Mon Sep 17 00:00:00 2001 From: EliasKnudsen <38568225+EliasKnudsen@users.noreply.github.com> Date: Wed, 17 Apr 2024 14:25:22 +0200 Subject: [PATCH] 308 make homepage responsive (#313) * Satellite sdatahome responsive on phones 300 max screen width #308 * Responsivness * Fix table on satellites to be more responsive #308 * Lint and prettier #308 * Navbar aschild --- frontend/src/app/page.tsx | 2 +- frontend/src/app/satellites/page.tsx | 54 ++---------------- frontend/src/components/Navbar.tsx | 39 ++++++++----- .../components/SatelliteResponsiveTable.tsx | 57 +++++++++++++++++++ .../satelliteData/SatelliteDataHome.tsx | 10 ++-- .../satelliteData/SatelliteStatsTableRow.tsx | 31 ++++++---- frontend/tailwind.config.ts | 4 ++ 7 files changed, 119 insertions(+), 78 deletions(-) create mode 100644 frontend/src/components/SatelliteResponsiveTable.tsx diff --git a/frontend/src/app/page.tsx b/frontend/src/app/page.tsx index f23b569..cc36579 100644 --- a/frontend/src/app/page.tsx +++ b/frontend/src/app/page.tsx @@ -25,7 +25,7 @@ export default async function Home() { <>
{/* Stats Container */} -
+
diff --git a/frontend/src/app/satellites/page.tsx b/frontend/src/app/satellites/page.tsx index 4502e7b..958067d 100644 --- a/frontend/src/app/satellites/page.tsx +++ b/frontend/src/app/satellites/page.tsx @@ -1,18 +1,6 @@ import { gql } from "@/__generated__/gql"; -import { - PageHeaderAndSubtitle, - PageHeader, - PageSubtitle, -} from "@/components/PageHeader"; -import SatelliteStatsTableRow from "@/components/satelliteData/SatelliteStatsTableRow"; import { getClient } from "@/lib/ApolloClient"; -import { - Table, - TableBody, - TableHead, - TableHeader, - TableRow, -} from "@/components/shadcn/table"; +import SatelliteResponsiveTable from "@/components/SatelliteResponsiveTable"; const GET_SATELLITES = gql(` query GET_SATELLITES { @@ -45,41 +33,11 @@ export default async function Satellites() { }); return ( -
- - Satellites - - Here are the satellites we have worked on. Click on them - to see more details. - - - - - - Satellite - Speed - Altitude - Latitude - Longitude - - - - {graphqlData?.data?.satellites?.data?.map( - (satellite: any) => { - let satelliteName = - satellite?.attributes?.name ?? ""; - return ( - - ); - }, - )} - -
-
+ <> + + ); } catch (error) { console.error("Error fetching satellites:", error); diff --git a/frontend/src/components/Navbar.tsx b/frontend/src/components/Navbar.tsx index 444d5ed..8861eb9 100644 --- a/frontend/src/components/Navbar.tsx +++ b/frontend/src/components/Navbar.tsx @@ -6,6 +6,7 @@ import { Drawer, DrawerContent, DrawerTrigger, + DrawerClose, } from "@/components/shadcn/drawer"; import Image from "next/image"; @@ -126,16 +127,20 @@ export default function Navbar() { return "ghost"; }; + const handleHomeClick = () => { + window.location.href = "/"; + }; + return (
diff --git a/frontend/src/components/SatelliteResponsiveTable.tsx b/frontend/src/components/SatelliteResponsiveTable.tsx new file mode 100644 index 0000000..2462ad0 --- /dev/null +++ b/frontend/src/components/SatelliteResponsiveTable.tsx @@ -0,0 +1,57 @@ +"use client"; +import { + PageHeaderAndSubtitle, + PageHeader, + PageSubtitle, +} from "@/components/PageHeader"; +import SatelliteStatsTableRow from "@/components/satelliteData/SatelliteStatsTableRow"; +import { + Table, + TableBody, + TableHead, + TableHeader, + TableRow, +} from "@/components/shadcn/table"; + +export default function SatelliteResponsiveTable({ satellites }: any) { + return ( +
+ + Satellites + + Here are the satellites we have worked on. Click on them to + see more details. + + + + + + Satellite + Speed + + Altitude + + + Latitude + + + Longitude + + + + + {satellites.map((satellite: any) => { + let satelliteName = satellite?.attributes?.name ?? ""; + return ( + + ); + })} + +
+
+ ); +} diff --git a/frontend/src/components/satelliteData/SatelliteDataHome.tsx b/frontend/src/components/satelliteData/SatelliteDataHome.tsx index 687c5d4..79e58c4 100644 --- a/frontend/src/components/satelliteData/SatelliteDataHome.tsx +++ b/frontend/src/components/satelliteData/SatelliteDataHome.tsx @@ -42,8 +42,8 @@ export default function SatelliteDataHome() { return (
-
-
+
+

{satelliteInfo ? satelliteInfo.velocity + " km/s" @@ -51,7 +51,7 @@ export default function SatelliteDataHome() {

Velocity

-
+

{satelliteInfo ? satelliteInfo.altitude + " km" @@ -59,7 +59,7 @@ export default function SatelliteDataHome() {

Altitude

-
+

{satelliteInfo ? satelliteInfo.latitudeDeg + "° N" @@ -67,7 +67,7 @@ export default function SatelliteDataHome() {

Latitude

-
+

{satelliteInfo ? satelliteInfo.longitudeDeg + "° E" diff --git a/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx b/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx index b6c3097..8c2acaf 100644 --- a/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx +++ b/frontend/src/components/satelliteData/SatelliteStatsTableRow.tsx @@ -46,10 +46,10 @@ export default function SatelliteStatsTableRow({ return ( Loading... - Loading... - Loading... - Loading... - Loading... + Loading... + Loading... + Loading... + Loading... ); } @@ -61,19 +61,30 @@ export default function SatelliteStatsTableRow({ return ( - {satName} - + + {satName} + + {satelliteInfo.velocity + " km/s"} - + {satelliteInfo.altitude + " km"} - + {satelliteInfo.latitudeDeg + "° N"} - + {satelliteInfo.longitudeDeg + "° E"} diff --git a/frontend/tailwind.config.ts b/frontend/tailwind.config.ts index 06e306a..2b872d3 100644 --- a/frontend/tailwind.config.ts +++ b/frontend/tailwind.config.ts @@ -18,6 +18,10 @@ const config = { }, }, extend: { + screens: { + xs: "400px", + xxs: "300px", + }, colors: { // These should all be defined in the global CSS file and used with the var(--color) syntax. Preferably using hsl border: "var(--border)",