Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Code clean up #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/app/layout.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const metadata = {
export default function RootLayout({ children }) {
return (
<html lang="en" className="h-full">
<body className={`${inter.className} bg-[url('../assets/background.jpg')] h-full bg-center bg-cover bg-no-repeat`}>
<body className={`${inter.className} bg-[url('../assets/backgroundTry.png')] h-full bg-center bg-cover bg-no-repeat`}>
<Header />
{children}
</body>
Expand Down
Binary file added src/assets/backgroundTry.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
11 changes: 5 additions & 6 deletions src/components/desktopHeader.jsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import Link from "next/link";
import { DesktopLinks } from "./mobileHeader/links";

export const DesktopHeader = () => <div className="hidden lg:block ">
<nav
className="w-full flex justify-center items-center gap-4 bg-[#C5C6C7] h-20"
>
<Link href="/" className="text-2xl text-[#1F2833]">Home</Link>
<Link href="/movies" className="text-2xl text-[#1F2833]">Movies</Link>
<nav className="w-full h-12 flex justify-end items-center gap-4 bg-[#142833]
transition-all duration-500 ease-out opacity-75 hover:opacity-90 hover:h-16 ">
<DesktopLinks/>
</nav>
</div>
</div>
18 changes: 18 additions & 0 deletions src/components/mobileHeader/Icons.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
export const CloseIcon = () => (
<svg
viewBox="0 0 12 12"
version="1.1"
xmlns="http://www.w3.org/2000/svg"
className="text-[#1F2833] w-7 h-7"
>
<line x1="1" y1="7" x2="7" y2="1" stroke="black" strokeWidth="1.5" />
<line x1="1" y1="1" x2="7" y2="7" stroke="black" strokeWidth="1.5" />
</svg>

);

export const MenuIcon = () => (
<svg className="w-5 h-5 text-red-50" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M1 1h15M1 7h15M1 13h15" />
</svg>
);
11 changes: 6 additions & 5 deletions src/components/mobileHeader/header.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,16 @@

import { useState } from "react"
import { Overlay } from "./overlay";
import { MenuIcon } from "./Icons";

export const MobileHeader = () => {
const [isOpen, setIsOpen] = useState(false);

return <div className="block lg:hidden p-5">
<button onClick={() => setIsOpen(true)}>
<svg className="w-7 h-7 text-red-50" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 17 14">
<path stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" d="M1 1h15M1 7h15M1 13h15" />
</svg>
return <div className="block lg:hidden m-10" >
<button
onClick={() => setIsOpen(true)}
onMouseEnter={() => setIsOpen(true)} >
<MenuIcon/>
</button>
<Overlay setIsOpen={setIsOpen} isOpen={isOpen}/>
</div>
Expand Down
40 changes: 36 additions & 4 deletions src/components/mobileHeader/links.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,37 @@
import Link from "next/link";
export const Links = () => <div className="flex items-center flex-col gap-5">
<Link href="/" className="w-1/2 bg-slate-900 text-center h-12 flex items-center justify-center" onClick={() => setIsOpen(false)}>Home</Link>
<Link href="/movies" className="w-1/2 bg-slate-900 text-center h-12 flex items-center justify-center" onClick={() => setIsOpen(false)}>Movies</Link>
</div>

export const NavLink = ({ href, children, onClick, additionalClasses }) => (
<Link href={href} className={`text-center flex items-center justify-center
transition ease-in-out transform hover:-translate-y-1 ${additionalClasses}`} onClick={onClick}>
{children}
</Link>
);

export const LinksWrapper = ({ children, additionalClasses }) => (
<div className={`flex items-center text-cyan-100 ${additionalClasses}`}>
{children}
</div>
);

export const MobileLinks = () =>
<LinksWrapper additionalClasses="flex-col gap-5">
<NavLink href="/" additionalClasses="w-1/2 h-12" onClick={() => setIsOpen(false)}>
Home
</NavLink>

<NavLink href="/movies" additionalClasses="w-1/2 h-12" onClick={() => setIsOpen(false)}>
Movies
</NavLink>

</LinksWrapper>

export const DesktopLinks = () =>
<LinksWrapper additionalClasses="gap-5 px-10 ">
<NavLink href="/" additionalClasses="text-2xl ">
Home
</NavLink>

<NavLink href="/movies" additionalClasses="text-2xl">
Movies
</NavLink>
</LinksWrapper>
30 changes: 15 additions & 15 deletions src/components/mobileHeader/overlay.jsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
import { CloseIcon } from "./Icons";
import { MobileLinks } from "./links";


export const Overlay = ({ setIsOpen, isOpen }) =>
<div
className={`m-7 absolute left-0 top-0 bg-[#142833] overflow-hidden
opacity-95 rounded-md z-10 transition-all duration-500 ease-out ${isOpen ? 'w-1/3 h-1/3' : 'h-0 w-0'}`}
>

<button onClick={() => setIsOpen(false)} className="p-3">
<CloseIcon/>
<MobileLinks/>
</button>
</div>

export const Overlay = ({ setIsOpen, isOpen }) => <div className={`absolute left-0 top-0 h-full bg-[#C5C6C7] w-full ${isOpen ? "block" : "hidden"} z-10`}>
<button onClick={() => setIsOpen(false)}>
<svg viewBox="0 0 12 12" version="1.1"
xmlns="http://www.w3.org/2000/svg" className="text-[#1F2833] w-7 h-7 m-5">
<line x1="1" y1="11"
x2="11" y2="1"
stroke="black"
strokeWidth="2"/>
<line x1="1" y1="1"
x2="11" y2="11"
stroke="black"
strokeWidth="2"/>
</svg>
</button>

</div>