PluginProbe
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites / 3.3.3
BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites v3.3.3
4.1.0 trunk 1.0.0 1.0.1 1.0.2 1.0.3 1.0.4 1.0.5 1.1.0 1.1.1 1.1.2 1.2.0 1.2.1 1.2.2 1.2.3 1.3.0 1.3.1 1.3.2 1.3.3 1.3.4 1.3.5 2.1.2 2.5.0 2.5.3 2.6.1 All 38 releases
blockspare / admin / components / MobileMenu.js

MobileMenu.js in BlockSpare – Gutenberg Blocks for News, Magazine, Blog & Business Websites 3.3.3, at admin/components/MobileMenu.js

62 lines 1.6 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import React, {useState, useEffect } from 'react'
2 import { mobileMenu, menuClose } from '../data/icons'
3
4 const MobileMenu = ({ current, activeNavHandler }) => {
5 const [active, setActive] = useState(false)
6 const menuHandler = () => {
7 setActive(!active)
8 }
9 const menuActiveItemHandler = (i) => {
10 activeNavHandler(i)
11 setActive(false)
12 }
13 useEffect(() => {
14 if(active) {
15 document.body.style.overflow = "hidden";
16 }
17 return () => (document.body.style.overflow = "scroll");
18 },[active]);
19 return (
20 <>
21 <div className='mobile-menu-icon' onClick={menuHandler}>
22 {mobileMenu}
23 </div>
24 {active && (
25 <div className="mobile-menu-content">
26 <div className="mobile-menu-close" onClick={() => setActive(false)}>
27 {menuClose}
28 </div>
29 <nav className="navigation-items-mobile">
30 {navs.map((item, i) => (
31 <a key={i} className={`navigation-item ${current === i ? "active" : " "}`} onClick={() => menuActiveItemHandler(i)}>{item.title}</a>
32 ))}
33 </nav>
34 </div>
35 )}
36 </>
37 )
38 }
39
40 export default MobileMenu
41
42
43 const navs = [
44 {
45 title: "Welcome",
46 },
47 // {
48 // title: "Blocks",
49 // },
50 {
51 title: "Designs"
52 },
53 // {
54 // title: "Settings",
55 // },
56 // {
57 // title: "Colors"
58 // },
59 // {
60 // title: "Typography"
61 // }
62 ]