Skip to content

Commit

Permalink
πŸŽ³πŸ’³ ↝ Add planetary orbitals
Browse files Browse the repository at this point in the history
  • Loading branch information
Gizmotronn committed Nov 29, 2023
1 parent 000c3c2 commit 0c42dc2
Show file tree
Hide file tree
Showing 15 changed files with 480 additions and 18 deletions.
Binary file modified .DS_Store
Binary file not shown.
118 changes: 116 additions & 2 deletions components/Content/CreatePostForm.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,117 @@
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import { Button } from "../ui/Button";
// import { Card }
// Look into methods to engage resource gathering with the lightcurves, make it a scrollable feed with planet content, show how the curves lead into the rover.
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from "../ui/Card";
import { Form, FormControl, FormField, FormItem, FormMessage } from "../ui/Form";
import { Textarea } from "../ui/TextArea";
import { useToast } from "../ui/use-toast";
import { zodResolver } from "@hookform/resolvers/zod";
import { VenetianMask } from "lucide-react";
import React, { useContext, useEffect, useState} from "react";
import { useForm } from "react-hook-form";
import { z } from "zod";
import { UserContext } from "../../context/UserContext";
import { useRouter } from "next/router";
import { Avatar, AvatarFallback } from "../ui/Avatar";
import { AvatarImage } from "@radix-ui/react-avatar";

type TProps = {
category_id: "1" | "2",
openCreateMenu: boolean;
setOpenCreateMenu: (value: React.SetStateAction<boolean>) => void;
setCreatedPost: (value: React.SetStateAction<boolean>) => void;
};

export default function CreatePostForm ( { planetId2 } ) { // category_id
const supabase = useSupabaseClient();
const session = useSession();

const [postContent, setPostContent] = useState('')
const profile = useContext(UserContext);
const [username, setUsername] = useState('');

const [uploads, SetUploads] = useState('');
const [isUploading, setIsUploading] = useState(false);
const [avatar_url, setAvatarUrl] = useState(null);
const [userExperience, setUserExperience] = useState();
// const [hasRequiredItem, setHasRequiredItem] = useState(false);

function createPost() {
supabase
.from('posts_duplicates')
.insert({
author: session?.user?.id,
content: postContent,
media: uploads,
planets2: planetId2,
})
};

useEffect(() => {
supabase
.from('profiles')
.select(`avatar_url, experience, username`)
.eq('id', session?.user?.id)
.then(result => {
setAvatarUrl(result?.data[0]?.avatar_url);
setUsername(result?.data[0]?.username);
});
}, [session]);

// async function addMedia ( e ) {
// const files = e.target.files;
// if (files.length > 0) {
// setIsUploading(true);
// for (const file of files) { // To-Do: List of user's photos from the image gallery in wb3-10
// const fileName = Date.now() + session?.user?.id + file.name; // Generate a random string to make the file unique
// const result = await supabase.storage
// .from('media') // Upload the file/media
// .upload(fileName, file);

// if (result.data) {
// const url = process.env.NEXT_PUBLIC_SUPABASE_URL + '/storage/v1/object/public/media/' + result.data.path;
// SetUploads(prevUploads => [...prevUploads, url]); // Add the most recently uploaded image to an array of images that are in state
// } else {
// console.log(result);
// }
// }
// setIsUploading(false);
// }
// }

const form = useForm({
defaultValues: {
content: "",
},
});

return (
<>
<div className="flex gap-2">
<Avatar>
{/* <AvatarImage src={"https://qwbufbmxkjfaikoloudl.supabase.co/storage/v1/object/public/avatars/" + avatar_url ?? ""}> */}
<AvatarFallback>{username}</AvatarFallback>
{/* </AvatarImage> */}
</Avatar>
</div>
{/* <CardContent className="p-0 pt-2">
<Form {...form}>
</Form>
</CardContent> */}
<textarea value={postContent} onChange={e => setPostContent(e.target.value)} className="grow p-3 h-24 rounded-xl" placeholder={"What do you think about this candidate"} />
{/* {uploads.length > 0 && (
<div className="flex gap-2 mt-4">
{uploads.map(upload => (
<div className=""><img src={upload} className="w-auto h-48 rounded-md" />
))}
</div>
)} */}
{/* <div className={`fixed inset-0 bg-white/80 backdrop-blur-md z-20 items-center justify-center`}> */}
{/* <Card> */}
{/* </Card> */}
{/* </div> */}
</>
)
}

