From 37e0d002145f09ce6b6150297559100666143e3e Mon Sep 17 00:00:00 2001 From: Norbert Maciaszek Date: Fri, 22 Aug 2025 00:48:08 +0200 Subject: [PATCH] feat: enhance layout and navbar components for improved user experience; add padding to main content, update navbar structure with floating navigation, and refine search functionality --- src/app/layout.tsx | 2 +- .../molecules/TrackedMovies/index.tsx | 2 +- .../Navbar/components/Search/index.tsx | 211 ++++++++-------- src/components/organisms/Navbar/index.tsx | 236 +++++++----------- 4 files changed, 190 insertions(+), 261 deletions(-) diff --git a/src/app/layout.tsx b/src/app/layout.tsx index 7d7a638..b65d589 100644 --- a/src/app/layout.tsx +++ b/src/app/layout.tsx @@ -26,7 +26,7 @@ export default async function RootLayout({ -
{children}
+
{children}
diff --git a/src/components/molecules/TrackedMovies/index.tsx b/src/components/molecules/TrackedMovies/index.tsx index e14068d..7cb2bed 100644 --- a/src/components/molecules/TrackedMovies/index.tsx +++ b/src/components/molecules/TrackedMovies/index.tsx @@ -54,7 +54,7 @@ export const TrackedMovies: FC = ({ ); return ( -
+
{/* Currently in cinemas. */} diff --git a/src/components/organisms/Navbar/components/Search/index.tsx b/src/components/organisms/Navbar/components/Search/index.tsx index 94610a5..f1640b2 100644 --- a/src/components/organisms/Navbar/components/Search/index.tsx +++ b/src/components/organisms/Navbar/components/Search/index.tsx @@ -1,20 +1,22 @@ "use client"; -import { IoClose, IoSearch } from "react-icons/io5"; -import { useEffect, useState } from "react"; +import { IoClose } from "react-icons/io5"; +import { FC, useEffect, useState } from "react"; import { SearchResult } from "@/lib/tmdb/types"; import { TMDB } from "@/lib/tmdb"; import { SearchInput } from "@/components/atoms/SearchInput"; import { useKeyListener } from "@/hooks/useKeyListener"; import { useRef } from "react"; -import { useOutsideClick } from "@/hooks/useOutsideClick"; import { Button } from "@/components/atoms/Button"; import { MovieList } from "@/components/molecules/MovieList"; import { Spinner } from "@/components/atoms/Spinner"; import { usePathname } from "next/navigation"; -export const Search = () => { +type Props = { + onClose: () => void; +}; + +export const Search: FC = ({ onClose }) => { const ref = useRef(null); - const [isSearchOpen, setIsSearchOpen] = useState(false); const [response, setResponse] = useState(null); const [query, setQuery] = useState(""); const isLoading = query.length > 2 && !response; @@ -22,7 +24,7 @@ export const Search = () => { const pathname = usePathname(); useEffect(() => { - setIsSearchOpen(false); + query && onClose(); }, [pathname]); const handleSearch = async (query: string) => { @@ -39,127 +41,110 @@ export const Search = () => { }; const handleClose = () => { - setIsSearchOpen(false); - setResponse(null); + onClose(); }; useKeyListener("Escape", handleClose); - useOutsideClick(ref, handleClose); return ( - <> +
+ {/* Close button */} - {isSearchOpen && ( -
- {/* Aurora Background */} -
+
+
+ {/* Header Section */} +
+

+ Znajdź Filmy +

+

+ Odkryj niesamowite filmy z całego świata +

- {/* Close button */} - - -
-
- {/* Header Section */} -
-

- Znajdź Filmy -

-

- Odkryj niesamowite filmy z całego świata -

- - {/* Enhanced Search Input */} -
-
-
- -
-
+ {/* Enhanced Search Input */} +
+
+
+
- - {/* Loading State */} - {isLoading && ( -
-
- -
-
-

Szukam filmów...

-
- )} - - {/* Results Header */} - {results && ( -
-

- - Znaleziono {total_results} filmów -

-
- )} - - {/* Results */} - {results && ( -
- ({ - ...m, - favorite: false, - seen: false, - genre_ids: JSON.stringify(m.genre_ids), - }))} - fluid - /> -
- )} - - {/* Show More Button */} - {total_results > 4 && ( -
-
- -
-
- )} - - {/* No Results */} - {query.length >= 3 && results && results.length === 0 && ( -
-
🎬
-

- Brak wyników -

-

Spróbuj wyszukać inny tytuł

-
- )}
+ + {/* Loading State */} + {isLoading && ( +
+
+ +
+
+

Szukam filmów...

+
+ )} + + {/* Results Header */} + {results && ( +
+

+ + Znaleziono {total_results} filmów +

+
+ )} + + {/* Results */} + {results && ( +
+ ({ + ...m, + favorite: false, + seen: false, + genre_ids: JSON.stringify(m.genre_ids), + }))} + fluid + /> +
+ )} + + {/* Show More Button */} + {total_results > 4 && ( +
+
+ +
+
+ )} + + {/* No Results */} + {query.length >= 3 && results && results.length === 0 && ( +
+
🎬
+

+ Brak wyników +

+

Spróbuj wyszukać inny tytuł

+
+ )}
- )} - +
+
); }; diff --git a/src/components/organisms/Navbar/index.tsx b/src/components/organisms/Navbar/index.tsx index f2ccf19..5d73f36 100644 --- a/src/components/organisms/Navbar/index.tsx +++ b/src/components/organisms/Navbar/index.tsx @@ -1,180 +1,124 @@ "use client"; import Link from "next/link"; -import { useEffect, useState } from "react"; -import { HiMenuAlt3, HiX, HiSparkles } from "react-icons/hi"; +import { useState } from "react"; +import { HiSearch, HiHome, HiViewGrid } from "react-icons/hi"; import { Search } from "./components/Search"; import { usePathname } from "next/navigation"; -import { Button } from "@/components/atoms/Button"; -const links = [ +const navigationItems = [ + { + label: "Strona Główna", + href: "/", + icon: HiHome, + emoji: "🏠", + color: "from-blue-500 to-purple-600", + description: "Twoja lista filmów", + }, { label: "Odkrywaj", href: "/odkrywaj", - icon: "🎬", - }, - { - label: "Moja Lista", - href: "/", - icon: "📚", + icon: HiViewGrid, + emoji: "🎬", + color: "from-purple-500 to-pink-600", + description: "Znajdź nowe filmy", }, ]; export const Navbar = () => { - const [isMobileMenuOpen, setIsMobileMenuOpen] = useState(false); + const [searchOpen, setSearchOpen] = useState(false); const pathname = usePathname(); - useEffect(() => { - setIsMobileMenuOpen(false); - }, [pathname]); - - const toggleMobileMenu = () => { - setIsMobileMenuOpen(!isMobileMenuOpen); - }; - return ( <> - {/* Main Navbar */} -
- {/* Aurora background effect */} -
+ {/* Elegant Floating Navigation */} +
+ - {/* Mobile Menu Overlay */} - {isMobileMenuOpen && ( -
- {/* Backdrop */} -
- - {/* Menu Panel */} -
- {/* Aurora background */} -
-
-
- -
- {/* Menu Items */} - -
+ {/* Enhanced Search Modal */} + {searchOpen && ( +
+
+
+ setSearchOpen(false)} />
)} - - ); };