Skip to content

Commit b8ff1ab

Browse files
committed
⭐️💍 ↝ [SGV2-182]: Ringed layouts are back, baby!
1 parent 7e0cf70 commit b8ff1ab

File tree

2 files changed

+159
-4
lines changed

2 files changed

+159
-4
lines changed

components/_Core/Section/Navbar.tsx

+3-2
Original file line numberDiff line numberDiff line change
@@ -565,5 +565,6 @@ export function Navbar() {
565565
</Dialog.Panel>
566566
</Dialog>
567567
</header>
568-
)
569-
}
568+
);
569+
};
570+

pages/tests/planetRing.tsx

+156-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,159 @@
1-
export default function PlanetRingTestPage() {
1+
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
2+
import React, { useEffect, useState } from "react";
3+
import { useMediaQuery } from "react-responsive";
4+
import { LayoutNoNav } from "../../components/_Core/Section/Layout";
5+
6+
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
7+
const supabase = useSupabaseClient();
8+
const session = useSession();
9+
10+
const planetId = '2';
11+
const [planetData, setPlanetData] = useState<any>(null);
12+
const [screenWidth, setScreenWidth] = useState<number>(0); // State to store screenWidth
13+
14+
useEffect(() => {
15+
if (planetId) {
16+
getPlanetData();
17+
}
18+
}, [session]);
19+
20+
useEffect(() => {
21+
// This useEffect runs only on client side after the component mounts
22+
const handleResize = () => {
23+
setScreenWidth(window.innerWidth);
24+
};
25+
handleResize(); // Initial call to set the initial screenWidth
26+
window.addEventListener("resize", handleResize);
27+
return () => {
28+
window.removeEventListener("resize", handleResize);
29+
};
30+
}, []); // Empty dependency array ensures this effect runs only once after component mount
31+
32+
const getPlanetData = async () => {
33+
try {
34+
const { data, error } = await supabase
35+
.from("basePlanets")
36+
.select("*")
37+
.eq("id", planetId)
38+
.single();
39+
40+
if (data) {
41+
setPlanetData(data);
42+
}
43+
44+
if (error) {
45+
throw error;
46+
}
47+
} catch (error) {
48+
console.error(error.message);
49+
}
50+
};
51+
52+
const isTabletOrMobile = useMediaQuery({ query: '(max-width: 1224px)' });
53+
54+
if (!planetData) {
55+
return <div>Loading...</div>;
56+
}
57+
58+
const { avatar_url } = planetData;
59+
60+
const planetSizeMobile = 8; // 8% of the screen size
61+
const planetSizeDesktop = 14; // 14% of the screen size
62+
const ringSizeFactor = 2.12; // Start rings around 2 times the size of the planet image
63+
const ringCount = 3; // Number of rings
64+
265
return (
3-
<>p</>
66+
<LayoutNoNav>
67+
<div className="h-screen relative z-10">
68+
<style jsx global>
69+
{`
70+
body {
71+
background: url('/garden.png') center/cover;
72+
);
73+
}
74+
@media only screen and (max-width: 1000px) {
75+
body {
76+
background: url('/void.png') center/cover;
77+
}
78+
}
79+
@media only screen and (max-width: 767px) {
80+
.planet-heading {
81+
color: white;
82+
font-size: 24px;
83+
text-align: center;
84+
margin-bottom: 10px;
85+
}
86+
`}
87+
</style>
88+
<div className="bg-cover bg-center h-screen flex items-center justify-center relative">
89+
<div className="underline"></div>
90+
{/* {planetPosts?.length > 0 &&
91+
planetPosts.map((post) => (
92+
<CardForum key={post.id} {...post} />
93+
))} */}
94+
95+
{/* Rings */}
96+
{[...Array(ringCount)].map((_, index) => (
97+
<div
98+
key={index}
99+
className="absolute border-solid border-2 rounded-full"
100+
style={{
101+
width: `${
102+
((planetSizeDesktop * ringSizeFactor * (index + 1)) / 100) *
103+
screenWidth
104+
}px`,
105+
height: `${
106+
((planetSizeDesktop * ringSizeFactor * (index + 1)) / 100) *
107+
screenWidth
108+
}px`,
109+
top: "50%",
110+
left: "50%",
111+
transform: "translate(-50%, -50%)",
112+
zIndex: 10,
113+
border: `1px solid rgba(255, 255, 255, 0.5)`,
114+
}}
115+
>
116+
{index === 0 && (
117+
<img
118+
src="https://github.com/Signal-K/client/blob/CPW-8/public/assets/Inventory/Items/GoldenTelescopeLevel1noBg.png?raw=true"
119+
alt="Telescope Icon"
120+
className="w-12 h-12 absolute top-1 left-12 transform -translate-x-1/2 -translate-y-1/2"
121+
/>
122+
)}
123+
{index === 1 && (
124+
<img
125+
src="https://raw.githubusercontent.com/Signal-K/client/main/public/assets/Inventory/Items/AeroCameraLevel1NoBg.png"
126+
alt="Telescope Icon"
127+
className="w-12 h-12 absolute top-8 right-4 transform -translate-x-1/2 -translate-y-1/2"
128+
/>
129+
)}
130+
{index === 2 && (
131+
<img
132+
src="https://qwbufbmxkjfaikoloudl.supabase.co/storage/v1/object/public/planets/69/Kepler22.png"
133+
alt="Telescope Icon"
134+
className="w-8 h-8 absolute bottom-20 left-8 transform"
135+
/>
136+
)}
137+
{index === 2 && (
138+
<img
139+
src="https://qwbufbmxkjfaikoloudl.supabase.co/storage/v1/object/public/planets/72/Trappist.png"
140+
alt="Telescope Icon"
141+
className="w-20 h-16 absolute bottom-1 right-2 transform -translate-x-1/2 -translate-y-1/2"
142+
/>
143+
)}
144+
</div>
145+
))}
146+
147+
<img
148+
src={avatar_url}
149+
alt="Planet Image"
150+
className={`w-2/12 h-2/12 sm:w-2/12 sm:h-2/12 object-contain z-20`}
151+
style={{
152+
zIndex: 20,
153+
}}
154+
/>
155+
</div>
156+
</div>
157+
</LayoutNoNav>
4158
);
5159
};

0 commit comments

Comments
 (0)