Skip to content

Commit

Permalink
Merge pull request #39 from nnivxix/fix/home-page
Browse files Browse the repository at this point in the history
Fix/home page
  • Loading branch information
nnivxix authored Sep 26, 2024
2 parents dc7f3e0 + cb400fc commit e64ad9e
Show file tree
Hide file tree
Showing 9 changed files with 147 additions and 119 deletions.
3 changes: 2 additions & 1 deletion .eslintrc-auto-import.json
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
"BackdropCard": true,
"Genres": true,
"useHead": true,
"Footer": true
"Footer": true,
"Discover": true
}
}
1 change: 1 addition & 0 deletions auto-imports.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ declare global {
const DialogPortal: typeof import('./src/components/ui/dialog')['DialogPortal']
const DialogTitle: typeof import('./src/components/ui/dialog')['DialogTitle']
const DialogTrigger: typeof import('./src/components/ui/dialog')['DialogTrigger']
const Discover: typeof import('./src/pages/Discover')['default']
const DropdownMenu: typeof import('./src/components/ui/dropdown-menu')['DropdownMenu']
const DropdownMenuCheckboxItem: typeof import('./src/components/ui/dropdown-menu')['DropdownMenuCheckboxItem']
const DropdownMenuContent: typeof import('./src/components/ui/dropdown-menu')['DropdownMenuContent']
Expand Down
Binary file added public/home-banner-vertical.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/home-banner.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ function App() {
<Navbar />
<Routes>
<Route path="/" element={<Home />} />
<Route path="/discover" element={<Discover />} />
<Route path="/show/tv/:id" element={<Tv />} />
<Route path="/show/movie/:id" element={<Movie />} />
<Route path="/search" element={<Search />} />
Expand Down
46 changes: 23 additions & 23 deletions src/components/Footer.tsx
Original file line number Diff line number Diff line change
@@ -1,23 +1,23 @@
export default function Footer() {
return (
<footer className="bg-gray-900 text-white py-8 px-4 border-t-4 border-blue-600 w-full mt-9">
<div className="w-full px-4 grid grid-cols-1 lg:grid-cols-2">
<div className="col-spans-1">
<h1 className="text-2xl font-bold mb-4">Vilm</h1>
<p className="text-gray-400 mb-1 ">
The Vilm website is a movie discovery platform featuring a modern
design. Users can browse various movie titles and access detailed
information, including the synopsis and trailers.
</p>
<div className="flex items-center mb-4">
<h3 className="text-gray-400">Data provided by </h3>
<Link to="https://www.themoviedb.org" target="_blank">
<img src="tmdb.png" alt="" width={"80px"} className="ml-2" />
</Link>
</div>
<p className="text-gray-400">© 2024</p>
</div>
</div>
</footer>
);
}
export default function Footer() {
return (
<footer className="bg-gray-900 text-white border-t-4 border-blue-600 mt-9">
<div className=" max-w-6xl mx-auto px-4 py-6 grid grid-cols-1 lg:grid-cols-2">
<div className="col-spans-1">
<h1 className="text-2xl font-bold mb-4 italic">Vilm</h1>
<p className="text-gray-400 mb-1 ">
The Vilm website is a movie discovery platform featuring a modern
design. Users can browse various movie titles and access detailed
information, including the synopsis and trailers.
</p>
<div className="flex items-center mb-4">
<h3 className="text-gray-400">Data provided by </h3>
<Link to="https://www.themoviedb.org" target="_blank">
<img src="tmdb.png" alt="" width={"80px"} className="ml-2" />
</Link>
</div>
<p className="text-gray-400">© 2024</p>
</div>
</div>
</footer>
);
}
121 changes: 47 additions & 74 deletions src/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,74 +1,47 @@
import { LibraryBig, Settings } from "lucide-react";
import type { FormEvent } from "react";

export default function Navbar() {
const [searchParams] = useSearchParams();
const querySearch = searchParams.get("title");
const [search, setSearch] = useState<string>(querySearch ?? "");
const navigate = useNavigate();
const { account } = useAccount();

const handleSearch = (e: FormEvent) => {
e.preventDefault();
if (!search.length) {
return;
}
navigate({
pathname: "/search",
search: `?title=${search}&type=movie`,
});
};

return (
<div className="bg-gray-900">
<nav className="flex max-w-6xl mx-auto h-16 items-center justify-between px-3 bg-gray-900 text-white">
<Link to="/" className="logo">
<h1 className="text-2xl md:text-4xl font-bold">Vilm</h1>
</Link>
<div className="flex gap-3 items-center">
<form onSubmit={handleSearch}>
<Input
type="search"
value={search}
onChange={(e) => setSearch(e.target.value)}
className="rounded-md p-2 md:w-96 focus:outline-none focus:ring-2 focus:ring-gray-700 focus:border-transparent"
aria-label="Search"
placeholder="Search movies and tvs"
style={{ backgroundColor: "#c4c4c430" }}
/>
</form>
<DropdownMenu>
<DropdownMenuTrigger>
<Avatar>
<AvatarImage
src={gravatarUrl(account?.avatar?.gravatar.hash ?? "guest")}
/>
<AvatarFallback>
{account?.username ? account?.username[0] : "G"}
</AvatarFallback>
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>
Hello {account?.username ?? "Guest"}
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem className="font-normal" asChild>
<Link to="/setting" title="Go to profile setting page">
<Settings />
<span className="ml-3">Settings</span>
</Link>
</DropdownMenuItem>
<DropdownMenuItem className="font-normal" asChild>
<Link to="/watchlist/movie" title="Go to watchlist page">
<LibraryBig />
<span className="ml-3">My Watchlist</span>
</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</nav>
</div>
);
}
import { LibraryBig, Settings } from "lucide-react";

export default function Navbar() {
const { account } = useAccount();

return (
<div className="bg-gray-900">
<nav className="flex max-w-6xl mx-auto h-16 items-center justify-between px-3 bg-gray-900 text-white">
<Link to="/" className="logo">
<h1 className="text-2xl md:text-4xl italic font-bold">Vilm</h1>
</Link>
<div className="flex gap-3 items-center">
<DropdownMenu>
<DropdownMenuTrigger>
<Avatar>
<AvatarImage
src={gravatarUrl(account?.avatar?.gravatar.hash ?? "guest")}
/>
<AvatarFallback>
{account?.username ? account?.username[0] : "G"}
</AvatarFallback>
</Avatar>
</DropdownMenuTrigger>
<DropdownMenuContent align="end">
<DropdownMenuLabel>
Hello {account?.username ?? "Guest"}
</DropdownMenuLabel>
<DropdownMenuSeparator />
<DropdownMenuItem className="font-normal" asChild>
<Link to="/setting" title="Go to profile setting page">
<Settings />
<span className="ml-3">Settings</span>
</Link>
</DropdownMenuItem>
<DropdownMenuItem className="font-normal" asChild>
<Link to="/watchlist/movie" title="Go to watchlist page">
<LibraryBig />
<span className="ml-3">My Watchlist</span>
</Link>
</DropdownMenuItem>
</DropdownMenuContent>
</DropdownMenu>
</div>
</nav>
</div>
);
}
18 changes: 18 additions & 0 deletions src/pages/Discover.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import type { Response, MovieTv } from "../types/response";

export default function Discover() {
const { data: movies, isLoading } = useFetch<Response<MovieTv[]>>("/trending/all/day");

if (isLoading) {
return "Loading..."
}
return (
<div>
<div className="grid lg:grid-cols-8 md:grid-cols-4 grid-cols-2 gap-5 mx-auto px-5 mt-5">
{movies?.results.map((movie: MovieTv) => (
<CardItem movie={movie} key={movie.id} />
))}
</div>
</div>
);
}
76 changes: 55 additions & 21 deletions src/pages/Home.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,55 @@
import type { Response, MovieTv } from "../types/response";

export default function Home() {
useHead({
title: 'Vilm',
meta: {
description: 'Best Reference Movies'
}
});
const { data: movies } = useFetch<Response<MovieTv[]>>("/trending/all/day");

return (
<div>
<div className="grid lg:grid-cols-8 md:grid-cols-4 grid-cols-2 gap-5 mx-auto px-5 mt-5">
{movies?.results.map((movie: MovieTv) => (
<CardItem movie={movie} key={movie.id} />
))}
</div>
</div>
);
}
import type { FormEvent } from "react";
import { buttonVariants } from "@/components/ui/button";
import { cn } from "@/lib/utils"

export default function Home() {
useHead({
title: 'Vilm',
meta: {
description: 'Best Reference Movies'
}
});
const [searchParams] = useSearchParams();
const querySearch = searchParams.get("title");
const [search, setSearch] = useState<string>(querySearch ?? "");
const navigate = useNavigate();

const handleSearch = (e: FormEvent) => {
e.preventDefault();
if (!search.length) {
return;
}
navigate({
pathname: "/search",
search: `?title=${search}&type=movie`,
});
};

return (
<div className="lg:bg-[url('/home-banner.jpg')] bg-[url('/home-banner-vertical.jpg')] bg-center bg-cover" data-bg-src="https://www.pexels.com/photo/three-friends-watching-at-a-movie-theater-while-eating-popcorn-8263318/">
<div className="mx-auto max-w-4xl px-5 mt-5">
<div className="flex w-full lg:h-[63vh] h-[45vh] md:h-[56vh] justify-center flex-col gap-3 items-center">
<div className="text-center">
<h1 className="text-3xl font-bold italic">Vilm</h1>
<h2 className="text-xl font-bold">Explore what you next watch?</h2>
</div>
<form onSubmit={handleSearch} className="lg:w-1/2 w-full">
<Input
type="search"
value={search}
onChange={(e) => setSearch(e.target.value)}
className="rounded-md py-5 w-full focus:outline-none focus:ring-2 focus:ring-gray-700 focus:border-transparent"
aria-label="Search"
placeholder="Search movies and tvs"
style={{ backgroundColor: "#c4c4c430" }}
/>
</form>
<p>
Or
</p>
<Link to={'/discover'} className={`lg:w-1/2 w-full ${cn(buttonVariants({ variant: "default" }))}`}> Discover </Link>
</div>
</div>
</div>
);
}

0 comments on commit e64ad9e

Please sign in to comment.