File indexing completed on 2025-01-26 05:27:58

0001 import React , {useEffect, useState, useRef} from 'react'
0002 import AboutMenuItems from './function/AboutMenuItems';
0003 
0004 const AboutMenu = () => {
0005   const [dropdownClass, setDropdownClass] = useState('');    
0006   const toggleEl = useRef(null);  
0007   useEffect(() => {        
0008     document.addEventListener('mousedown',handleClick, false);
0009     return () => {
0010         
0011         document.removeEventListener('mousedown',handleClick, false);
0012     };
0013   },[dropdownClass])
0014 
0015   const handleClick= e => {          
0016         let cls = "";
0017         if (toggleEl.current.contains(e.target)){                 
0018           if (dropdownClass === "open"){              
0019             if (e.target.className === "about-menu-link-item"){
0020                 cls = "";
0021             } else {
0022                 cls = "open";
0023             }
0024           } else {
0025             cls = "open";
0026           }
0027         }        
0028         setDropdownClass(cls);              
0029       }
0030 
0031   return (
0032       <li ref={toggleEl} id="about-dropdown-menu" className={dropdownClass}>
0033         <a className="about-menu-link-item"> About &#8964; </a>
0034         <ul className="dropdown-menu dropdown-menu-right">
0035           <AboutMenuItems />
0036         </ul>
0037       </li>
0038   )
0039 }
0040 
0041 export default AboutMenu