diff --git a/electron-react/.eslintrc b/electron-react/.eslintrc new file mode 100644 index 0000000000..9b4e0d28b9 --- /dev/null +++ b/electron-react/.eslintrc @@ -0,0 +1,16 @@ +{ + "eslintConfig": { + "extends": ["react-app", "shared-config"], + "rules": { + "additional-rule": "warn" + }, + "overrides": [ + { + "files": ["**/*.ts?(x)"], + "rules": { + "additional-typescript-only-rule": "warn" + } + } + ] + } +} \ No newline at end of file diff --git a/electron-react/package.json b/electron-react/package.json index ec3651fff5..9e1b5b7803 100644 --- a/electron-react/package.json +++ b/electron-react/package.json @@ -29,6 +29,7 @@ "react-redux": "^7.2.1", "react-router": "^5.2.0", "react-router-dom": "^5.2.0", + "react-use": "^15.3.4", "redux": "^4.0.5", "redux-thunk": "^2.3.0", "stringify": "^5.2.0", diff --git a/electron-react/src/components/App.tsx b/electron-react/src/components/App.tsx index 10617060d6..25e718f057 100644 --- a/electron-react/src/components/App.tsx +++ b/electron-react/src/components/App.tsx @@ -3,7 +3,7 @@ import { CssBaseline } from "@material-ui/core"; import { Provider } from "react-redux"; import { ModalDialog, Spinner } from '../pages/ModalDialog'; import Router from './Router'; -import theme from '../theme/default'; +import theme from '../theme/light'; import WebSocketConnection from "../hocs/WebsocketConnection"; import { daemon_rpc_ws } from "../util/config"; import store from "../modules/store"; diff --git a/electron-react/src/components/Router.tsx b/electron-react/src/components/Router.tsx index b074bc5a89..39410b75ea 100644 --- a/electron-react/src/components/Router.tsx +++ b/electron-react/src/components/Router.tsx @@ -1,7 +1,7 @@ import React from 'react'; import { HashRouter, Switch, Route } from 'react-router-dom'; import SelectKey from "./selectKey/SelectKey"; -import NewWallet from "../pages/NewWallet"; +import NewWallet from "./newWallet/NewWallet"; import OldWallet from "../pages/OldWallet"; import Dashboard from "../pages/Dashboard"; import { RestoreBackup } from "../pages/backup/restoreBackup"; @@ -41,9 +41,12 @@ export default function Router() { return ( - + + + + ); diff --git a/electron-react/src/components/form/TextField.tsx b/electron-react/src/components/form/TextField.tsx new file mode 100644 index 0000000000..9974e7ab67 --- /dev/null +++ b/electron-react/src/components/form/TextField.tsx @@ -0,0 +1,53 @@ +import styled from "styled-components"; +import { TextField } from "@material-ui/core"; + +export default styled(TextField)` + color: #ffffff; + + & .MuiFormLabel-root { + color: #e3f2fd; + } + + & .MuiInputLabel-root { + color: #e3f2fd; + } + + & label.Mui-focused { + color: #e3f2fd; + } + + & label.Mui-required { + color: #e3f2fd; + } + + & label.Mui-disabled { + color: #e3f2fd; + } + + & label.Mui-root { + color: #e3f2fd; + } + + & .MuiInput-underline:after { + border-bottom-color: #e3f2fd; + } + + & .MuiOutlinedInput-root { + & fieldset { + border-color: #e3f2fd; + } + &:hover fieldset { + border-color: #e3f2fd; + } + &.Mui-focused fieldset { + border-color: #e3f2fd; + } + &.Mui-disabled fieldset { + border-color: #e3f2fd; + } + } + + & .MuiOutlinedInput-input { + color: #ffffff; + } +`; diff --git a/electron-react/src/components/loading/Loading.tsx b/electron-react/src/components/loading/Loading.tsx new file mode 100644 index 0000000000..a9b0030a62 --- /dev/null +++ b/electron-react/src/components/loading/Loading.tsx @@ -0,0 +1,6 @@ +import { CircularProgress } from '@material-ui/core'; +import styled from 'styled-components'; + +export default styled(CircularProgress)` + color: white; +`; diff --git a/electron-react/src/components/loading/LoadingScreen.tsx b/electron-react/src/components/loading/LoadingScreen.tsx index fa243acaa9..97ad996ace 100644 --- a/electron-react/src/components/loading/LoadingScreen.tsx +++ b/electron-react/src/components/loading/LoadingScreen.tsx @@ -1,11 +1,8 @@ import React, { ReactNode } from 'react'; -import { CircularProgress, Typography } from '@material-ui/core'; +import { Typography } from '@material-ui/core'; import styled from 'styled-components'; import LayoutHero from '../layout/LayoutHero'; - -const StyledCircularProgress = styled(CircularProgress)` - color: white; -`; +import Loading from './Loading'; const StyledTypography = styled(Typography)` color: white; @@ -23,7 +20,7 @@ export default function LoadingScreen(props: Props) { {children} - + ); } diff --git a/electron-react/src/components/logo/Logo.tsx b/electron-react/src/components/logo/Logo.tsx new file mode 100644 index 0000000000..59d1d9a73a --- /dev/null +++ b/electron-react/src/components/logo/Logo.tsx @@ -0,0 +1,8 @@ +import React from 'react'; +import logo from "../../assets/img/chia_logo.svg"; + +export default function Logo() { + return ( + Logo + ); +} \ No newline at end of file diff --git a/electron-react/src/components/newWallet/NewWallet.tsx b/electron-react/src/components/newWallet/NewWallet.tsx new file mode 100644 index 0000000000..2998226e9c --- /dev/null +++ b/electron-react/src/components/newWallet/NewWallet.tsx @@ -0,0 +1,91 @@ +import React from "react"; +import { Typography, Button, Grid, Container } from "@material-ui/core"; +import { ArrowBackIos as ArrowBackIosIcon } from "@material-ui/icons"; +import { useSelector, useDispatch } from "react-redux"; +import { useEffectOnce } from 'react-use'; +import { genereate_mnemonics, add_new_key_action } from "../../modules/message"; +import TextField from "../form/TextField"; +import type { RootState } from "../../modules/rootReducer"; +import Logo from '../logo/Logo'; +import Flex from '../flex/Flex'; +import Loading from '../loading/Loading'; +import Link from '../router/Link'; +import LayoutHero from "../layout/LayoutHero"; + +const MnemonicField = (props: any) => { + return ( + + + + ); +}; + +export default function NewWallet() { + const dispatch = useDispatch(); + const words = useSelector((state: RootState) => state.wallet_state.mnemonic); + + useEffectOnce(() => { + const get_mnemonics = genereate_mnemonics(); + dispatch(get_mnemonics); + }); + + function handleNext() { + dispatch(add_new_key_action(words)); + } + + return ( + + + + + + + + + + + New Wallet + + + Welcome! The following words are used for your wallet backup. + Without them, you will lose access to your wallet, keep them safe! + Write down each word along with the order number next to them. + (Order is important) + + {!!words.length ? ( + + {words.map((word, i) => ( + + ))} + + ) : ( + + )} + + + + + + + ); +} diff --git a/electron-react/src/components/selectKey/SelectKey.tsx b/electron-react/src/components/selectKey/SelectKey.tsx index dffe5ad142..e4f88a4c57 100644 --- a/electron-react/src/components/selectKey/SelectKey.tsx +++ b/electron-react/src/components/selectKey/SelectKey.tsx @@ -1,12 +1,13 @@ import React, { useState } from "react"; import { useSelector, useDispatch } from "react-redux"; -import { Container, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Tooltip, List, ListItem, ListItemText, IconButton } from "@material-ui/core"; +import { Card, Typography, Container, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle, Tooltip, List, ListItem, ListItemText, IconButton } from "@material-ui/core"; import ListItemSecondaryAction from "@material-ui/core/ListItemSecondaryAction"; import { Delete as DeleteIcon, Visibility as VisibilityIcon } from "@material-ui/icons"; import Button from '../button/Button'; import { makeStyles } from "@material-ui/core/styles"; -import logo from "../../assets/img/chia_logo.svg"; import LayoutHero from '../layout/LayoutHero'; +import Flex from '../flex/Flex'; +import Logo from '../logo/Logo'; import { login_action, delete_key, @@ -21,15 +22,9 @@ import { presentNewWallet } from "../../modules/entranceMenu"; import { resetMnemonic } from "../../modules/mnemonic"; -import { RootState } from "../../modules/rootReducer"; +import type { RootState } from "../../modules/rootReducer"; const useStyles = makeStyles(theme => ({ - paper: { - display: "flex", - flexDirection: "column", - alignItems: "center", - height: "100%" - }, centeredSpan: { display: "flex", flexDirection: "column", @@ -38,29 +33,6 @@ const useStyles = makeStyles(theme => ({ textField: { borderColor: "#ffffff" }, - topButton: { - width: 400, - height: 45, - marginTop: theme.spacing(4), - marginBottom: theme.spacing(1) - }, - bottomButton: { - width: 400, - height: 45, - marginTop: theme.spacing(2), - marginBottom: theme.spacing(1) - }, - bottomButtonRed: { - width: 400, - height: 45, - marginTop: theme.spacing(2), - marginBottom: theme.spacing(1), - color: "red" - }, - logo: { - marginTop: theme.spacing(8), - marginBottom: theme.spacing(3) - }, whiteText: { color: "white" }, @@ -79,7 +51,7 @@ const useStyles = makeStyles(theme => ({ export default function SelectKey() { const dispatch = useDispatch(); const classes = useStyles(); - const public_key_fingerprints = useSelector( + const publicKeyFingerprints = useSelector( (state: RootState) => state.wallet_state.public_key_fingerprints ); @@ -122,92 +94,100 @@ export default function SelectKey() { dispatch(changeEntranceMenu(presentNewWallet)); }; - const list_items = public_key_fingerprints.map(fingerprint => { - return ( - - - - - - - - - - - - - - - - ); - }); + const hasFingerprints = publicKeyFingerprints && !!publicKeyFingerprints.length; return ( - -
- Logo - {public_key_fingerprints && public_key_fingerprints.length > 0 ? ( + + + + {hasFingerprints ? (

Select Key

) : ( - -

Sign In

-

+ <> + + Sign In + + Welcome to Chia. Please log in with an existing key, or create a a new key. -

-
+ + )} -
- {list_items} -
- + + {hasFingerprints && ( + + + {publicKeyFingerprints.map((fingerprint) => ( + + + + + + + + + + + + + + + + ))} + + + )} + + + + + + - - - - - -
+ +