From dde1bd6931e3971ff414ad248abc946eda91acef Mon Sep 17 00:00:00 2001 From: chip Date: Tue, 1 Sep 2020 21:37:53 +0200 Subject: [PATCH] Feat(Contacts | Components): Contact modal | Input compoent | New dependency --- phone/package.json | 3 +- phone/src/Phone.js | 41 +------ .../apps/contacts/components/ContactList.js | 12 +- .../apps/contacts/components/ContactModal.js | 103 +++++++++++++++++ .../apps/contacts/components/ContactsApp.js | 7 +- phone/src/apps/contacts/hooks/useContacts.js | 21 ---- phone/src/ui/components/Input.js | 24 ++++ phone/yarn.lock | 106 +++++++++++++++++- 8 files changed, 245 insertions(+), 72 deletions(-) create mode 100644 phone/src/apps/contacts/components/ContactModal.js create mode 100644 phone/src/ui/components/Input.js diff --git a/phone/package.json b/phone/package.json index 7cb0376..9e97561 100644 --- a/phone/package.json +++ b/phone/package.json @@ -20,7 +20,8 @@ "react-i18next": "^11.7.1", "react-router-dom": "^5.2.0", "react-scripts": "3.4.3", - "recoil": "^0.0.10" + "recoil": "^0.0.10", + "styled-components": "^5.1.1" }, "devDependencies": { "@babel/cli": "^7.4.4", diff --git a/phone/src/Phone.js b/phone/src/Phone.js index f310ca9..c4768c1 100644 --- a/phone/src/Phone.js +++ b/phone/src/Phone.js @@ -18,6 +18,7 @@ import { useApps } from "./os/apps/hooks/useApps"; import { useContactsService } from "./apps/contacts/hooks/useContactsService"; +// These events are just for testing. Comment it out before building. setTimeout(() => { window.dispatchEvent( new MessageEvent("message", { @@ -47,46 +48,6 @@ setTimeout(() => { number: "345-4366", display: "Kevin", }, - { - id: 3, - number: "345-4366", - display: "Kevin", - }, - { - id: 4, - number: "345-4366", - display: "Kevin", - }, - { - id: 2, - number: "345-4366", - display: "Kevin", - }, - { - id: 3, - number: "345-4366", - display: "Kevin", - }, - { - id: 4, - number: "345-4366", - display: "Kevin", - }, - { - id: 2, - number: "345-4366", - display: "Kevin", - }, - { - id: 3, - number: "345-4366", - display: "Kevin", - }, - { - id: 4, - number: "345-4366", - display: "Kevin", - }, ], }, }) diff --git a/phone/src/apps/contacts/components/ContactList.js b/phone/src/apps/contacts/components/ContactList.js index 665c5f2..c412ce0 100644 --- a/phone/src/apps/contacts/components/ContactList.js +++ b/phone/src/apps/contacts/components/ContactList.js @@ -15,10 +15,18 @@ export const ContactList = () => { {contacts.contacts.map((contact) => ( - - diff --git a/phone/src/apps/contacts/components/ContactModal.js b/phone/src/apps/contacts/components/ContactModal.js new file mode 100644 index 0000000..21bc05a --- /dev/null +++ b/phone/src/apps/contacts/components/ContactModal.js @@ -0,0 +1,103 @@ +import React, { useState } from "react"; +import { makeStyles } from "@material-ui/core/styles"; +import AddCircleIcon from "@material-ui/icons/AddCircle"; +import { AppContent } from "../../../ui/components/AppContent"; +import { Container, Button } from "@material-ui/core"; +import Nui from "../../../os/nui-events/utils/Nui"; +import { TextInput } from "../../../ui/components/Input"; + +const useStyles = makeStyles((theme) => ({ + modal: { + display: "flex", + alignItems: "center", + justifyContent: "center", + }, + paper: { + backgroundColor: theme.palette.background.paper, + boxShadow: theme.shadows[5], + padding: theme.spacing(2, 4, 3), + }, + modalContainer: { + backgroundColor: "#232323", + width: "80%", + height: "30vh", + }, + button: { + margin: 5, + marginTop: 20, + }, +})); + +export const AddContactModal = () => { + const [modal, setModal] = useState(false); + + const Modal = (props) => { + const [name, setName] = useState(""); + const [number, setNumber] = useState(""); + + const addContact = () => { + if (name === "" || number === "") { + console.log("You need to pass in values"); + } else { + Nui.send("contacts:add", { + name, + number, + }); + console.log(name, number); + } + }; + const classes = useStyles(); + return ( + +

New contact:

+ setName(e.target.value)} + /> + setNumber(e.target.value)} + id="number-basic" + type="number" + label="Phone Number" + color="primary" + /> + + +
+ ); + }; + + return ( + + + + + ); +}; diff --git a/phone/src/apps/contacts/components/ContactsApp.js b/phone/src/apps/contacts/components/ContactsApp.js index 98f2f6e..c5484b1 100644 --- a/phone/src/apps/contacts/components/ContactsApp.js +++ b/phone/src/apps/contacts/components/ContactsApp.js @@ -4,8 +4,7 @@ import { AppTitle } from "../../../ui/components/AppTitle"; import { AppContent } from "../../../ui/components/AppContent"; import { ContactList } from "./ContactList"; import { useApp } from "../../../os/apps/hooks/useApps"; -import { Button } from "../../../ui/components/Button"; -import AddCircleIcon from "@material-ui/icons/AddCircle"; +import { AddContactModal } from "./ContactModal"; export const ContactsApp = () => { const contacts = useApp("CONTACTS"); @@ -14,9 +13,7 @@ export const ContactsApp = () => { - + ); diff --git a/phone/src/apps/contacts/hooks/useContacts.js b/phone/src/apps/contacts/hooks/useContacts.js index 7d575bd..1b5f41f 100644 --- a/phone/src/apps/contacts/hooks/useContacts.js +++ b/phone/src/apps/contacts/hooks/useContacts.js @@ -5,24 +5,3 @@ export const useContacts = () => { const contacts = useRecoilValue(contactsState.contacts); return { contacts }; }; - -//const contactListState = atom({ -// key: "contactList", -// default: [ -// { -// id: 0, -// display: "Test Contact", -// phoneNumber: "000-1111", -// }, -// { -// id: 1, -// display: "Test Contact 2", -// phoneNumber: "000-1112", -// }, -// ], -//}); -// -//export const useContacts = () => { -// const [contactList, setContactList] = useRecoilState//(contactListState); -// return { contactList, setContactList }; -//}; diff --git a/phone/src/ui/components/Input.js b/phone/src/ui/components/Input.js new file mode 100644 index 0000000..e182f45 --- /dev/null +++ b/phone/src/ui/components/Input.js @@ -0,0 +1,24 @@ +import React from "react"; + +import styled from "styled-components"; + +const Input = styled("input")` + text-align: center; + padding: 10px; + border: none; + font-size: 20px; + outline: none; + background: transparent; + color: #fff; + margin-bottom: 1em; + border-bottom: 1px solid #fff; +`; + +export const TextInput = (props) => ( + +); diff --git a/phone/yarn.lock b/phone/yarn.lock index 726c7a5..4546a83 100644 --- a/phone/yarn.lock +++ b/phone/yarn.lock @@ -94,6 +94,15 @@ jsesc "^2.5.1" source-map "^0.5.0" +"@babel/generator@^7.11.5": + version "7.11.5" + resolved "https://registry.yarnpkg.com/@babel/generator/-/generator-7.11.5.tgz#a5582773425a468e4ba269d9a1f701fbca6a7a82" + integrity sha512-9UqHWJ4IwRTy4l0o8gq2ef8ws8UPzvtMkVKjTLAiRmza9p9V6Z+OfuNd9fB1j5Q67F+dVJtPC2sZXI8NM9br4g== + dependencies: + "@babel/types" "^7.11.5" + jsesc "^2.5.1" + source-map "^0.6.1" + "@babel/helper-annotate-as-pure@^7.0.0", "@babel/helper-annotate-as-pure@^7.10.4": version "7.10.4" resolved "https://registry.yarnpkg.com/@babel/helper-annotate-as-pure/-/helper-annotate-as-pure-7.10.4.tgz#5bf0d495a3f757ac3bda48b5bf3b3ba309c72ba3" @@ -323,6 +332,11 @@ resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.4.tgz#6fa1a118b8b0d80d0267b719213dc947e88cc0ca" integrity sha512-MggwidiH+E9j5Sh8pbrX5sJvMcsqS5o+7iB42M9/k0CD63MjYbdP4nhSh7uB5wnv2/RVzTZFTxzF/kIa5mrCqA== +"@babel/parser@^7.11.5": + version "7.11.5" + resolved "https://registry.yarnpkg.com/@babel/parser/-/parser-7.11.5.tgz#c7ff6303df71080ec7a4f5b8c003c58f1cf51037" + integrity sha512-X9rD8qqm695vgmeaQ4fvz/o3+Wk4ZzQvSHkDBgpYKxpD4qTAUm88ZKtHkVqIOsYFFbIQ6wQYhC6q7pjqVK0E0Q== + "@babel/plugin-proposal-async-generator-functions@^7.10.4", "@babel/plugin-proposal-async-generator-functions@^7.8.3": version "7.10.5" resolved "https://registry.yarnpkg.com/@babel/plugin-proposal-async-generator-functions/-/plugin-proposal-async-generator-functions-7.10.5.tgz#3491cabf2f7c179ab820606cec27fed15e0e8558" @@ -1163,6 +1177,21 @@ globals "^11.1.0" lodash "^4.17.19" +"@babel/traverse@^7.4.5": + version "7.11.5" + resolved "https://registry.yarnpkg.com/@babel/traverse/-/traverse-7.11.5.tgz#be777b93b518eb6d76ee2e1ea1d143daa11e61c3" + integrity sha512-EjiPXt+r7LiCZXEfRpSJd+jUMnBd4/9OUv7Nx3+0u9+eimMwJmG0Q98lw4/289JCoxSE8OolDMNZaaF/JZ69WQ== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/generator" "^7.11.5" + "@babel/helper-function-name" "^7.10.4" + "@babel/helper-split-export-declaration" "^7.11.0" + "@babel/parser" "^7.11.5" + "@babel/types" "^7.11.5" + debug "^4.1.0" + globals "^11.1.0" + lodash "^4.17.19" + "@babel/types@^7.0.0", "@babel/types@^7.10.4", "@babel/types@^7.10.5", "@babel/types@^7.11.0", "@babel/types@^7.3.0", "@babel/types@^7.4.0", "@babel/types@^7.4.4", "@babel/types@^7.7.0", "@babel/types@^7.9.0": version "7.11.0" resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.11.0.tgz#2ae6bf1ba9ae8c3c43824e5861269871b206e90d" @@ -1172,6 +1201,15 @@ lodash "^4.17.19" to-fast-properties "^2.0.0" +"@babel/types@^7.11.5": + version "7.11.5" + resolved "https://registry.yarnpkg.com/@babel/types/-/types-7.11.5.tgz#d9de577d01252d77c6800cee039ee64faf75662d" + integrity sha512-bvM7Qz6eKnJVFIn+1LPtjlBFPVN5jNDc1XmN15vWe7Q3DPBufWWsLiIvUu7xW87uTG6QoggpIDnUgLQvPheU+Q== + dependencies: + "@babel/helper-validator-identifier" "^7.10.4" + lodash "^4.17.19" + to-fast-properties "^2.0.0" + "@cnakazawa/watch@^1.0.3": version "1.0.4" resolved "https://registry.yarnpkg.com/@cnakazawa/watch/-/watch-1.0.4.tgz#f864ae85004d0fcab6f50be9141c4da368d1656a" @@ -1195,6 +1233,28 @@ resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413" integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow== +"@emotion/is-prop-valid@^0.8.8": + version "0.8.8" + resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.8.8.tgz#db28b1c4368a259b60a97311d6a952d4fd01ac1a" + integrity sha512-u5WtneEAr5IDG2Wv65yhunPSMLIpuKsbuOktRojfrEiEvRyC85LgPMZI63cr7NUqT8ZIGdSVg8ZKGxIug4lXcA== + dependencies: + "@emotion/memoize" "0.7.4" + +"@emotion/memoize@0.7.4": + version "0.7.4" + resolved "https://registry.yarnpkg.com/@emotion/memoize/-/memoize-0.7.4.tgz#19bf0f5af19149111c40d98bb0cf82119f5d9eeb" + integrity sha512-Ja/Vfqe3HpuzRsG1oBtWTHk2PGZ7GR+2Vz5iYGelAw8dx32K0y7PjVuxK6z1nMpZOqAFsRUPCkK1YjJ56qJlgw== + +"@emotion/stylis@^0.8.4": + version "0.8.5" + resolved "https://registry.yarnpkg.com/@emotion/stylis/-/stylis-0.8.5.tgz#deacb389bd6ee77d1e7fcaccce9e16c5c7e78e04" + integrity sha512-h6KtPihKFn3T9fuIrwvXXUOwlx3rfUvfZIcP5a6rh8Y7zjE3O06hT5Ss4S/YI1AYhuZ1kjaE/5EaOOI2NqSylQ== + +"@emotion/unitless@^0.7.4": + version "0.7.5" + resolved "https://registry.yarnpkg.com/@emotion/unitless/-/unitless-0.7.5.tgz#77211291c1900a700b8a78cfafda3160d76949ed" + integrity sha512-OWORNpfjMsSSUBVrRBVGECkhWcULOAJz9ZW8uK9qgxD+87M7jHRcvh/A96XXNhXTLmKcoYSQtBEX7lHMO7YRwg== + "@hapi/address@2.x.x": version "2.1.4" resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" @@ -2544,7 +2604,7 @@ babel-plugin-named-asset-import@^0.3.6: resolved "https://registry.yarnpkg.com/babel-plugin-named-asset-import/-/babel-plugin-named-asset-import-0.3.6.tgz#c9750a1b38d85112c9e166bf3ef7c5dbc605f4be" integrity sha512-1aGDUfL1qOOIoqk9QKGIo2lANk+C7ko/fqH0uIyC71x3PEGz0uVP8ISgfEsFuG+FKmjHTvFK/nNM8dowpmUxLA== -babel-plugin-styled-components@^1.10.0: +"babel-plugin-styled-components@>= 1", babel-plugin-styled-components@^1.10.0: version "1.11.1" resolved "https://registry.yarnpkg.com/babel-plugin-styled-components/-/babel-plugin-styled-components-1.11.1.tgz#5296a9e557d736c3186be079fff27c6665d63d76" integrity sha512-YwrInHyKUk1PU3avIRdiLyCpM++18Rs1NgyMXEAQC33rIXs/vro0A+stf4sT0Gf22Got+xRWB8Cm0tw+qkRzBA== @@ -3014,6 +3074,11 @@ camelcase@5.3.1, camelcase@^5.0.0, camelcase@^5.2.0, camelcase@^5.3.1: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-5.3.1.tgz#e3c9b31569e106811df242f715725a1f4c494320" integrity sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg== +camelize@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/camelize/-/camelize-1.0.0.tgz#164a5483e630fa4321e5af07020e531831b2609b" + integrity sha1-FkpUg+Yw+kMh5a8HAg5TGDGyYJs= + caniuse-api@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/caniuse-api/-/caniuse-api-3.0.0.tgz#5e4d90e2274961d46291997df599e3ed008ee4c0" @@ -3604,6 +3669,11 @@ css-blank-pseudo@^0.1.4: dependencies: postcss "^7.0.5" +css-color-keywords@^1.0.0: + version "1.0.0" + resolved "https://registry.yarnpkg.com/css-color-keywords/-/css-color-keywords-1.0.0.tgz#fea2616dc676b2962686b3af8dbdbe180b244e05" + integrity sha1-/qJhbcZ2spYmhrOvjb2+GAskTgU= + css-color-names@0.0.4, css-color-names@^0.0.4: version "0.0.4" resolved "https://registry.yarnpkg.com/css-color-names/-/css-color-names-0.0.4.tgz#808adc2e79cf84738069b646cb20ec27beb629e0" @@ -3692,6 +3762,15 @@ css-select@^2.0.0: domutils "^1.7.0" nth-check "^1.0.2" +css-to-react-native@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/css-to-react-native/-/css-to-react-native-3.0.0.tgz#62dbe678072a824a689bcfee011fc96e02a7d756" + integrity sha512-Ro1yETZA813eoyUp2GDBhG2j+YggidUmzO1/v9eYBKR2EHVEniE2MI/NqpTQ954BMpTPZFsGNPm46qFB9dpaPQ== + dependencies: + camelize "^1.0.0" + css-color-keywords "^1.0.0" + postcss-value-parser "^4.0.2" + css-tree@1.0.0-alpha.37: version "1.0.0-alpha.37" resolved "https://registry.yarnpkg.com/css-tree/-/css-tree-1.0.0-alpha.37.tgz#98bebd62c4c1d9f960ec340cf9f7522e30709a22" @@ -5520,7 +5599,7 @@ hmac-drbg@^1.0.0: minimalistic-assert "^1.0.0" minimalistic-crypto-utils "^1.0.1" -hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.2: +hoist-non-react-statics@^3.0.0, hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.3.2: version "3.3.2" resolved "https://registry.yarnpkg.com/hoist-non-react-statics/-/hoist-non-react-statics-3.3.2.tgz#ece0acaf71d62c2969c2ec59feff42a4b1a85b45" integrity sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw== @@ -10209,6 +10288,11 @@ shallow-clone@^3.0.0: dependencies: kind-of "^6.0.2" +shallowequal@^1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/shallowequal/-/shallowequal-1.1.0.tgz#188d521de95b9087404fd4dcb68b13df0ae4e7f8" + integrity sha512-y0m1JoUZSlPAjXVtPPW70aZWfIL/dSP7AFkRnniLCrK/8MDKog3TySTBmckD+RObVxH0v4Tox67+F14PdED2oQ== + shebang-command@^1.2.0: version "1.2.0" resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea" @@ -10729,6 +10813,22 @@ style-loader@0.23.1, style-loader@^0.23.1: loader-utils "^1.1.0" schema-utils "^1.0.0" +styled-components@^5.1.1: + version "5.1.1" + resolved "https://registry.yarnpkg.com/styled-components/-/styled-components-5.1.1.tgz#96dfb02a8025794960863b9e8e365e3b6be5518d" + integrity sha512-1ps8ZAYu2Husx+Vz8D+MvXwEwvMwFv+hqqUwhNlDN5ybg6A+3xyW1ECrAgywhvXapNfXiz79jJyU0x22z0FFTg== + dependencies: + "@babel/helper-module-imports" "^7.0.0" + "@babel/traverse" "^7.4.5" + "@emotion/is-prop-valid" "^0.8.8" + "@emotion/stylis" "^0.8.4" + "@emotion/unitless" "^0.7.4" + babel-plugin-styled-components ">= 1" + css-to-react-native "^3.0.0" + hoist-non-react-statics "^3.0.0" + shallowequal "^1.1.0" + supports-color "^5.5.0" + stylehacks@^4.0.0: version "4.0.3" resolved "https://registry.yarnpkg.com/stylehacks/-/stylehacks-4.0.3.tgz#6718fcaf4d1e07d8a1318690881e8d96726a71d5" @@ -10743,7 +10843,7 @@ supports-color@^2.0.0: resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7" integrity sha1-U10EXOa2Nj+kARcIRimZXp3zJMc= -supports-color@^5.3.0: +supports-color@^5.3.0, supports-color@^5.5.0: version "5.5.0" resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow==