diff --git a/src/App.jsx b/src/App.jsx index 6493b65..862da4f 100644 --- a/src/App.jsx +++ b/src/App.jsx @@ -12,6 +12,8 @@ import { useTranslation } from "react-i18next"; import PopupLanguageSelector from "./components/features/popupLanguageSelector"; import AboutPopup from "./components/core/aboutPopup"; +import { menuStore } from "./stores/menuStore"; + function App() { const { t, i18n } = useTranslation(); const [isOpen, setIsOpen] = useState(false); @@ -32,6 +34,8 @@ function App() { const toggle = (workExperience) => { setIsOpen((isOpen) => !isOpen); setWorkExperience(workExperience); + setIsContactOpen(false); + menuStore.close(); }; const menuSelected = (subItemSelected) => { diff --git a/src/components/core/menuBar.jsx b/src/components/core/menuBar.jsx index 83bff03..6eec950 100644 --- a/src/components/core/menuBar.jsx +++ b/src/components/core/menuBar.jsx @@ -1,56 +1,67 @@ -import { useState } from "react"; +import { useEffect, useState } from "react"; import { getMenuItemsService, getMenuItemsBySelectionService, } from "../../services/menuBarService"; +import { menuStore } from "../../stores/menuStore"; export default function MenuBar({ onSubMenuSelected }) { const [subMenuItem, setSubMenuItem] = useState(null); - - const [menuItems, setMenuItems] = useState(getMenuItemsService()); + useEffect(() => { + menuStore.subscribe((status) => { + if (!status) { + setMenuItems(getMenuItemsService()); + } + }); + }, []); const onMenuSelectItem = (itemSelected) => { - setMenuItems(getMenuItemsBySelectionService(itemSelected)) - } + setMenuItems(getMenuItemsBySelectionService(itemSelected)); + }; const onSubMenuClick = () => { onSubMenuSelected(subMenuItem); setMenuItems(getMenuItemsService); - } - - return (
- {menuItems.map((item, index) => ( -
- - - {item.opened && item.subMenuItems.length > 0 && ( -
- {item.subMenuItems.map((subItem, index) => ( - - ))} -
- )} -
- ))} - -
+ }; - ) -} \ No newline at end of file + return ( +
+ {menuItems.map((item, index) => ( +
+ + {item.opened && item.subMenuItems.length > 0 && ( +
+ {item.subMenuItems.map((subItem, index) => ( + + ))} +
+ )} +
+ ))} +
+ ); +} diff --git a/src/components/features/popup.jsx b/src/components/features/popup.jsx index caa5f7c..cb7b387 100644 --- a/src/components/features/popup.jsx +++ b/src/components/features/popup.jsx @@ -123,8 +123,8 @@ export default function Popup({ onClose, experience }) { -
-
+
+
-
+