Skip to content

Commit

Permalink
Clean up links page, footer
Browse files Browse the repository at this point in the history
  • Loading branch information
azpha committed Feb 24, 2024
1 parent b236db9 commit 6673154
Show file tree
Hide file tree
Showing 8 changed files with 59 additions and 227 deletions.
20 changes: 0 additions & 20 deletions src/components/RootLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,6 @@ type LayoutProps = {

export default function RootLayout({ children, protectedPage }: LayoutProps) {
const {status} = useSession()
const snowflakeElements = []

for (let i = 0; i < 50; i++) {
snowflakeElements.push(
<div
className="snowflake text-white"
style={
{
left: `${Math.random() * 100}%`,
animationDuration: `${Math.random() *5 + 5}s`,
fontSize: `${Math.random() * 1.5 + 0.5}em`
}
}
>
</div>
)
}

if (protectedPage) {
if (status === "loading") {
Expand All @@ -54,7 +36,6 @@ export default function RootLayout({ children, protectedPage }: LayoutProps) {
return (
<main className="min-h-screen bg-black">
<Head />
{snowflakeElements}
<Header />
{children}
<Footer />
Expand All @@ -65,7 +46,6 @@ export default function RootLayout({ children, protectedPage }: LayoutProps) {
return (
<main className="min-h-screen bg-black">
<Head />
{snowflakeElements}
<Header />
{children}
<Footer />
Expand Down
12 changes: 7 additions & 5 deletions src/components/SocialCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,15 @@ type SocialCardProps = {

export default function SocialMediaCard(props: SocialCardProps) {
return (
<div className="bg-gray-500 rounded-lg text-center max-w-sm p-4 mx-auto">
<Link href={props.url}>
{props.name}
</Link>
<div>
{
props.showDelete && <Trash onClick={props.deleteCallback} color="plain" className="pl-2 hover:cursor-pointer" />
props.showDelete && <Trash onClick={props.deleteCallback} color="white" className="pl-2 hover:cursor-pointer" />
}
<Link href={props.url} target="_blank">
<div className="bg-white py-5 w-full text-left">
<h2 className="px-4 text-lg font-bold">{props.name}</h2>
</div>
</Link>
</div>
)
}
19 changes: 4 additions & 15 deletions src/components/footer.tsx
Original file line number Diff line number Diff line change
@@ -1,29 +1,18 @@
import { Twitter, LinkedinOption } from "grommet-icons"
import Link from 'next/link';

export default function Footer() {
const date = new Date()

return (
<>
<div className="absolute bottom-0 left-0 w-full bg-gray-900 p-2 text-white">
<div className="absolute bottom-0 left-0 w-full bg-zinc-900 p-2 text-white">
<p className="text-center">
<Link href="mailto:[email protected]" className="hover:text-gray-500 hover:underline hover:cursor-pointer">
[email protected]
</Link>
</p>
<p className="text-center">
All music, game, TV and movie covers are owned by their respective authors.<br/>Currently playing info provided by Last.fm
</p>
<p className="text-center">
&copy; Alex Frantz, 2023
</p>
<p className="text-center space-x-2">
<Link href="https://twitter.com/avvex__" target="_blank" rel="noreferrer">
<Twitter color='plain' size="30" />
</Link>

<Link href="https://linkedin.com/in/thatalex" target="_blank" rel="noreferrer">
<LinkedinOption size="30" />
</Link>
&copy; Alex Frantz, {date.getFullYear()}
</p>
</div>
</>
Expand Down
1 change: 0 additions & 1 deletion src/components/header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export default function Header() {
<p className="text-2xl font-bold">alex</p>
<div className="inline-block pb-2">
<HeaderItem content="home" linkTo="/" />
<HeaderItem content="reviews" linkTo="/reviews" />
<HeaderItem content="links" linkTo="/links" />
<HeaderItem content="blog" linkTo="/blog" />
{ status === "authenticated" &&
Expand Down
19 changes: 0 additions & 19 deletions src/pages/create.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,25 +77,6 @@ export default function CreatePage() {
return (
<RootLayout protectedPage={true}>
<div className="space-y-4">
<div className="w-96 p-2 mx-auto bg-gray-500 text-center">
<h1 className="font-bold text-2xl">Create Review Post</h1>

<div className="pt-2 pb-2">
<hr />
</div>

<form onSubmit={onPostSubmit}>
<InputOption inputName="title" label="Title" />
<InputOption inputName="image" label="Image URL" />
<InputOption inputName="type" label="Content Type (book, movie, tv, game)" />
<InputOption inputName="review" label="Review" isTextArea={true} />

<button className="bg-gray-800 text-white rounded-lg p-2" type="submit">Submit</button>
</form>

<p>{message}</p>
</div>

<div className="w-96 p-2 mx-auto bg-gray-500 text-center">
<h1 className="font-bold text-2xl">Create Link</h1>

Expand Down
69 changes: 48 additions & 21 deletions src/pages/links.tsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,64 @@
import SocialCard from '@/components/SocialCard'
import RootLayout from '@/components/RootLayout';
import { api } from "@/utils/api";
import { useSession } from 'next-auth/react';
import React from 'react';
import { useRouter } from 'next/router';
import Image from 'next/image';
import Link from 'next/link';
import React, {useState, useEffect} from 'react';

export default function Links() {
const router = useRouter();
const {status} = useSession();
const [links, setLinks] = useState<React.JSX.Element[] | null>(null);

// trpc hooks
const { data: linkData } = api.links.getAll.useQuery()
const deleteMutation = api.links.delete.useMutation()

useEffect(() => {
if (!links && linkData) {
const allLinks = [];

for (const link of linkData) {
allLinks.push(
<SocialCard
name={link.name}
key={link.id}
url={link.url}
showDelete={status == "authenticated"}
deleteCallback={() => {
deleteMutation.mutate(link.id);
router.reload()
}}
/>
)
}

setLinks(allLinks)
}
})

return (
<RootLayout>
<div className="space-y-2">
{
linkData && linkData.length > 0 ? linkData.map((v) => {
return <SocialCard
url={v.url}
name={v.name}
key={v.name}
showDelete={status === "authenticated"}
deleteCallback={() => {
deleteMutation.mutate(v.id)
}}
/>
}) :
<div className="text-center text-white">
<h1>Uh oh!</h1>
<p>There&apos;s nothing here :(</p>
<main className="bg-black flex flex-col justify-center items-center min-h-screen">
<Link href="/">
<h1 className="text-white text-sm underline hover:text-gray-500 pb-2">&lt;- Back Home</h1>
</Link>
<div className="bg-zinc-900 p-10 rounded-sm">
<div className="pb-2 flex flex-col justify-center items-center">
<Image className="rounded-lg" width="90" height="90" alt="Profile Picture" src="https://storage.thatalex.dev/content/pfp.png" />
<div className="text-white text-center pt-2">
<h1>Alex</h1>
<p>I&apos;m Alex, a QA Engineer by day and developer by night</p>
<hr className="h-px my-2 bg-gray-200 border-0 dark:bg-gray-700" />
</div>
}
</div>

<div className="space-y-2">
{
links && links.length > 0 ? links : <h1 className="text-center text-white font-bold">Uh oh, there are no links here!</h1>
}
</div>
</div>
</RootLayout>
</main>
)
}
67 changes: 0 additions & 67 deletions src/pages/reviews/[name].tsx

This file was deleted.

79 changes: 0 additions & 79 deletions src/pages/reviews/index.tsx

This file was deleted.

0 comments on commit 6673154

Please sign in to comment.