Skip to content

Commit 41039ad

Browse files
authored
Merge pull request #38 from AzmSurov/header
#19 - Header Updated
2 parents 268f723 + 3f5081b commit 41039ad

File tree

3 files changed

+103
-1
lines changed

3 files changed

+103
-1
lines changed

next.config.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
/** @type {import('next').NextConfig} */
22
const nextConfig = {
3-
images: { domains: ['avatars.githubusercontent.com'] }
3+
images: {
4+
domains: [
5+
'avatars.githubusercontent.com',
6+
"res.cloudinary.com"
7+
]
8+
}
49
}
510

611
module.exports = nextConfig

src/app/page.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import Header from "@/components/header";
12
import { Button } from "@/components/ui/button";
23
import { LoginButton, LogoutButton } from "@/components/ui/buttons";
34
import { getSession } from "@/lib/getSession";
@@ -9,6 +10,8 @@ export default async function Home() {
910
const session = await getSession();
1011

1112
return (
13+
<>
14+
<Header />
1215
<main className="flex min-h-screen flex-col items-center justify-between p-24">
1316
<Button>Button</Button>
1417
{session ? (
@@ -27,5 +30,7 @@ export default async function Home() {
2730
<LoginButton />
2831
)}
2932
</main>
33+
</>
34+
3035
);
3136
}

src/components/header.tsx

Lines changed: 92 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
'use client'
2+
3+
import Image from 'next/image';
4+
import Link from 'next/link';
5+
import React, { useState } from 'react';
6+
import { Button } from './ui/button';
7+
8+
const Header = () => {
9+
const [state, setState] = useState(false);
10+
11+
// Replace javascript:void(0) path with your path
12+
const navigation = [
13+
{ title: 'Race', path: '/' },
14+
{ title: 'Leaderboard', path: '/' },
15+
{ title: 'About', path: '/' },
16+
];
17+
18+
return (
19+
<div>
20+
<nav className="bg-white w-full border-b md:border-0 md:static">
21+
<div className="items-center px-4 max-w-screen-xl mx-auto md:flex md:px-8">
22+
<div className="flex items-center justify-between py-3 md:py-5 md:block">
23+
<Link href="javascript:void(0)">
24+
<Image
25+
src="https://res.cloudinary.com/dfrtxrh9c/image/upload/v1688858445/Web-Dev-Cody/Logo_lvkfmp.png"
26+
width={96}
27+
height={96}
28+
alt="Code Racer Logo"
29+
/>
30+
</Link>
31+
<div className="md:hidden">
32+
<button
33+
className="text-gray-700 outline-none p-2 rounded-md focus:border-gray-400 focus:border"
34+
onClick={() => setState(!state)}
35+
>
36+
{state ? (
37+
<svg
38+
xmlns="http://www.w3.org/2000/svg"
39+
className="h-6 w-6"
40+
viewBox="0 0 20 20"
41+
fill="currentColor"
42+
>
43+
<path
44+
fillRule="evenodd"
45+
d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z"
46+
clipRule="evenodd"
47+
/>
48+
</svg>
49+
) : (
50+
<svg
51+
xmlns="http://www.w3.org/2000/svg"
52+
className="h-6 w-6"
53+
fill="none"
54+
viewBox="0 0 24 24"
55+
stroke="currentColor"
56+
>
57+
<path
58+
strokeLinecap="round"
59+
strokeLinejoin="round"
60+
strokeWidth={2}
61+
d="M4 8h16M4 16h16"
62+
/>
63+
</svg>
64+
)}
65+
</button>
66+
</div>
67+
</div>
68+
<div
69+
className={`flex-1 justify-self-center pb-3 mt-8 md:block md:pb-0 md:mt-0 ${
70+
state ? 'block' : 'hidden'
71+
}`}
72+
>
73+
<ul className="justify-center items-center space-y-8 md:flex md:space-x-6 md:space-y-0">
74+
{navigation.map((item, idx) => {
75+
return (
76+
<li key={idx} className="text-gray-600 p-2 rounded-lg hover:bg-gray-50">
77+
<Link href={item.path}>{item.title}</Link>
78+
</li>
79+
);
80+
})}
81+
</ul>
82+
</div>
83+
<div className="hidden md:inline-block">
84+
<Button>Login</Button>
85+
</div>
86+
</div>
87+
</nav>
88+
</div>
89+
);
90+
};
91+
92+
export default Header;

0 commit comments

Comments
 (0)