Skip to content

Commit ced2cb7

Browse files
hh
1 parent ecc78a2 commit ced2cb7

28 files changed

Lines changed: 784 additions & 3921 deletions

components/Layout.js

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,21 @@ export default function Layout( { children } ) {
1111
};
1212

1313
return (
14-
<div className="min-h-screen w-full">
14+
<div className="w-full">
1515

1616

1717
<div className="relative flex flex-wrap min-h-screen w-full text-white">
1818
{/* Sidebar */ }
19-
<div
20-
className={ `fixed inset-y-0 left-0 z-50 w-[280px] max-w-xs transform transition-transform duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] lg:relative lg:translate-x-0 ${ isSidebarOpen ? 'translate-x-0' : '-translate-x-full lg:translate-x-0' }` }
19+
<div className={ `fixed inset-y-0 left-0 z-50 w-auto max-w-xs transform transition-transform duration-300 ease-[cubic-bezier(0.22,1,0.36,1)] lg:relative lg:translate-x-0 ${ isSidebarOpen ? 'translate-x-0' : '-translate-x-full lg:translate-x-0' }` }
2120
>
22-
<div className="glass-strong h-full border-r border-white/10 shadow-xl">
21+
<div className="glass-strong h-full border-r border-white/20 shadow-xl">
2322
<div className="flex items-center justify-between gap-4 border-b border-white/5 px-5 py-4 backdrop-blur">
2423
<Link className="group flex items-center gap-2 text-lg font-semibold tracking-wide" href="/" passHref>
25-
<span className="inline-flex h-10 w-10 items-center justify-center rounded-full bg-gradient-to-br from-purple-500/40 to-indigo-500/30 text-sm font-bold uppercase shadow-ring">
24+
<span className="inline-flex h-10 w-10 items-center justify-center rounded-full bg-gradient-to-br from-purple-500/10 to-indigo-500/10 text-sm font-bold uppercase shadow-ring">
2625
CPA
2726
</span>
2827
<span className="text-shadow transition-colors group-hover:text-indigo-100">
29-
Card Price App
28+
CARD PRICE APP
3029
</span>
3130
</Link>
3231
<button
@@ -42,24 +41,24 @@ export default function Layout( { children } ) {
4241
</div>
4342

4443
{/* Main Content */ }
45-
<div className="flex min-h-screen w-full flex-1 flex-col">
46-
<header className="sticky top-0 z-30 flex items-center justify-between border-b border-white/5 bg-slate-900/60 px-4 py-3 backdrop-blur lg:hidden">
44+
<div className="flex w-full flex-1 flex-col">
45+
<header className="sticky top-0 z-30 flex items-center justify-between border-b border-white/50 bg-slate-900/10 px-4 py-3 backdrop-blur lg:hidden">
4746
<Link href="/" passHref className="text-base font-semibold tracking-wide">
48-
<span className="text-shadow">Card Price App</span>
47+
<span className="text-shadow backdrop font-semibold">CARD PRICE APP</span>
4948
</Link>
5049
<button
5150
className="rounded-md border border-white/10 bg-white/5 p-2 text-white/90 transition hover:bg-white/10"
5251
title="Menu"
5352
onClick={ toggleSidebar }
5453
>
55-
<MenuIcon size={ 24 } />
54+
<MenuIcon size={ 30 } />
5655
</button>
5756
</header>
5857

59-
<main className="relative flex-1 px-4 py-6 sm:px-6 lg:px-10">
60-
<div className="">
61-
<div className="glass-card animate-floaty absolute inset-x-10 top-10 -z-10 hidden h-32 rounded-full blur-3xl lg:block" />
62-
<div className="relative z-10">
58+
<main className="mx-auto w-full">
59+
<div className="w-full px-4 py-2">
60+
61+
<div className="backdrop text-shadow relative z-10">
6362
{ children }
6463
</div>
6564
</div>
@@ -70,7 +69,7 @@ export default function Layout( { children } ) {
7069
{ isSidebarOpen && (
7170
<button
7271
type="button"
73-
className="fixed inset-0 z-30 bg-black/50 lg:hidden"
72+
className="fixed inset-0 z-30 bg-black/85 lg:hidden"
7473
onClick={ toggleSidebar }
7574
aria-label="Close sidebar overlay"
7675
/>

components/Navigation/Breadcrumb.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { useEffect, useState } from 'react';
1+
import { useEffect, useState } from 'react';
22
import Link from 'next/link';
33
import { useRouter } from 'next/router';
44

@@ -81,10 +81,10 @@ const Breadcrumb = () => {
8181
>
8282
<ol className="mx-auto sm:mx-0 sm:float-start flex flex-wrap w-fit space-x-4 px-4 sm:px-6 lg:px-8">
8383
{ crumbs.map( ( crumb, idx ) => (
84-
<li key={ idx } className="flex items-center">
84+
<li key={ idx } className="flex flex-wrap items-center">
8585
{ idx > 0 && (
8686
<svg
87-
className="h-full w-6 flex-shrink-0 text-white text-shadow"
87+
className="h-5 w-5 flex-shrink-0 text-white text-shadow backdrop"
8888
viewBox="0 0 24 44"
8989
fill="currentColor"
9090
aria-hidden="true"
@@ -93,13 +93,13 @@ const Breadcrumb = () => {
9393
</svg>
9494
) }
9595
{ crumb.href ? (
96-
<span className="ml-4 text-sm font-medium text-white text-shadow hover:text-gray-300">
96+
<span className="ml-4 p-2 text-sm font-black text-white text-shadow hover:text-gray-300">
9797
<Link href={ crumb.href } passHref>
9898
{ crumb.label }
9999
</Link>
100100
</span>
101101
) : (
102-
<span className="ml-4 text-sm font-medium text-white text-shadow">
102+
<span className="ml-4 p-2 text-sm font-black text-white text-shadow">
103103
{ crumb.label }
104104
</span>
105105
) }

components/Navigation/SideNav.js

Lines changed: 103 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,70 @@
11
import Link from "next/link";
2-
import { useMemo, useState } from "react";
2+
import Image from "next/image";
3+
import { useEffect, useState } from "react";
34
import { useRouter } from "next/router";
45

6+
const normalizePath = ( path ) => {
7+
if ( !path ) {
8+
return "/";
9+
}
10+
11+
const [ base ] = path.split( "?" );
12+
const cleanBase = base.split( "#" )[ 0 ];
13+
if ( !cleanBase || cleanBase === "/" ) {
14+
return cleanBase || "/";
15+
}
16+
17+
return cleanBase.replace( /\/+$/, "" );
18+
};
19+
20+
const NAV_LINKS = [
21+
{
22+
href: "/yugioh",
23+
label: "Yu-Gi-Oh! Card Prices",
24+
title: "Search for current Yu-Gi-Oh! card prices",
25+
icon: "/images/icons/yugioh/yugiohPrices.svg",
26+
matcher: ( path ) => path === "/yugioh",
27+
},
28+
{
29+
href: "/yugioh/sets/set-index",
30+
label: "Browse Yu-Gi-Oh! Sets",
31+
title: "Browse Yu-Gi-Oh! sets",
32+
icon: "/images/icons/yugioh/browseSets.svg",
33+
matcher: ( path ) => path === "/yugioh/sets/set-index" || path.startsWith( "/yugioh/sets/" ),
34+
},
35+
{
36+
href: "/yugioh/deck-builder",
37+
label: "Yu-Gi-Oh! Deck Builder",
38+
title: "Build and test decks",
39+
icon: "/images/icons/yugioh/deckBuilder.svg",
40+
matcher: ( path ) => path.startsWith( "/yugioh/deck-builder" ),
41+
},
42+
{
43+
href: "/sports",
44+
label: "Sports Card Prices",
45+
title: "Get current sports card prices",
46+
icon: "/images/icons/sports/sportsPrices.svg",
47+
matcher: ( path ) => path === "/sports" || path.startsWith( "/sports/" ),
48+
},
49+
{
50+
href: "/yugioh/my-collection",
51+
label: "My Collection",
52+
title: "View your saved cards",
53+
icon: "/images/icons/yugioh/collection.svg",
54+
matcher: ( path ) => path.startsWith( "/yugioh/my-collection" ),
55+
},
56+
];
57+
558
export default function SideNav() {
6-
const [ isAuthenticated, setIsAuthenticated ] = useState( false );
759
const router = useRouter();
60+
const [ isAuthenticated, setIsAuthenticated ] = useState( false );
61+
const [ activeHref, setActiveHref ] = useState( () => {
62+
const currentPath = normalizePath( router.asPath ?? router.pathname ?? "" );
63+
const match = NAV_LINKS.find( ( link ) => link.matcher( currentPath ) );
64+
return match?.href ?? NAV_LINKS[ 0 ].href;
65+
} );
866

9-
useMemo( () => {
67+
useEffect( () => {
1068
const checkAuth = async () => {
1169
try {
1270
const res = await fetch( "/api/auth/validate", {
@@ -20,7 +78,15 @@ export default function SideNav() {
2078
};
2179

2280
checkAuth();
23-
}, [ router ] );
81+
}, [] );
82+
83+
useEffect( () => {
84+
const currentPath = normalizePath( router.asPath ?? router.pathname ?? "" );
85+
const match = NAV_LINKS.find( ( link ) => link.matcher( currentPath ) );
86+
if ( match ) {
87+
setActiveHref( match.href );
88+
}
89+
}, [ router.asPath, router.pathname ] );
2490

2591
const handleLogout = async () => {
2692
try {
@@ -35,33 +101,44 @@ export default function SideNav() {
35101
}
36102
};
37103

38-
const links = [
39-
{ href: "/yugioh", label: "Yu-Gi-Oh! Card Prices", title: "Search for current Yu-Gi-Oh! card prices" },
40-
{ href: "/yugioh/sets/set-index", label: "Browse Yu-Gi-Oh! Sets", title: "Browse Yu-Gi-Oh! sets" },
41-
{ href: "/yugioh/deck-builder", label: "Yu-Gi-Oh! Deck Builder", title: "Build and test decks" },
42-
{ href: "/sports", label: "Sports Card Prices", title: "Get current sports card prices" },
43-
{ href: "/yugioh/my-collection", label: "My Collection", title: "View your saved cards" },
44-
];
45-
46104
return (
47-
<nav className="flex max-h-fit flex-col justify-between px-4 py-6">
48-
<ul className="space-y-3">
49-
{ links.map( ( item ) => (
50-
<li key={ item.href } className="navButton">
51-
<Link href={ item.href } title={ item.title } passHref>
52-
<span className="block">
53-
{ item.label }
54-
</span>
55-
</Link>
56-
</li>
57-
) ) }
105+
<nav className="mx-auto w-[300px] inline-flex max-h-screen flex-col justify-evenly">
106+
<ul className="block flex-1 px-2 py-2 gap-3">
107+
{ NAV_LINKS.map( ( item ) => {
108+
const isActive = activeHref === item.href;
109+
110+
return (
111+
<li key={ item.href } className="navButton max-w-fit text-nowrap">
112+
<Link
113+
href={ item.href }
114+
title={ item.title }
115+
className={ `navLink${ isActive ? " navLink-active" : "" }` }
116+
onClick={ () => setActiveHref( item.href ) }
117+
aria-current={ isActive ? "page" : undefined }
118+
>
119+
<span className="navLink-circle">
120+
<Image
121+
src={ item.icon }
122+
alt={ `${ item.label } icon` }
123+
width={ 40 }
124+
height={ 40 }
125+
className="navLink-iconImage object-center object-cover"
126+
/>
127+
</span>
128+
<span className="navLink-label">
129+
{ item.label }
130+
</span>
131+
</Link>
132+
</li>
133+
);
134+
} ) }
58135
</ul>
59136

60137
<div className="mt-6 space-y-3">
61138
{ isAuthenticated ? (
62139
<button
63140
onClick={ handleLogout }
64-
className="w-full rounded-lg border border-white/10 bg-red-500/20 px-4 py-2 text-sm font-semibold tracking-wide text-red-100 transition hover:bg-red-500/30"
141+
className="block w-full max-w-prose rounded-lg border border-white/10 bg-red-500/20 px-2 py-2 text-sm font-semibold tracking-wide text-red-100 transition hover:bg-red-500/30"
65142
title="Log out"
66143
>
67144
Log Out
@@ -71,8 +148,7 @@ export default function SideNav() {
71148
<Link
72149
href="/login"
73150
title="Log in"
74-
passHref
75-
className="block w-full rounded-lg border border-white/10 bg-white/5 px-4 py-2 text-center text-sm font-semibold tracking-wide text-white/90 transition hover:bg-white/10"
151+
className="block w-full max-w-prose rounded-lg border border-white/10 bg-white/5 px-2 py-2 text-center text-sm font-semibold tracking-wide text-white/90 transition hover:bg-white/10"
76152
>
77153
Log In
78154
</Link>
@@ -82,3 +158,4 @@ export default function SideNav() {
82158
</nav>
83159
);
84160
}
161+

components/Yugioh/YugiohCardDataTable.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -349,11 +349,7 @@ const YugiohCardDataTable = ( {
349349

350350
return (
351351
<div className="mx-auto w-full mb-10 min-h-fit z-50">
352-
<Notification
353-
show={ notification.show }
354-
setShow={ ( show ) => setNotification( { ...notification, show } ) }
355-
message={ notification.message }
356-
/>
352+
357353

358354
{ sortedAndPaginatedData.currentItems.length > 0 && (
359355
<div>
@@ -486,6 +482,11 @@ const YugiohCardDataTable = ( {
486482
} ) }
487483
</tbody>
488484
</table>
485+
<Notification
486+
show={ notification.show }
487+
setShow={ ( show ) => setNotification( { ...notification, show } ) }
488+
message={ notification.message }
489+
/>
489490
</div>
490491
</div>
491492
</div>

components/Yugioh/YugiohCardListInput.js

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,17 @@ const YugiohCardListInput = ( { cardList, setCardList, handleSubmit, error } ) =
1111

1212
return (
1313
<>
14-
<div className='mx-auto object-center self-center place-content-center text-shadow glass'>
15-
<Notification show={ notification.show } setShow={ ( show ) => setNotification( { ...notification, show } ) } message={ notification.message } />
16-
</div>
1714
<form
1815
name="YugiohCardListInput"
1916
onSubmit={ handleSubmit }
2017
>
21-
<div className="text-black">
18+
<div className="text-white">
19+
<div className='mx-auto object-center self-center place-content-center text-shadow glass'>
20+
<Notification show={ notification.show } setShow={ ( show ) => setNotification( { ...notification, show } ) } message={ notification.message } />
21+
</div>
2222
<textarea
2323
name="cardListInput"
24-
className="w-full max-w-7xl rounded-xs flex flex-wrap text-nowrap resize-none h-48"
24+
className="w-full max-w-7xl rounded-xs flex flex-wrap text-nowrap resize-none h-48 glass bg-transparent"
2525
value={ cardList }
2626
onChange={ ( e ) => setCardList( e.target.value ) }
2727
placeholder="Enter your list of cards..." />
@@ -31,6 +31,7 @@ const YugiohCardListInput = ( { cardList, setCardList, handleSubmit, error } ) =
3131
</div>
3232
</form>
3333
{ error && <p>{ error }</p> }
34+
3435
</>
3536
);
3637
};

pages/_document.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@ import { SpeedInsights } from '@vercel/speed-insights/next';
33

44
export default function Document() {
55
return (
6-
<Html lang="en" className="h-full bg-black">
6+
<Html lang="en">
77
<Head>
88
<meta name="description" content="Enter list of TCG cards, get data back" />
99
<meta name="keywords" content="javascript,nextjs,price-tracker,trading-card-game,tailwindcss" />
1010
<meta charSet="UTF-8" />
1111
</Head>
12-
<body className="mx-auto">
13-
<div className="transition-all main mx-auto min-h-full">
12+
<body className="mx-auto bg-black min-h-screen">
13+
<div className="transition-all main mx-auto">
1414
<Main />
1515
</div>
1616
<NextScript />

pages/index.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,12 @@ export default function LandingPage() {
1818
};
1919

2020
return (
21-
<div className="h-fit min-h-screen w-full mx-auto flex overflow-hidden">
21+
<div className="min-h-screen w-full mx-auto flex overflow-hidden">
2222
{/* Yu-Gi-Oh! Panel */ }
2323
<div
2424
onClick={ () => goTo( "/yugioh" ) }
2525
className={ `
26-
relative flex-1 flex items-center justify-center cursor-pointer
26+
relative flex-1 flex items-center justify-center cursor-pointer
2727
transition-all duration-700 ease-in-out
2828
${ animate ? "translate-x-0" : "-translate-x-full" }
2929
bg-gradient-to-br from-blue-500 via-purple-600 to-pink-500

0 commit comments

Comments
 (0)