first working UI

This commit is contained in:
erik-sn committed 2020-09-19 20:33:46 -04:00
1 parent c7bbf3bc35
commit 64973a5cc9
7 files changed
+275 -3

No files matched your search

@@ -0,0 +1,108 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { Button, TextField, Paper } from "@material-ui/core";
import InsertPhotoIcon from "@material-ui/icons/InsertPhoto";
import GifIcon from "@material-ui/icons/Gif";
import CloseIcon from "@material-ui/icons/Close";
import EmojiIcon from "@material-ui/icons/SentimentSatisfied";
import TweetText from "./TweetText";
const useStyles = makeStyles((theme) => ({
button: {
margin: 5,
marginTop: 20,
},
root: {
zIndex: 2,
background: "#232323",
marginTop: "15px",
width: "90%",
display: "flex",
flexFlow: "column nowrap",
},
close: {
position: "absolute",
top: "12px",
right: "4px",
zIndex: 2,
},
buttonsContainer: {
paddingBottom: "8px",
display: "flex",
flexFlow: "row nowrap",
justifyContent: "space-between",
flex: "1 0 45px",
},
leftButtons: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "flex-start",
},
rightButtons: {
display: "flex",
flexFlow: "row nowrap",
justifyContent: "flex-end",
alignItems: "justify-content",
marginRight: "15px",
},
button: {
background: "transparent",
},
displayBlock: {
/*Sets modal to center*/
display: "flex",
flexFlow: "column nowrap",
justifyContent: "center",
alignItems: "center",
position: "relative",
},
displayNone: {
display: "none",
},
}));
export const AddTweetModal = ({ visible, handleClose }) => {
const [text, setText] = useState("");
const classes = useStyles();
const { t } = useTranslation();
const showHideClassName = visible
? classes.displayBlock
: classes.displayNone;
const submitTweet = () => {
console.log("submitting tweet");
};
return (
<div className={showHideClassName}>
<Paper className={classes.root}>
<Button className={classes.close} onClick={handleClose}>
<CloseIcon color="action" />
</Button>
<TweetText value={text} onChange={(e) => setText(e.target.value)} />
<div className={classes.buttonsContainer}>
<div className={classes.leftButtons}>
<Button className={classes.button}>
<InsertPhotoIcon color="action" />
</Button>
<Button className={classes.button}>
<GifIcon color="action" />
</Button>
<Button className={classes.button}>
<EmojiIcon color="action" />
</Button>
</div>
<div className={classes.rightButtons}>
<Button variant="contained" color="primary" onClick={submitTweet}>
{t("APPS_TWITTER_TWEET")}
</Button>
</div>
</div>
</Paper>
</div>
);
};
export default AddTweetModal;
@@ -0,0 +1,33 @@
import React, { useState } from "react";
import { useTranslation } from "react-i18next";
import { makeStyles } from "@material-ui/core/styles";
import { TextField } from "@material-ui/core";
const useStyles = makeStyles((theme) => ({
textField: {
flex: "1 1 100%",
padding: "10px 15px",
marginTop: "15px",
},
textFieldInput: {
fontSize: "22px",
},
}));
export const TweetText = ({ text, setText }) => {
const classes = useStyles();
const { t } = useTranslation();
return (
<TextField
value={text}
inputProps={{ className: classes.textFieldInput }}
className={classes.textField}
onChange={(e) => setText(e.target.value)}
multiline
placeholder={t("APPS_TWITTER_PLACEHOLDER")}
/>
);
};
export default TweetText;
@@ -0,0 +1,66 @@
import React, { useState, useCallback, useEffect } from "react";
import { blue } from "@material-ui/core/colors";
import { makeStyles, Button } from "@material-ui/core";
import AddCircleIcon from "@material-ui/icons/AddCircle";
import { AppTitle } from "../../../ui/components/AppTitle";
import { AppWrapper } from "../../../ui/components";
import { AppContent } from "../../../ui/components/AppContent";
import { useTranslation } from "react-i18next";
import { useApp } from "../../../os/apps/hooks/useApps";
import AddTweetModal from "./AddTweetModal";
const useStyles = makeStyles((theme) => ({
root: {
height: "90px",
display: "flex",
justifyContent: "center",
backgroundColor: blue[600],
alignItems: "center",
},
header: {
fontFamily: "'Bebas Neue', cursive",
textAlign: "center",
fontSize: 50,
},
}));
export const TwitterApp = () => {
const [modalVisible, setModalVisible] = useState(true);
const { t } = useTranslation();
const classes = useStyles();
const twitter = useApp("TWITTER");
const openModal = useCallback(() => setModalVisible(true), []);
const hideModal = useCallback(() => setModalVisible(false), []);
useEffect(() => {
const listener = window.addEventListener(
"keydown",
(e) => {
if (e.key == "Escape" || e.key == "Esc") {
e.preventDefault();
hideModal();
}
},
true
);
return () => window.removeEventListener("keydown", listener);
}, []);
return (
<AppWrapper>
<AppTitle app={twitter} className={classes.root} />
<Button
onClick={openModal}
variant="contained"
style={{ backgroundColor: "#232323" }}
>
<AddCircleIcon color="action" />
</Button>
<AppContent>
<AddTweetModal visible={modalVisible} handleClose={hideModal} />
</AppContent>
</AppWrapper>
);
};
+5 -1
View File
@@ -11,6 +11,10 @@
"APPS_BANK_WITHDRAW": "Withdraw",
"APPS_BANK_TRANSFER": "Transfer",
"APPS_SETTINGS_OPTIONS_WALLPAPER": "Wallpaper",
"APPS_SETTINGS_OPTIONS_FRAME": "Frame"
"APPS_SETTINGS_OPTIONS_FRAME": "Frame",
"APPS_TWITTER": "Twitter",
"APPS_TWITTER_PLACEHOLDER": "What's happening?",
"APPS_TWITTER_TWEET": "Tweet",
"APPS_TWITTER_CLOSE": "Close"
}
}
+12
View File
@@ -2,6 +2,7 @@ import React from "react";
import { useConfig } from "../../../config/hooks/useConfig";
import {
blue,
common,
grey,
green,
orange,
@@ -13,6 +14,7 @@ import SettingsIcon from "@material-ui/icons/Settings";
import PhoneIcon from "@material-ui/icons/Phone";
import AccountBalanceIcon from "@material-ui/icons/AccountBalance";
import MessageIcon from "@material-ui/icons/Message";
import AccessibilityIcon from "@material-ui/icons/Accessibility";
import { atom } from "recoil";
import { CalculatorIcon } from "../../../apps/calculator/components/CalculatorIcon";
import { Route } from "react-router-dom";
@@ -22,6 +24,7 @@ import { CalculatorApp } from "../../../apps/calculator/components/CalculatorApp
import { SettingsApp } from "../../../apps/settings/components/SettingsApp";
import { BankApp } from "../../../apps/bank/components/BankApp";
import { MessagesApp } from "../../../apps/messages/components/MessagesApp";
import { TwitterApp } from "../../../apps/twitter/components/TwitterApp";
const appsState = atom({
key: "apps",
@@ -81,6 +84,15 @@ const appsState = atom({
path: "/bank",
Route: () => <Route path="/bank" component={BankApp} />,
},
{
id: "TWITTER",
nameLocale: "APPS_TWITTER",
icon: <AccessibilityIcon />,
backgroundColor: blue[600],
color: common.white,
path: "/twitter",
Route: () => <Route path="/twitter" component={TwitterApp} />,
},
],
},
});
+7 -1
View File
@@ -4,4 +4,10 @@ Config.Locale = 'en'
Config.KeyTogglePhone = 288 -- F1
Config.KeyTakeCall = 38 -- E
Config.PhoneAsItem = true
Config.PhoneAsItem = false
Config.twitter = {}
Config.twitter.characterLimit = 240
Config.twitter.renderImages = true -- whether or not links to images are automatically rendered on the UI
Config.twitter.renderGifs = true -- whether or not links to gifs are automatically rendered on the UI
Config.twitter.renderVideos = true -- whether or not links to videos are automatically rendered on the UI
+44 -1
View File
@@ -1 +1,44 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="%PUBLIC_URL%/favicon.ico"/><link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap"/><link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><title>React App</title></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script src="main.js"></script></body></html>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="/favicon.ico" />
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:300,400,500,700&display=swap" />
<link rel="stylesheet" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<!--
Notice the use of in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
<script src="dev.js"></script></body>
</html>