From d1c7e61b30a544c1f0f11c546fa4a9cd4b510a7d Mon Sep 17 00:00:00 2001 From: J Francisco Rader Date: Sat, 22 Aug 2020 21:47:10 -0300 Subject: [PATCH 1/4] Calculator ! --- src/Phone.js | 2 + src/apps/appmarket/hooks/useApps.js | 41 +++-- src/apps/calculator/components/Calculator.js | 68 +++++++ .../calculator/components/CalculatorApp.js | 22 +++ .../calculator/components/CalculatorIcon.js | 43 +++++ src/apps/calculator/hooks/useCalculator.js | 168 ++++++++++++++++++ src/locale/en.json | 1 + 7 files changed, 330 insertions(+), 15 deletions(-) create mode 100644 src/apps/calculator/components/Calculator.js create mode 100644 src/apps/calculator/components/CalculatorApp.js create mode 100644 src/apps/calculator/components/CalculatorIcon.js create mode 100644 src/apps/calculator/hooks/useCalculator.js diff --git a/src/Phone.js b/src/Phone.js index ea46555..6db6172 100644 --- a/src/Phone.js +++ b/src/Phone.js @@ -13,6 +13,7 @@ import { ContactsApp } from "./apps/contacts/components/ContactsApp"; import { SettingsApp } from "./apps/settings/components/SettingsApp"; import { PhoneApp } from './apps/phone/components/PhoneApp'; import { ThemeProvider } from "@material-ui/core"; +import { CalculatorApp } from "./apps/calculator/components/CalculatorApp"; function Phone() { const { settings, currentTheme } = useSettings(); @@ -42,6 +43,7 @@ function Phone() { + diff --git a/src/apps/appmarket/hooks/useApps.js b/src/apps/appmarket/hooks/useApps.js index 630e52a..02e2321 100644 --- a/src/apps/appmarket/hooks/useApps.js +++ b/src/apps/appmarket/hooks/useApps.js @@ -3,51 +3,62 @@ import { useConfig } from "../../../config/hooks/useConfig"; import { blue, grey, green } from "@material-ui/core/colors"; import { useTranslation } from "react-i18next"; import ContactsIcon from "@material-ui/icons/Contacts"; -import SettingsIcon from '@material-ui/icons/Settings' -import PhoneIcon from '@material-ui/icons/Phone'; +import SettingsIcon from "@material-ui/icons/Settings"; +import PhoneIcon from "@material-ui/icons/Phone"; import { atom } from "recoil"; +import { useSettings } from "../../settings/hooks/useSettings"; +import { CalculatorIcon } from "../../calculator/components/CalculatorIcon"; const appsState = atom({ - key: 'apps', - default: { preinstalled: [] } + key: "apps", + default: { preinstalled: [] }, }); export const useApps = () => { const [apps, setApps] = useConfig(appsState); + const { currentTheme } = useSettings(); const { t } = useTranslation(); useEffect(() => { setApps("preinstalled", [ { - id: 'phone', - name: t('APPS_PHONE'), + id: "phone", + name: t("APPS_PHONE"), icon: , backgroundColor: green[400], color: green[50], - path: '/phone' + path: "/phone", }, { - id: 'contacts', - name: t('APPS_CONTACTS'), + id: "contacts", + name: t("APPS_CONTACTS"), icon: , backgroundColor: blue[500], color: blue[50], - path: '/contacts' + path: "/contacts", }, { - id: 'settings', - name: t('APPS_SETTINGS'), + id: "calculator", + name: t("APPS_SETTINGS"), + icon: , + backgroundColor: currentTheme().palette.primary.light, + color: currentTheme().palette.primary.contrastText, + path: "/calculator", + }, + { + id: "settings", + name: t("APPS_SETTINGS"), icon: , backgroundColor: grey[700], color: grey[50], - path: '/settings' - } + path: "/settings", + }, ]); // eslint-disable-next-line }, []); const allApps = [...apps.preinstalled]; - const getApp = id => allApps.find(a => a.id === id) || {}; + const getApp = (id) => allApps.find((a) => a.id === id) || {}; return { apps, allApps, setApps, getApp }; }; diff --git a/src/apps/calculator/components/Calculator.js b/src/apps/calculator/components/Calculator.js new file mode 100644 index 0000000..8818e7d --- /dev/null +++ b/src/apps/calculator/components/Calculator.js @@ -0,0 +1,68 @@ +import React from "react"; +import { useCalculator, CalcButton } from "../hooks/useCalculator"; +import { Grid, makeStyles, Box, Paper } from "@material-ui/core"; + +const useStyles = makeStyles((theme) => ({ + button: { + fontSize: theme.typography.h5.fontSize, + padding: theme.spacing(2), + }, + result: { + fontSize: theme.typography.h2.fontSize, + textAlign: "right", + }, +})); + +export const Calculator = ({ ...props }) => { + const { + result, + equals, + clear, + clearAll, + divider, + multiplier, + substractor, + adder, + dot, + zero, + one, + two, + three, + four, + five, + six, + seven, + eight, + nine, + } = useCalculator(); + const classes = useStyles(); + return ( + + + {result()} + + + + + + + + + + + + + + + + + + + + + + + + + ); +}; diff --git a/src/apps/calculator/components/CalculatorApp.js b/src/apps/calculator/components/CalculatorApp.js new file mode 100644 index 0000000..c6e2464 --- /dev/null +++ b/src/apps/calculator/components/CalculatorApp.js @@ -0,0 +1,22 @@ +import React from "react"; +import { AppWrapper } from "../../../ui/components"; +import { AppTitle } from "../../../ui/components/AppTitle"; +import { AppContent } from "../../../ui/components/AppContent"; +import { useTranslation } from "react-i18next"; +import { useApps } from "../../appmarket/hooks/useApps"; +import { Calculator } from "./Calculator"; + +export const CalculatorApp = () => { + const { t } = useTranslation(); + const { getApp } = useApps(); + return ( + + + {t("APPS_CALCULATOR")} + + + + + + ); +}; diff --git a/src/apps/calculator/components/CalculatorIcon.js b/src/apps/calculator/components/CalculatorIcon.js new file mode 100644 index 0000000..398c66c --- /dev/null +++ b/src/apps/calculator/components/CalculatorIcon.js @@ -0,0 +1,43 @@ +import React from "react"; +import { SvgIcon } from "@material-ui/core"; + +export const CalculatorIcon = ({ ...props }) => { + return ( + + + + + + + + + + + + + + ); +}; diff --git a/src/apps/calculator/hooks/useCalculator.js b/src/apps/calculator/hooks/useCalculator.js new file mode 100644 index 0000000..251c7f7 --- /dev/null +++ b/src/apps/calculator/hooks/useCalculator.js @@ -0,0 +1,168 @@ +import React, { useReducer } from "react"; +import { Grid, Button } from "@material-ui/core"; + +const initialState = { + value: 0, + op: "", + num1: 0, + num2: "", + num3: "", +}; + +const Reducer = (state, action) => { + switch (action.type) { + case "2": + if (!state.num1) { + return { ...state, num1: state.num2, op: action.payload, num2: "" }; + } + if (!state.num2) { + return { ...state, op: action.payload }; + } + if (state.num1 && state.op) { + return { + ...state, + value: state.op(state.value, state.num2), + op: action.payload, + }; + } + return { + ...state, + value: state.op(state.num1, state.num2), + num2: "", + op: action.payload, + num1: state.op(state.num1, state.num2), + }; + + case "1": + if (state.num2 === "" && action.payload === ".") { + return { ...state, num2: "0" + action.payload }; + } + if (state.num2 === "") { + return { ...state, num2: action.payload }; + } + if (action.payload === "." && state.num2.includes(".")) { + return state; + } else { + return { ...state, num2: state.num2 + action.payload }; + } + + case "3": + if (state.op && state.num2) { + return { + ...state, + value: state.op(state.num1, state.num2), + num2: "", + num1: state.op(state.num1, state.num2), + num3: state.num2, + }; + } + if (state.op && state.value) { + return { ...state, value: state.op(state.value, state.num3) }; + } + return state; + + case "c": + if (state.num2.length === 2 && state.num2.includes("0.")) { + return { ...state, num2: "" }; + } + if (state.num2.length > 1) { + return { ...state, num2: state.num2.slice(0, -1) }; + } + return { ...state, num2: "" }; + + case "ac": + return { + value: 0, + op: "", + num1: 0, + num2: "", + num3: "", + }; + + default: + return state; + } +}; + +export const CalcButton = ({ button, className, ...props }) => ( + + + +); + +export const useCalculator = () => { + const [state, dispatch] = useReducer(Reducer, initialState); + + const getPayload = (label, type) => { + if (type !== "2") { + return `${label}`; + } + switch (label) { + case "/": + return (a, b) => Number(a) / Number(b); + case "*": + return (a, b) => Number(a) * Number(b); + case "+": + return (a, b) => Number(a) + Number(b); + case "-": + return (a, b) => Number(a) - Number(b); + default: + break; + } + }; + + const buttonProps = (label, type) => ({ + label, + onClick: () => + dispatch({ + type, + payload: getPayload(label, type), + }), + }); + + const number = (n) => buttonProps(n, "1"); + const operator = (sym) => buttonProps(sym, "2"); + const clear = buttonProps("C", "c"); + const clearAll = buttonProps("AC", "ac"); + const equals = buttonProps("=", "3"); + const zero = number(0); + const dot = number("."); + const divider = operator("/"); + const multiplier = operator("*"); + const adder = operator("+"); + const substractor = operator("-"); + const one = number(1); + const two = number(2); + const three = number(3); + const four = number(4); + const five = number(5); + const six = number(6); + const seven = number(7); + const eight = number(8); + const nine = number(9); + const result = () => (!state.num2 ? state.value : state.num2); + + return { + result, + equals, + clear, + clearAll, + divider, + multiplier, + substractor, + adder, + dot, + zero, + one, + two, + three, + four, + five, + six, + seven, + eight, + nine, + }; +}; diff --git a/src/locale/en.json b/src/locale/en.json index 69da9f8..995877c 100644 --- a/src/locale/en.json +++ b/src/locale/en.json @@ -4,6 +4,7 @@ "APPS_PHONE": "Phone", "APPS_CONTACTS": "Contacts", "APPS_MESSAGES": "Messages", + "APPS_CALCULATOR": "Calculator", "APPS_SETTINGS": "Settings", "APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper", "APPS_SETTINGS_OPTIONS_FRAME": "Frame" From d36ef4ce381d72d13ecf814bc3d466d897f04b48 Mon Sep 17 00:00:00 2001 From: J Francisco Rader Date: Sat, 22 Aug 2020 21:56:12 -0300 Subject: [PATCH 2/4] Phone navigation button --- src/os/components/Navigation.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/os/components/Navigation.js b/src/os/components/Navigation.js index d51462f..1eb61ad 100644 --- a/src/os/components/Navigation.js +++ b/src/os/components/Navigation.js @@ -6,6 +6,7 @@ import { } from "@material-ui/core"; import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft"; import AppsIcon from "@material-ui/icons/Apps"; +import PhoneIcon from "@material-ui/icons/Phone"; import { useHistory } from "react-router-dom"; const useStyles = makeStyles((theme) => ({ @@ -18,24 +19,26 @@ const useStyles = makeStyles((theme) => ({ export const Navigation = () => { const classes = useStyles(); const history = useHistory(); - return ( - value === "back" ? history.goBack() : history.push("/") - } + onChange={(_e, value) => value()} > history.goBack()} icon={} /> history.push('/')} icon={} /> + history.push('/phone')} + icon={} + /> ); }; From eb570f21b3e456908877d2bd20716e041ee3dcda Mon Sep 17 00:00:00 2001 From: J Francisco Rader Date: Sat, 22 Aug 2020 23:03:54 -0300 Subject: [PATCH 3/4] Make List and ListItem reusable --- src/apps/contacts/components/ContactList.js | 4 +- src/apps/phone/components/PhoneList.js | 42 ++++++++++----------- src/ui/components/ContextMenu.js | 6 +-- src/ui/components/List.js | 19 +++++----- src/ui/components/ListItem.js | 10 +++++ 5 files changed, 45 insertions(+), 36 deletions(-) create mode 100644 src/ui/components/ListItem.js diff --git a/src/apps/contacts/components/ContactList.js b/src/apps/contacts/components/ContactList.js index 2302b6e..aac2da0 100644 --- a/src/apps/contacts/components/ContactList.js +++ b/src/apps/contacts/components/ContactList.js @@ -1,11 +1,11 @@ import React from "react"; -import List from "@material-ui/core/List"; -import ListItem from "@material-ui/core/ListItem"; import ListItemText from "@material-ui/core/ListItemText"; import { Button } from "@material-ui/core"; import PhoneIcon from "@material-ui/icons/Phone"; import ChatIcon from "@material-ui/icons/Chat"; +import { List } from "../../../ui/components/List"; +import { ListItem } from "../../../ui/components/ListItem"; export const ContactList = ({ contacts, onCall, onMessage }) => { return ( diff --git a/src/apps/phone/components/PhoneList.js b/src/apps/phone/components/PhoneList.js index 9174500..aa0a192 100644 --- a/src/apps/phone/components/PhoneList.js +++ b/src/apps/phone/components/PhoneList.js @@ -1,24 +1,24 @@ -import React from 'react'; -import List from "@material-ui/core/List"; -import ListItem from "@material-ui/core/ListItem"; +import React from "react"; import ListItemText from "@material-ui/core/ListItemText"; -import PhoneCallbackIcon from '@material-ui/icons/PhoneCallback'; -import PhoneForwardedIcon from '@material-ui/icons/PhoneForwarded'; +import PhoneCallbackIcon from "@material-ui/icons/PhoneCallback"; +import PhoneForwardedIcon from "@material-ui/icons/PhoneForwarded"; +import { List } from "../../../ui/components/List"; +import { ListItem } from "../../../ui/components/ListItem"; + +const CallTypeIcon = { + incoming: , + outgoing: , +}; export const PhoneList = ({ calls }) => { - const CallTypeIcon = {'incoming': , 'outgoing': } - - return ( - - {calls.map((call) => ( - - - {CallTypeIcon[call.type]} - - ))} - - ) -} \ No newline at end of file + return ( + + {calls.map((call) => ( + + + {CallTypeIcon[call.type]} + + ))} + + ); +}; diff --git a/src/ui/components/ContextMenu.js b/src/ui/components/ContextMenu.js index 57f25a7..a131371 100644 --- a/src/ui/components/ContextMenu.js +++ b/src/ui/components/ContextMenu.js @@ -1,13 +1,13 @@ import React from "react"; import { - ListItem, - List, ListItemIcon, ListItemText, Slide, makeStyles, Paper, } from "@material-ui/core"; +import { List } from "./List"; +import { ListItem } from "./ListItem"; const useStyles = makeStyles((theme) => ({ root: { @@ -34,7 +34,7 @@ export const ContextMenu = ({ open, onClose, options }) => { onClose(); }} > - {option.icon} + {option.icon && {option.icon}} ))} diff --git a/src/ui/components/List.js b/src/ui/components/List.js index 1a9d0df..27d2f92 100644 --- a/src/ui/components/List.js +++ b/src/ui/components/List.js @@ -1,11 +1,10 @@ -import React from 'react' -import List from '@material-ui/core/List'; +import React from "react"; +import MaterialList from "@material-ui/core/List"; -export const PhoneList = (props) => { - - return ( - - {props.children} - - ) -} +export const List = ({ ...props }) => { + return ( + + {props.children} + + ); +}; diff --git a/src/ui/components/ListItem.js b/src/ui/components/ListItem.js new file mode 100644 index 0000000..2f9d5be --- /dev/null +++ b/src/ui/components/ListItem.js @@ -0,0 +1,10 @@ +import React from "react"; +import MaterialListItem from "@material-ui/core/ListItem"; + +export const ListItem = ({ ...props }) => { + return ( + + {props.children} + + ); +}; From dd9b3bddff8cee67a226f9801c59a47b5bbdea64 Mon Sep 17 00:00:00 2001 From: J Francisco Rader Date: Sun, 23 Aug 2020 01:47:38 -0300 Subject: [PATCH 4/4] Keyboard management and remove ugly errors --- src/Phone.js | 9 +- src/apps/appmarket/hooks/useApps.js | 2 +- src/apps/settings/components/SettingsApp.js | 4 +- src/config/hooks/useConfig.js | 2 - src/index.js | 12 ++- src/os/components/Navigation.js | 22 ++--- src/os/components/NotificationBar.js | 2 +- src/os/hooks/useKeyboard.js | 99 +++++++++++++++++++++ src/ui/components/Button.js | 10 +++ src/ui/components/ContextMenu.js | 2 +- src/ui/components/GridMenu.js | 22 +++-- src/ui/components/List.js | 2 +- src/ui/components/ListItem.js | 2 +- 13 files changed, 156 insertions(+), 34 deletions(-) create mode 100644 src/os/hooks/useKeyboard.js diff --git a/src/Phone.js b/src/Phone.js index 6db6172..254fb14 100644 --- a/src/Phone.js +++ b/src/Phone.js @@ -11,12 +11,15 @@ import MessageIcon from "@material-ui/icons/Email"; import { HomeApp } from "./apps/home/components/Home"; import { ContactsApp } from "./apps/contacts/components/ContactsApp"; import { SettingsApp } from "./apps/settings/components/SettingsApp"; -import { PhoneApp } from './apps/phone/components/PhoneApp'; +import { PhoneApp } from "./apps/phone/components/PhoneApp"; import { ThemeProvider } from "@material-ui/core"; import { CalculatorApp } from "./apps/calculator/components/CalculatorApp"; +import { useInitKeyboard } from "./os/hooks/useKeyboard"; function Phone() { + useInitKeyboard(); const { settings, currentTheme } = useSettings(); + return (
@@ -36,7 +39,9 @@ function Phone() { }} > }, { icon: }]} + notifications={[ + { key: 'newMessage', icon: }, + ]} />
diff --git a/src/apps/appmarket/hooks/useApps.js b/src/apps/appmarket/hooks/useApps.js index 02e2321..f5bdf10 100644 --- a/src/apps/appmarket/hooks/useApps.js +++ b/src/apps/appmarket/hooks/useApps.js @@ -38,7 +38,7 @@ export const useApps = () => { }, { id: "calculator", - name: t("APPS_SETTINGS"), + name: t("APPS_CALCULATOR"), icon: , backgroundColor: currentTheme().palette.primary.light, color: currentTheme().palette.primary.contrastText, diff --git a/src/apps/settings/components/SettingsApp.js b/src/apps/settings/components/SettingsApp.js index 5adbd4b..ce5e5a4 100644 --- a/src/apps/settings/components/SettingsApp.js +++ b/src/apps/settings/components/SettingsApp.js @@ -1,6 +1,6 @@ import React from "react"; import { AppWrapper } from "../../../ui/components"; -import { List, ListItem, ListItemText, Divider } from "@material-ui/core"; +import { ListItemText, Divider } from "@material-ui/core"; import { AppTitle } from "../../../ui/components/AppTitle"; import { AppContent } from "../../../ui/components/AppContent"; import { useTranslation } from "react-i18next"; @@ -11,6 +11,8 @@ import { import { useConfig } from "../../../config/hooks/useConfig"; import { useSettings } from "../hooks/useSettings"; import { useApps } from "../../appmarket/hooks/useApps"; +import { List } from "../../../ui/components/List"; +import { ListItem } from "../../../ui/components/ListItem"; export const SettingItem = ({ options, label, value, onClick }) => { return ( diff --git a/src/config/hooks/useConfig.js b/src/config/hooks/useConfig.js index 68f41c4..70ed6b1 100644 --- a/src/config/hooks/useConfig.js +++ b/src/config/hooks/useConfig.js @@ -6,8 +6,6 @@ const configState = atom({ default: Default }) -console.log(Default) - export const useConfig = (state = configState) => { const [config, _setConfig] = useRecoilState(state) diff --git a/src/index.js b/src/index.js index f84a406..c8b4f48 100644 --- a/src/index.js +++ b/src/index.js @@ -7,13 +7,11 @@ import { BrowserRouter } from "react-router-dom"; import { RecoilRoot } from "recoil"; ReactDOM.render( - - - - - - - , + + + + + , document.getElementById("root") ); diff --git a/src/os/components/Navigation.js b/src/os/components/Navigation.js index 1eb61ad..77c7dcc 100644 --- a/src/os/components/Navigation.js +++ b/src/os/components/Navigation.js @@ -2,7 +2,7 @@ import React from "react"; import { makeStyles, BottomNavigation, - BottomNavigationAction + BottomNavigationAction, } from "@material-ui/core"; import KeyboardArrowLeftIcon from "@material-ui/icons/KeyboardArrowLeft"; import AppsIcon from "@material-ui/icons/Apps"; @@ -24,21 +24,21 @@ export const Navigation = () => { className={classes.root} onChange={(_e, value) => value()} > + history.push("/phone")} + icon={} + /> + history.push("/")} + icon={} + /> history.goBack()} icon={} /> - history.push('/')} - icon={} - /> - history.push('/phone')} - icon={} - /> ); }; diff --git a/src/os/components/NotificationBar.js b/src/os/components/NotificationBar.js index 88bb2df..8bd028d 100644 --- a/src/os/components/NotificationBar.js +++ b/src/os/components/NotificationBar.js @@ -36,7 +36,7 @@ export const NotificationBar = ({ notifications = [] }) => { > {notifications.map((notification) => ( - + {notification.icon} ))} diff --git a/src/os/hooks/useKeyboard.js b/src/os/hooks/useKeyboard.js new file mode 100644 index 0000000..1fe5c85 --- /dev/null +++ b/src/os/hooks/useKeyboard.js @@ -0,0 +1,99 @@ +import { useEffect } from "react"; +import { atom, useSetRecoilState, useRecoilValue } from "recoil"; + +const keyboardState = { + ArrowRight: atom({ + key: "ArrowRight", + default: null, + }), + ArrowLeft: atom({ + key: "ArrowLeft", + default: null, + }), + ArrowUp: atom({ + key: "ArrowUp", + default: null, + }), + ArrowDown: atom({ + key: "ArrowDown", + default: null, + }), + Backspace: atom({ + key: "Backspace", + default: null, + }), + Enter: atom({ + key: "Enter", + default: null, + }), + Escape: atom({ + key: "Escape", + default: null, + }), +}; + +const validKeys = [ + "ArrowRight", + "ArrowLeft", + "ArrowUp", + "ArrowDown", + "Backspace", + "Enter", + "Escape", +]; + +const isKeyValid = (key) => validKeys.indexOf(key) !== -1; + +export const useInitKeyboard = () => { + const getters = { + ArrowRight: useRecoilValue(keyboardState.ArrowRight), + ArrowLeft: useRecoilValue(keyboardState.ArrowLeft), + ArrowUp: useRecoilValue(keyboardState.ArrowUp), + ArrowDown: useRecoilValue(keyboardState.ArrowDown), + Backspace: useRecoilValue(keyboardState.Backspace), + Enter: useRecoilValue(keyboardState.Enter), + Escape: useRecoilValue(keyboardState.Escape), + }; + + const setEscape = useSetRecoilState(keyboardState.Escape); + + useEffect( + function handleNUIKeyboardMessage() { + function onKeyUp(event) { + const { key } = event; + const callback = getters[key]; + if ( + isKeyValid(key) && + callback && + callback.handler && + callback.handler.call + ) { + return callback.handler(); + } + } + + window.addEventListener("keyup", onKeyUp); + return () => window.removeEventListener("keyup", onKeyUp); + }, + [getters] + ); + + useEffect(function registerEscapeHandler() { + setEscape({ handler: () => console.log("close phone") }); + }, [setEscape]); +}; + +export const useKeyboard = () => { + const setters = { + ArrowRight: useSetRecoilState(keyboardState.ArrowRight), + ArrowLeft: useSetRecoilState(keyboardState.ArrowLeft), + ArrowUp: useSetRecoilState(keyboardState.ArrowUp), + ArrowDown: useSetRecoilState(keyboardState.ArrowDown), + Backspace: useSetRecoilState(keyboardState.Backspace), + Enter: useSetRecoilState(keyboardState.Enter), + }; + + return (key, handler) => { + setters[key]({ handler }); + }; +}; diff --git a/src/ui/components/Button.js b/src/ui/components/Button.js index e69de29..707ecbe 100644 --- a/src/ui/components/Button.js +++ b/src/ui/components/Button.js @@ -0,0 +1,10 @@ +import React from "react"; +import MaterialButton from "@material-ui/core/Button"; + +export const Button = ({ ...props }) => { + return ( + + {props.children} + + ); +}; diff --git a/src/ui/components/ContextMenu.js b/src/ui/components/ContextMenu.js index a131371..5b08fdc 100644 --- a/src/ui/components/ContextMenu.js +++ b/src/ui/components/ContextMenu.js @@ -23,7 +23,7 @@ export const ContextMenu = ({ open, onClose, options }) => { return ( - + {options.map((option) => ( ({ +const useStyles = makeStyles((theme) => ({ root: { - marginTop: theme.spacing(3) + marginTop: theme.spacing(3), }, item: { marginTop: theme.spacing(3), - width: '20%' - } + width: "20%", + }, })); export const GridMenu = ({ items, Component = AppIcon }) => { + const setKey = useKeyboard(); const classes = useStyles(); + + useEffect(function registerKeyHandlers() { + setKey("ArrowLeft", () => { + console.log(":v"); + }); + // eslint-disable-next-line + }, []); + return ( @@ -25,7 +35,7 @@ export const GridMenu = ({ items, Component = AppIcon }) => { item className={classes.item} key={item.name} - tabindex="-1" + tabIndex="-1" component={Link} to={item.path} > diff --git a/src/ui/components/List.js b/src/ui/components/List.js index 27d2f92..3d43122 100644 --- a/src/ui/components/List.js +++ b/src/ui/components/List.js @@ -3,7 +3,7 @@ import MaterialList from "@material-ui/core/List"; export const List = ({ ...props }) => { return ( - + {props.children} ); diff --git a/src/ui/components/ListItem.js b/src/ui/components/ListItem.js index 2f9d5be..95dfbdc 100644 --- a/src/ui/components/ListItem.js +++ b/src/ui/components/ListItem.js @@ -3,7 +3,7 @@ import MaterialListItem from "@material-ui/core/ListItem"; export const ListItem = ({ ...props }) => { return ( - + {props.children} );