Firist commit
This commit is contained in:
19
src/components/auth/login.tsx
Normal file
19
src/components/auth/login.tsx
Normal file
@@ -0,0 +1,19 @@
|
||||
import { auth } from "@/lib/auth";
|
||||
import { LoginButton } from "./login_button";
|
||||
import { LogoutButton } from "./logout_button";
|
||||
|
||||
/**
|
||||
* This is a server component, then the buttons are client
|
||||
*/
|
||||
export default async function LogIn(): Promise<JSX.Element | undefined> {
|
||||
const session = await auth();
|
||||
if (session) {
|
||||
return (
|
||||
<LogoutButton/>
|
||||
);
|
||||
} else {
|
||||
return (
|
||||
<LoginButton/>
|
||||
);
|
||||
}
|
||||
}
|
||||
12
src/components/auth/login_button.tsx
Normal file
12
src/components/auth/login_button.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
"use client";
|
||||
import { UserCircleIcon } from '@heroicons/react/24/outline';
|
||||
import { signIn } from "next-auth/react";
|
||||
|
||||
export function LoginButton(): JSX.Element {
|
||||
return (
|
||||
<button className="p-1 hover:bg-dracula-bglight rounded-3xl transition-colors group" onClick={() => void signIn('cognito')}>
|
||||
<UserCircleIcon className='stroke-dracula-cyan h-8 w-auto group-hover:stroke-dracula-orange transition-colors'/>
|
||||
<span className="sr-only">Log in</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
12
src/components/auth/logout_button.tsx
Normal file
12
src/components/auth/logout_button.tsx
Normal file
@@ -0,0 +1,12 @@
|
||||
"use client";
|
||||
import { UserCircleIcon } from '@heroicons/react/24/outline';
|
||||
import { signOut } from "next-auth/react";
|
||||
|
||||
export function LogoutButton(): JSX.Element {
|
||||
return (
|
||||
<button className="p-1 hover:bg-dracula-bglight rounded-3xl transition-colors group" onClick={() => void signOut()}>
|
||||
<UserCircleIcon className='stroke-dracula-cyan h-8 w-auto group-hover:stroke-dracula-red transition-colors'/>
|
||||
<span className="sr-only">Log out</span>
|
||||
</button>
|
||||
);
|
||||
}
|
||||
11
src/components/footer.tsx
Normal file
11
src/components/footer.tsx
Normal file
@@ -0,0 +1,11 @@
|
||||
export default function NavBar(): JSX.Element {
|
||||
return (
|
||||
<footer className="bg-dracula-bg-darker border-t-2 border-dracula-purple">
|
||||
<div className="mx-auto max-w-7xl px-4">
|
||||
<div className="relative flex flex-row-reverse h-12 items-center justify-between">
|
||||
<span className='text-white select-none'>© Joe Monk 2024</span>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
);
|
||||
}
|
||||
84
src/components/navbar.tsx
Normal file
84
src/components/navbar.tsx
Normal file
@@ -0,0 +1,84 @@
|
||||
'use client';
|
||||
import { useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { HomeModernIcon, Bars3Icon, XMarkIcon, UserCircleIcon } from '@heroicons/react/24/outline';
|
||||
import { AnimatePresence, m, LazyMotion, domAnimation } from "framer-motion";
|
||||
import LogIn from './auth/login';
|
||||
|
||||
const navigation = [
|
||||
{ name: 'Blog', href: '#', current: true },
|
||||
{ name: 'Projects', href: '#', current: false },
|
||||
{ name: 'Photos', href: '#', current: false },
|
||||
{ name: 'CV', href: '#', current: false },
|
||||
{ name: 'Contact', href: '#', current: false },
|
||||
];
|
||||
|
||||
export default function NavBar(): JSX.Element {
|
||||
const [open, setOpen] = useState(false);
|
||||
|
||||
return (
|
||||
<nav className="bg-dracula-bg-darker border-b-2 border-dracula-purple">
|
||||
<LazyMotion features={domAnimation}>
|
||||
<div className="mx-auto max-w-7xl px-4">
|
||||
<div className="relative flex h-16 items-center justify-between">
|
||||
<div className="flex">
|
||||
<button className='sm:hidden hover:bg-dracula-bglight transition-colors duration-100 rounded-sm p-1' onClick={() => setOpen(!open)}>
|
||||
{open ? (
|
||||
<XMarkIcon className='rounded-sm stroke-dracula-cyan h-8 w-auto'/>
|
||||
) : (
|
||||
<Bars3Icon className='rounded-sm stroke-dracula-cyan h-8 w-auto'/>
|
||||
)}
|
||||
</button>
|
||||
<Link className='hidden sm:flex items-center p-1 hover:bg-dracula-bglight transition-colors' href='/'>
|
||||
<HomeModernIcon className='stroke-dracula-cyan rounded-sm h-8 w-auto'/>
|
||||
</Link>
|
||||
<div className='space-x-5 hidden sm:flex ml-10'>
|
||||
{navigation.map((item) => (
|
||||
<Link
|
||||
key={item.name}
|
||||
href={item.href}
|
||||
className={`hover:bg-dracula-bglight transition-colors duration-100 text-white rounded-sm px-3 pt-2 pb-1.5 font-normal border-b-2 border-transparent ${
|
||||
item.current ? 'border-b-dracula-pink' : ''
|
||||
}`}
|
||||
aria-current={item.current ? 'page' : undefined}
|
||||
>
|
||||
{item.name}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
</div>
|
||||
<LogIn/>
|
||||
</div>
|
||||
</div>
|
||||
<AnimatePresence>
|
||||
{ open ? (
|
||||
<m.div
|
||||
initial={{ height: 0 }}
|
||||
animate={{ height: "auto" }}
|
||||
transition={{ duration: 0.15, ease: 'linear' }}
|
||||
exit={{ height: 0 }}
|
||||
className='sm:hidden overflow-hidden'
|
||||
>
|
||||
<div className='flex flex-col space-y-1 py-1'>
|
||||
{navigation.map((item) => (
|
||||
<Link
|
||||
key={item.name}
|
||||
href={item.href}
|
||||
className={`hover:bg-dracula-bglight transition-colors duration-100 text-white px-2 py-2 font-normal border-l-4 border-transparent ${
|
||||
item.current ? 'border-l-dracula-pink' : ''
|
||||
}`}
|
||||
aria-current={item.current ? 'page' : undefined}
|
||||
>
|
||||
{item.name}
|
||||
</Link>
|
||||
))}
|
||||
</div>
|
||||
</m.div>
|
||||
) : null}
|
||||
</AnimatePresence>
|
||||
</LazyMotion>
|
||||
</nav>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user