// Look into methods to engage resource gathering with the lightcurves, make it a scrollable feed with planet content, show how the curves lead into the rover.
2 changes: 1 addition & 1 deletion components/Content/Planets/GalleryList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default function PlanetGallery() {
.order("created_at", { ascending: false })
.limit(200)
.gte("id", 67)
.lt("id", 69);
.lt("id", 75);

const { data, error } = await query;

Expand Down
46 changes: 33 additions & 13 deletions components/Content/Planets/IndividualPlanet.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { useRouter } from "next/router";
import React, { useState, useEffect, useRef } from "react";
import { useSession, useSupabaseClient } from "@supabase/auth-helpers-react";
import { UserContext } from "../../../context/UserContext";
import Layout from "../../Section/Layout";
import { LayoutNoNav } from "../../Section/Layout";
import CardForum from "../DiscussCard";

enum SidebarLink {
Expand Down Expand Up @@ -41,8 +41,6 @@ export default function IndividualPlanet({ id }: { id: string }) {
setShowSidebar(screenWidth >= 800);
}, [screenWidth]);

const planetCover = "https://qwbufbmxkjfaikoloudl.supabase.co/storage/v1/object/public/planets/" + id + "/download.png";

useEffect(() => {
if (planetId) {
getPlanetData();
Expand Down Expand Up @@ -93,17 +91,39 @@ export default function IndividualPlanet({ id }: { id: string }) {
};

const { content, avatar_url, cover } = planetData;
const rings = [2, 3, 4];

return (
<Layout>
<div className="mb-7"><center><img height="20%" width="20%" src={cover} /></center></div>
{planetPosts?.length > 0 &&
planetPosts.map((post) => (
<>
<CardForum key={post.id} {...post} />
</>
))
}
</Layout>
<LayoutNoNav>
<div style={{ backgroundImage: `url('/bg.jpg')` }} className="bg-cover bg-center h-screen flex items-center justify-center relative">
<div className="mb-7 flex items-center justify-center h-screen relative">
{rings.map((radius, index) => (
<div
key={index}
className="absolute border-white border-solid border-2 rounded-full"
style={{
width: `${(radius * 24) / 100 * screenWidth}px`,
height: `${(radius * 24) / 100 * screenWidth}px`,
top: "50%",
left: "50%",
transform: "translate(-50%, -50%)",
}}
></div>
))}
<img
src={avatar_url}
alt="Planet Image"
className="w-4/12 h-4/12 object-contain z-10"
/>
</div>
{planetPosts?.length > 0 &&
planetPosts.map((post) => (
<>
<CardForum key={post.id} {...post} />
</>
))
}
</div>
</LayoutNoNav>
);
};
82 changes: 82 additions & 0 deletions components/ui/Card.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
import * as React from "react";
import { cn } from "../../lib/uitls";

const Card = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn(
"rounded-xl border bg-card text-card-foreground shadow",
className,
)}
{...props}
/>
));
Card.displayName = "Card";

const CardHeader = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex flex-col space-y-1.5 p-6", className)}
{...props}
/>
));
CardHeader.displayName = "CardHeader";

const CardTitle = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLHeadingElement>
>(({ className, ...props }, ref) => (
<h3
ref={ref}
className={cn("font-semibold leading-none tracking-tight", className)}
{...props}
/>
));
CardTitle.displayName = "CardTitle";

const CardDescription = React.forwardRef<
HTMLParagraphElement,
React.HTMLAttributes<HTMLParagraphElement>
>(({ className, ...props }, ref) => (
<p
ref={ref}
className={cn("text-sm text-muted-foreground", className)}
{...props}
/>
));
CardDescription.displayName = "CardDescription";

const CardContent = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div ref={ref} className={cn("p-6 pt-0", className)} {...props} />
));
CardContent.displayName = "CardContent";

const CardFooter = React.forwardRef<
HTMLDivElement,
React.HTMLAttributes<HTMLDivElement>
>(({ className, ...props }, ref) => (
<div
ref={ref}
className={cn("flex items-center p-6 pt-0", className)}
{...props}
/>
));
CardFooter.displayName = "CardFooter";

export {
Card,
CardHeader,
CardFooter,
CardTitle,
CardDescription,
CardContent,
};
Loading

0 comments on commit 0c42dc2

Please sign in to comment.