diff --git a/src/components/menu/index.js b/src/components/menu/index.js index 8a43b6b6..bc1af0e6 100644 --- a/src/components/menu/index.js +++ b/src/components/menu/index.js @@ -1,98 +1,98 @@ -import React, {useState, useEffect} from 'react'; -import {useSelector, useDispatch} from 'react-redux'; -import {Icon} from '../../utils/general'; -import './menu.scss'; +import React, { useState, useEffect } from "react"; +import { useSelector, useDispatch } from "react-redux"; +import { Icon } from "../../utils/general"; +import "./menu.scss"; -import * as Actions from '../../actions'; +import * as Actions from "../../actions"; -export const ActMenu = ()=>{ - const menu = useSelector(state=>state.menus); - const {abpos, isLeft} = useSelector(state=>{ +export const ActMenu = () => { + const menu = useSelector((state) => state.menus); + const { abpos, isLeft } = useSelector((state) => { var acount = state.menus.menus[state.menus.opts].length; var tmpos = { - 'top': state.menus.top, - 'left': state.menus.left - }, tmpleft = false; + top: state.menus.top, + left: state.menus.left, + }, + tmpleft = false; var wnwidth = window.innerWidth, - wnheight = window.innerHeight; + wnheight = window.innerHeight; var ewidth = 312, - eheight = acount*28; + eheight = acount * 28; - tmpleft = (wnwidth - tmpos.left) > 504; - if(wnwidth - tmpos.left < ewidth){ + tmpleft = wnwidth - tmpos.left > 504; + if (wnwidth - tmpos.left < ewidth) { tmpos.right = wnwidth - tmpos.left; tmpos.left = null; } - if(wnheight - tmpos.top < eheight){ + if (wnheight - tmpos.top < eheight) { tmpos.bottom = wnheight - tmpos.top; tmpos.top = null; } return { abpos: tmpos, - isLeft: tmpleft + isLeft: tmpleft, }; - }) + }); const dispatch = useDispatch(); - const clickDispatch = (event)=>{ + const clickDispatch = (event) => { event.stopPropagation(); var action = { type: event.target.dataset.action, - payload: event.target.dataset.payload + payload: event.target.dataset.payload, }; - if(action.type){ - if(action.type!=action.type.toUpperCase()){ - Actions[action.type](action.payload,menu); - }else{ + if (action.type) { + if (action.type != action.type.toUpperCase()) { + Actions[action.type](action.payload, menu); + } else { dispatch(action); } - dispatch({type: "MENUHIDE"}); + dispatch({ type: "MENUHIDE" }); } - } + }; - const menuobj = (data)=>{ + const menuobj = (data) => { var mnode = []; - data.map(opt=>{ - if(opt.type=="hr"){ + data.map((opt) => { + if (opt.type == "hr") { mnode.push(
); - }else{ - mnode.push(