Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

👀✍🏻 ↝ Archived section #87

Merged
merged 1 commit into from
Dec 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
104 changes: 99 additions & 5 deletions components/Content/Planets/GalleryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import React, { useEffect, useState } from "react";
import Link from "next/link";
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import Login from "../../../pages/login";
import { GardenSidebar } from "../../Section/Sidebar";

interface Planet {
id: string;
Expand All @@ -26,6 +27,18 @@ export function PlanetGalleryCard({ planet, position }: Props) {
);
}

function ArchivedPlanetGalleryCard({ planet, position }: Props) {
const { id, content, cover } = planet;

return (
<Link legacyBehavior href={`https://starprotocol-og3j6xuus-gizmotronn.vercel.app/tests/planets/${id}`}>
<a style={{ position: "absolute", top: position.top, left: position.left }}>
<img src={cover} className="w-1/2" />
</a>
</Link>
);
}

export default function PlanetGallery() {
const supabase = useSupabaseClient();
const session = useSession();
Expand All @@ -35,14 +48,81 @@ export default function PlanetGallery() {
getPlanets();
}, [session]);

const getPlanets = async (): Promise<void> => {
try {
let query = supabase
// .from("planetsss")
.from("basePlanets")
.select("*")
.order("created_at", { ascending: false })
.limit(200)
// .gte("id", 67)
// .lt("id", 75);

const { data, error } = await query;

if (data != null) {
setPlanets(data);
console.log(planets);
}

if (error) {
throw error;
}
} catch (error: any) {
alert(error.message);
}
};

const getRandomPosition = (): { top: number; left: number } => {
const top = Math.floor(Math.random() * window.innerHeight);
const left = Math.floor(Math.random() * window.innerWidth);
return { top, left };
};

const buttonStyle = {
backgroundColor: "rgba(255, 255, 255, 0.2)",
border: "none",
color: "black",
transition: "background-color 0.3s ease",
cursor: "pointer",
marginRight: "8px",
};

const activeButtonStyle = {
backgroundColor: "rgba(255, 255, 255, 0.3)",
};

if (!session) {
return <Login />;
}

return (
<>
{planets.map((planet, index) => (
<PlanetGalleryCard key={planet.id} planet={planet} position={getRandomPosition()} />
))}
</>
);
}

export function ArchivedPlanetGallery() {
const supabase = useSupabaseClient();
const session = useSession();
const [planets, setPlanets] = useState<Planet[]>([]);

useEffect(() => {
getPlanets();
}, [session]);

const getPlanets = async (): Promise<void> => {
try {
let query = supabase
.from("planetsss")
.select("*")
.order("created_at", { ascending: false })
.limit(200)
.gte("id", 67)
.gte("id", 1)
.lt("id", 75);

const { data, error } = await query;
Expand Down Expand Up @@ -85,16 +165,30 @@ export default function PlanetGallery() {
return (
<>
{planets.map((planet, index) => (
<PlanetGalleryCard key={planet.id} planet={planet} position={getRandomPosition()} />
<ArchivedPlanetGalleryCard key={planet.id} planet={planet} position={getRandomPosition()} />
))}
</>
);
}

export const Garden: React.FC = () => {
return (
<div style={{ backgroundImage: `url('/garden.png')` }} className="bg-cover bg-center h-screen flex items-center justify-center relative">
<PlanetGallery />
</div>
<>
<div style={{ backgroundImage: `url('/garden.png')` }} className="bg-cover bg-center h-screen flex items-center justify-center relative">
<GardenSidebar />
<PlanetGallery />
</div>
</>
);
};

export const ArchivedGarden: React.FC = () => {
return (
<>
<div style={{ backgroundImage: `url('/garden.png')` }} className="bg-cover bg-center h-screen flex items-center justify-center relative">
<GardenSidebar />
<ArchivedPlanetGallery />
</div>
</>
);
};
56 changes: 46 additions & 10 deletions components/Section/Layout.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import Sidebar from "./Sidebar";
import Sidebar, { DesktopSidebar } from "./Sidebar";
import Navbar from "./Navbar";
import React, { ReactNode, useEffect, useState } from "react";
import Bottombar from "../Core/BottomBar";
Expand Down Expand Up @@ -26,22 +26,58 @@ const Layout: React.FC<DashboardLayoutProps> = ({ children }) => {

return (
<>
<Navbar />
<div className="flex relative items-start">
<Sidebar />
<main className="h-max pb-10 grow">{children}</main>
{isMobile && (
<div className="w-full md:hidden fixed bottom-0 left-0 z-50">
<Bottombar />
</div>
)}
<div className="hidden md:flex relative items-start">
<DesktopSidebar />
<main className="h-max pb-10 grow ml-64 pt-6">
{/* <Navbar /> */}
{children}
</main>
</div>
{isMobile && (
<div className="md:hidden overflow-y-auto h-screen p-4">
<main className="h-max pb-10 grow">{children}</main>
<Bottombar />
</div>
)}
</>
);
};

export default Layout;

export const GardenLayout: React.FC<DashboardLayoutProps> = ({ children }) => {
const [isMobile, setIsMobile] = useState(false);

useEffect(() => {
// Check if window is defined before accessing it
if (typeof window !== "undefined") {
const checkIsMobile = () => {
setIsMobile(window.innerWidth <= 768);
};
checkIsMobile();
window.addEventListener("resize", checkIsMobile);
return () => {
window.removeEventListener("resize", checkIsMobile);
};
}
}, []);

return (
<>
<main className="grow pt-6">
{/* <DesktopSidebar /> */}
{children}
</main>
{isMobile && (
<div className="md:hidden overflow-y-auto h-screen p-4">
<main className="h-max pb-10 grow">{children}</main>
<Bottombar />
</div>
)}
</>
);
};

export const LayoutNoNav: React.FC<DashboardLayoutProps> = ({ children }) => {
const [isMobile, setIsMobile] = useState(false);

Expand Down
Loading
Loading