From b8ff1abed0652e8f8b55f05b80230e1768f0b884 Mon Sep 17 00:00:00 2001 From: Liam Arbuckle Date: Tue, 16 Apr 2024 10:29:57 +0800 Subject: [PATCH] =?UTF-8?q?=E2=AD=90=EF=B8=8F=F0=9F=92=8D=20=E2=86=9D=20[S?= =?UTF-8?q?GV2-182]:=20Ringed=20layouts=20are=20back,=20baby!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- components/_Core/Section/Navbar.tsx | 5 +- pages/tests/planetRing.tsx | 158 +++++++++++++++++++++++++++- 2 files changed, 159 insertions(+), 4 deletions(-) diff --git a/components/_Core/Section/Navbar.tsx b/components/_Core/Section/Navbar.tsx index 525f2b33..cafa3c62 100644 --- a/components/_Core/Section/Navbar.tsx +++ b/components/_Core/Section/Navbar.tsx @@ -565,5 +565,6 @@ export function Navbar() { - ) -} \ No newline at end of file + ); +}; + diff --git a/pages/tests/planetRing.tsx b/pages/tests/planetRing.tsx index 23ba5445..2d876efd 100644 --- a/pages/tests/planetRing.tsx +++ b/pages/tests/planetRing.tsx @@ -1,5 +1,159 @@ -export default function PlanetRingTestPage() { +import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react"; +import React, { useEffect, useState } from "react"; +import { useMediaQuery } from "react-responsive"; +import { LayoutNoNav } from "../../components/_Core/Section/Layout"; + +export default function PlanetRingTestPage() { // This should actually be written as a component, not as a page, and then returned with the arguments when in mobile mode, but this doesn't really matter for the moment + const supabase = useSupabaseClient(); + const session = useSession(); + + const planetId = '2'; + const [planetData, setPlanetData] = useState(null); + const [screenWidth, setScreenWidth] = useState(0); // State to store screenWidth + + useEffect(() => { + if (planetId) { + getPlanetData(); + } + }, [session]); + + useEffect(() => { + // This useEffect runs only on client side after the component mounts + const handleResize = () => { + setScreenWidth(window.innerWidth); + }; + handleResize(); // Initial call to set the initial screenWidth + window.addEventListener("resize", handleResize); + return () => { + window.removeEventListener("resize", handleResize); + }; + }, []); // Empty dependency array ensures this effect runs only once after component mount + + const getPlanetData = async () => { + try { + const { data, error } = await supabase + .from("basePlanets") + .select("*") + .eq("id", planetId) + .single(); + + if (data) { + setPlanetData(data); + } + + if (error) { + throw error; + } + } catch (error) { + console.error(error.message); + } + }; + + const isTabletOrMobile = useMediaQuery({ query: '(max-width: 1224px)' }); + + if (!planetData) { + return
Loading...
; + } + + const { avatar_url } = planetData; + + const planetSizeMobile = 8; // 8% of the screen size + const planetSizeDesktop = 14; // 14% of the screen size + const ringSizeFactor = 2.12; // Start rings around 2 times the size of the planet image + const ringCount = 3; // Number of rings + return ( - <>p + +
+ +
+
+ {/* {planetPosts?.length > 0 && + planetPosts.map((post) => ( + + ))} */} + + {/* Rings */} + {[...Array(ringCount)].map((_, index) => ( +
+ {index === 0 && ( + Telescope Icon + )} + {index === 1 && ( + Telescope Icon + )} + {index === 2 && ( + Telescope Icon + )} + {index === 2 && ( + Telescope Icon + )} +
+ ))} + + Planet Image +
+
+
); }; \ No newline at end of file