diff --git a/frontend/src/App.tsx b/frontend/src/App.tsx index 4fbd05e8..b72cb664 100644 --- a/frontend/src/App.tsx +++ b/frontend/src/App.tsx @@ -5,12 +5,20 @@ import Header from "./components/header/Header"; import AppRoutes from "./AppRoutes.tsx"; function App() { - const [isSidebarOpen] = useState(false); + const [isSidebarOpen, setIsSidebarOpen] = useState(false); + + const openSidebar = () => { + setIsSidebarOpen(true); + }; + + const closeSidebar = () => { + setIsSidebarOpen(false); + }; return ( <> - -
+ +
); diff --git a/frontend/src/components/header/Header.css b/frontend/src/components/header/Header.css index 472fbeb1..4109c1f2 100644 --- a/frontend/src/components/header/Header.css +++ b/frontend/src/components/header/Header.css @@ -24,9 +24,33 @@ letter-spacing: -0.3px; } +.menu-button { + display: none; +} + @media (max-width: 767px) { .header { + height: 70px; margin-left: 0; width: 100%; } + + .header[data-sidebar-open="true"] { + display: none; + } + + .header h1 { + font-size: 37px; + } + + .menu-button { + display: block; + position: absolute; + left: 20px; + background: none; + border: none; + font-size: 40px; + cursor: pointer; + color: var(--text-dark); + } } diff --git a/frontend/src/components/header/Header.tsx b/frontend/src/components/header/Header.tsx index 75cf9c43..da90960c 100644 --- a/frontend/src/components/header/Header.tsx +++ b/frontend/src/components/header/Header.tsx @@ -3,6 +3,11 @@ import { useTranslation } from "react-i18next"; import { useLocation } from "react-router-dom"; import { ROUTES } from "../../AppRoutes"; +type HeaderProps = { + isSidebarOpen: boolean; + onOpenSidebar: () => void; +}; + // Maps each route path to the translation key used for its title const pageTitles: Record = { [ROUTES.plantMatch]: "sidebar.plantMatch", @@ -11,13 +16,22 @@ const pageTitles: Record = { [ROUTES.profile]: "sidebar.profile", }; -export default function Header() { +export default function Header({ isSidebarOpen, onOpenSidebar }: HeaderProps) { const { t } = useTranslation(); const { pathname } = useLocation(); + const titleKey = pageTitles[pathname] ?? "sidebar.plantMatch"; return ( -
+
+ +

{t(titleKey)}

); diff --git a/frontend/src/components/sidebar/Sidebar.css b/frontend/src/components/sidebar/Sidebar.css index 09b329c2..8ef32d4b 100644 --- a/frontend/src/components/sidebar/Sidebar.css +++ b/frontend/src/components/sidebar/Sidebar.css @@ -72,6 +72,10 @@ text-align: center; } +.close-button { + display: none; +} + @media (max-width: 767px) { .sidebar { width: 100%; @@ -82,4 +86,16 @@ .sidebar[data-open="true"] { transform: translateX(0); } + + .close-button { + display: block; + position: absolute; + top: 15px; + right: 20px; + background: none; + border: none; + font-size: 32px; + color: var(--text-dark); + cursor: pointer; + } } diff --git a/frontend/src/components/sidebar/Sidebar.tsx b/frontend/src/components/sidebar/Sidebar.tsx index 03af4072..e7fd748f 100644 --- a/frontend/src/components/sidebar/Sidebar.tsx +++ b/frontend/src/components/sidebar/Sidebar.tsx @@ -7,36 +7,61 @@ import "./Sidebar.css"; type SidebarProps = { isOpen: boolean; + onCloseSidebar: () => void; }; -export default function Sidebar({ isOpen }: SidebarProps) { +export default function Sidebar({ isOpen, onCloseSidebar }: SidebarProps) { const { t } = useTranslation(); return (