-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Minor fixes, mainly to function (profiles)
- Loading branch information
teachmetw
committed
Sep 11, 2023
1 parent
6f2e03d
commit f865bdb
Showing
37 changed files
with
562 additions
and
443 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -54,4 +54,4 @@ const Billboard: React.FC = () => { | |
</div> | ||
) | ||
} | ||
export default Billboard; | ||
export default Billboard; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,38 @@ | ||
import React from 'react'; | ||
|
||
interface MobileMenuProps { | ||
visible?: boolean; | ||
visible?: boolean; | ||
} | ||
|
||
const MobileMenu: React.FC<MobileMenuProps> = ({visible}) => { | ||
if (!visible) return null; | ||
return ( | ||
<div className='bg-black w-56 absolute top-8 left-0 py-5 flex-col border-2 border-gray-800 flex'> | ||
<div className='flex flex-col gap-4'> | ||
<div className='px-3 text-center text-white hover:underline'> | ||
Home | ||
</div> | ||
<div className='px-3 text-center text-white hover:underline'> | ||
Educational | ||
</div> | ||
<div className='px-3 text-center text-white hover:underline'> | ||
Entertainment | ||
</div> | ||
<div className='px-3 text-center text-white hover:underline'> | ||
New & Popular | ||
</div> | ||
<div className='px-3 text-center text-white hover:underline'> | ||
My Watch List | ||
</div> | ||
</div> | ||
const MobileMenu: React.FC<MobileMenuProps> = ({ visible }) => { | ||
if (!visible) { | ||
return null; | ||
} | ||
|
||
return ( | ||
<div className="bg-black w-56 absolute top-8 left-0 py-5 flex-col border-2 border-gray-800 flex"> | ||
<div className="flex flex-col gap-4"> | ||
<div className="px-3 text-center text-white hover:underline"> | ||
Home | ||
</div> | ||
<div className="px-3 text-center text-white hover:underline"> | ||
Series | ||
</div> | ||
<div className="px-3 text-center text-white hover:underline"> | ||
Films | ||
</div> | ||
<div className="px-3 text-center text-white hover:underline"> | ||
New & Popular | ||
</div> | ||
<div className="px-3 text-center text-white hover:underline"> | ||
My List | ||
</div> | ||
<div className="px-3 text-center text-white hover:underline"> | ||
Browse by Languages | ||
</div> | ||
) | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default MobileMenu; | ||
export default MobileMenu; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,90 +1,84 @@ | ||
import NavbarItem from "./Navbaritem" | ||
import MobileMenu from "./MobileMenu" | ||
import { FaChevronDown } from "react-icons/fa" | ||
import { useCallback, useEffect, useState } from "react" | ||
import { BsSearch, BsBell } from "react-icons/bs" | ||
import AccountMenu from "./AccountMenu" | ||
import React, { useCallback, useEffect, useState } from 'react'; | ||
import { BellIcon, MagnifyingGlassIcon, ChevronDownIcon } from '@heroicons/react/24/outline'; | ||
|
||
import AccountMenu from '@/components/AccountMenu'; | ||
import MobileMenu from '@/components/MobileMenu'; | ||
import NavbarItem from '@/components/NavbarItem'; | ||
import useCurrentUser from "@/hooks/useCurrentUser"; | ||
|
||
|
||
const TOP_OFFSET = 66; | ||
|
||
const Navbar = () => { | ||
const [showMobileMenu, setShowMobileMenu] = useState(false); | ||
const [showAccountMenu, setShowAccountMenu] = useState(false); | ||
const [showBackground, setShowBackground] = useState(false); | ||
const [showAccountMenu, setShowAccountMenu] = useState(false); | ||
const [showMobileMenu, setShowMobileMenu] = useState(false); | ||
const [showBackground, setShowBackground] = useState(false); | ||
|
||
useEffect(() => { | ||
const handleScroll = () => { | ||
console.log(window.scrollY) | ||
if (window.scrollY >= TOP_OFFSET) { | ||
setShowBackground(true) | ||
} else { | ||
setShowBackground(false) | ||
} | ||
} | ||
|
||
window.addEventListener('scroll', handleScroll); | ||
|
||
return () => { | ||
window.removeEventListener('scroll', handleScroll); | ||
} | ||
}, []); | ||
|
||
useEffect(() => { | ||
const handleScroll = () => { | ||
if (window.scrollY >= TOP_OFFSET) { | ||
setShowBackground(true); | ||
} else { | ||
setShowBackground(false); | ||
} | ||
} | ||
window.addEventListener('scroll', handleScroll); | ||
return () => window.removeEventListener('scroll', handleScroll); | ||
}, []); | ||
const toggleAccountMenu = useCallback(() => { | ||
setShowAccountMenu((current) => !current); | ||
}, []); | ||
|
||
const toggleMobileMenu = useCallback(() => { | ||
setShowMobileMenu((current) => !current); | ||
}, []); | ||
|
||
const { data: currentUser } = useCurrentUser(); | ||
|
||
const toggleMobileMenu = useCallback(() => { | ||
setShowMobileMenu((current) => !current); | ||
}, []); | ||
const toggleAccountMenu = useCallback(() => { | ||
setShowAccountMenu((current) => !current); | ||
}, []); | ||
return ( | ||
|
||
return ( | ||
<nav className="w-full fixed z-40"> | ||
<div className={` | ||
px-4 | ||
md:px-16 | ||
py-6 | ||
flex | ||
flex-row | ||
items-center | ||
transition | ||
duration-500 | ||
${showBackground ? 'bg-zinc-900 bg-opacity-90' : ''} | ||
`}> | ||
<img src="/images/logo.png" alt="Logo" className="h-10 lg:h-20"></img> | ||
<div className=" | ||
flex-row | ||
ml-8 | ||
gap-7 | ||
hidden | ||
lg:flex | ||
"> | ||
<NavbarItem label="Home"/> | ||
<NavbarItem label="Educational"/> | ||
<NavbarItem label="Entertainment"/> | ||
<NavbarItem label="New & Popular"/> | ||
<NavbarItem label="My Watch List"/> | ||
</div> | ||
<div onClick= {toggleMobileMenu} className="lg:hidden flex flex-row items-center gap-2 ml-8 cursor-pointer relative"> | ||
<p className="text-white text-sm">Browse</p> | ||
<FaChevronDown className={`text-white transition ${showMobileMenu ? 'rotate-180': 'rotate-0' }`}/> | ||
<MobileMenu visible={showMobileMenu}/> | ||
</div> | ||
<div className="flex flex-row ml-auto gap-7 items-center"> | ||
<div className="text-gray-200 hover:text-gray-300 cursor-pointer transition"> | ||
<BsSearch /> | ||
</div> | ||
<div className="text-gray-200 hover:text-gray-300 cursor-pointer transition"> | ||
<BsBell /> | ||
</div> | ||
|
||
<nav className="w-full fixed z-40"> | ||
<div className={`px-4 md:px-16 py-6 flex flex-row items-center transition duration-500 ${showBackground ? 'bg-zinc-900 bg-opacity-90' : ''}`}> | ||
<img src="/images/logo.png" className="h-15 lg:h-20" alt="Logo" /> | ||
<div className="flex-row ml-8 gap-7 hidden lg:flex"> | ||
<NavbarItem label="Home" active /> | ||
<NavbarItem label="Educational" /> | ||
<NavbarItem label="Entertainment" /> | ||
<NavbarItem label="New & Popular" /> | ||
<NavbarItem label="My List" /> | ||
<NavbarItem label="Browse by Category" /> | ||
</div> | ||
<div onClick={toggleMobileMenu} className="lg:hidden flex flex-row items-center gap-2 ml-8 cursor-pointer relative"> | ||
<p className="text-white text-sm">Browse</p> | ||
<ChevronDownIcon className={`w-6 text-white fill-white transition ${showMobileMenu ? 'rotate-180' : 'rotate-0'}`} /> | ||
<MobileMenu visible={showMobileMenu} /> | ||
</div> | ||
<div className="flex flex-row ml-auto gap-7 items-center"> | ||
<div className="text-gray-200 hover:text-gray-300 cursor-pointer transition"> | ||
<MagnifyingGlassIcon className="w-8" /> | ||
</div> | ||
<div className="text-gray-200 hover:text-gray-300 cursor-pointer transition"> | ||
<BellIcon className="w-8" /> | ||
</div> | ||
<div onClick={toggleAccountMenu} className="flex flex-row items-center gap-2 cursor-pointer relative"> | ||
<div className="w-12 h-12 lg:w-14 lg:h-14 rounded-md overflow-hidden"> | ||
<img src={currentUser?.image || "/images/profiles/5992.png"} alt="" /> | ||
</div> | ||
<ChevronDownIcon className={`w-6 text-white fill-white transition ${showAccountMenu ? 'rotate-180' : 'rotate-0'}`} /> | ||
<AccountMenu visible={showAccountMenu} /> | ||
</div> | ||
|
||
<div onClick={toggleAccountMenu} className="flex flex-row items-center gap-2 cursor-pointer relative"> | ||
<div className="w-6 h-6 lg:w-10 lg:h-10 rounded-md overflow-hidden"> | ||
<img src="/images/profiles/5992.png" alt="Profile"></img> | ||
</div> | ||
<FaChevronDown className={`text-white transition ${showAccountMenu ? 'rotate-180': 'rotate-0' }`}/> | ||
<AccountMenu visible={showAccountMenu}/> | ||
</div> | ||
</div> | ||
</div> | ||
</nav> | ||
) | ||
</div> | ||
</div> | ||
</nav> | ||
) | ||
} | ||
|
||
export default Navbar | ||
export default Navbar; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,16 @@ | ||
import React from 'react'; | ||
|
||
interface NavbarItemProps { | ||
label: string; | ||
label: string; | ||
active?: boolean; | ||
} | ||
|
||
const NavbarItem: React.FC<NavbarItemProps> = ({label}) => { | ||
return ( | ||
<div className="text-white cursor-pointer hover:text-gray-300 transition"> | ||
{label} | ||
</div> | ||
) | ||
const NavbarItem: React.FC<NavbarItemProps> = ({ label, active }) => { | ||
return ( | ||
<div className={active ? 'text-white cursor-default' : 'text-gray-200 hover:text-gray-300 cursor-pointer transition'}> | ||
{label} | ||
</div> | ||
) | ||
} | ||
|
||
export default NavbarItem; | ||
export default NavbarItem; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.