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