Skip to content
This repository has been archived by the owner on Mar 4, 2024. It is now read-only.

Commit

Permalink
Merge pull request #237 from chesslablab/issue/236-update-to-MUI-5
Browse files Browse the repository at this point in the history
Issue/236 update to m UI 5
  • Loading branch information
programarivm authored Jan 4, 2022
2 parents 456e150 + a357e31 commit a02c4de
Show file tree
Hide file tree
Showing 28 changed files with 93 additions and 173 deletions.
27 changes: 13 additions & 14 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,30 @@
"url": "git+ssh://git@github.com/chesslablab/redux-chess.git"
},
"dependencies": {
"@material-ui/core": "^4.11.4",
"@material-ui/icons": "^4.11.2",
"@material-ui/lab": "^4.0.0-alpha.60",
"@material-ui/styles": "^4.11.4",
"@material-ui/system": "^4.12.1",
"@material-ui/utils": "^4.11.2",
"@emotion/react": "^11.7.1",
"@emotion/styled": "^11.6.0",
"@mui/icons-material": "^5.2.5",
"@mui/material": "^5.2.7",
"@mui/styles": "^5.2.3",
"html2canvas": "^1.3.2",
"jwt-decode": "^3.1.2",
"recharts": "^2.1.0",
"redux": "^4.1.0",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.3.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"react-redux": "^7.2.4",
"react-scripts": "4.0.3",
"react-timer-hook": "^3.0.4"
"react-scripts": "^5.0.0",
"react-timer-hook": "^3.0.4",
"recharts": "^2.1.0",
"redux": "^4.1.0",
"redux-devtools-extension": "^2.13.9",
"redux-thunk": "^2.3.0"
},
"devDependencies": {
"@testing-library/react-hooks": "^7.0.1",
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"enzyme": "^3.11.0",
"enzyme-adapter-react-17-updated": "^1.0.2",
"@testing-library/react-hooks": "^7.0.1"
"enzyme-adapter-react-17-updated": "^1.0.2"
}
}
21 changes: 8 additions & 13 deletions src/components/Buttons.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import React, { useState } from 'react';
import { Button, Menu, MenuItem } from '@material-ui/core';
import ComputerIcon from '@material-ui/icons/Computer';
import TuneIcon from '@material-ui/icons/Tune';
import PublishIcon from '@material-ui/icons/Publish';
import GroupAddIcon from '@material-ui/icons/GroupAdd';
import SettingsIcon from '@material-ui/icons/Settings';
import { Button, ButtonGroup, Menu, MenuItem } from '@mui/material';
import ComputerIcon from '@mui/icons-material/Computer';
import TuneIcon from '@mui/icons-material/Tune';
import PublishIcon from '@mui/icons-material/Publish';
import GroupAddIcon from '@mui/icons-material/GroupAdd';
import SettingsIcon from '@mui/icons-material/Settings';
import { useDispatch, useSelector } from 'react-redux';
import boardActionTypes from '../constants/boardActionTypes';
import loadFenDialogActionTypes from '../constants/loadFenDialogActionTypes';
Expand Down Expand Up @@ -69,11 +69,10 @@ const Buttons = ({ props }) => {
const handleDownloadImage = () => DownloadImage();

return (
<div>
<ButtonGroup variant="contained" aria-label="outlined primary button group">
<Button
startIcon={<GroupAddIcon />}
onClick={handleClickPlayFriend}
style={{ textTransform: 'none' }}
>
Invite a Friend
</Button>
Expand All @@ -96,15 +95,13 @@ const Buttons = ({ props }) => {
</Menu>
<Button
startIcon={<TuneIcon />}
style={{ textTransform: 'none' }}
onClick={() => wsMssgQuit(state).then(() => wsMssgStartAnalysis(state.server.ws))}
>
Analysis Board
</Button>
<Button
startIcon={<ComputerIcon />}
onClick={handleClickPlayWithTheComputer}
style={{ textTransform: 'none' }}
>
Play With the Computer
</Button>
Expand All @@ -126,7 +123,6 @@ const Buttons = ({ props }) => {
<Button
startIcon={<PublishIcon />}
onClick={handleClickLoad}
style={{ textTransform: 'none' }}
>
Load
</Button>
Expand All @@ -148,7 +144,6 @@ const Buttons = ({ props }) => {
<Button
onClick={handleClickSettings}
startIcon={<SettingsIcon />}
style={{ textTransform: 'none' }}
>
Settings
</Button>
Expand Down Expand Up @@ -209,7 +204,7 @@ const Buttons = ({ props }) => {
Image
</MenuItem>
</Menu>
</div>
</ButtonGroup>
);
}

Expand Down
39 changes: 11 additions & 28 deletions src/components/Chess.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import React from "react";
import { makeStyles } from "@material-ui/core/styles";
import { Provider } from "react-redux";
import { CssBaseline } from "@material-ui/core";
import Grid from "@material-ui/core/Grid";
import Paper from "@material-ui/core/Paper";
import { CssBaseline } from "@mui/material";
import { makeStyles } from '@mui/styles';
import Grid from "@mui/material/Grid";
import Paper from "@mui/material/Paper";
import LoadFenDialog from "./Dialog/LoadFenDialog";
import FenDialog from "./Dialog/FenDialog";
import TakebackOfferDialog from "./Dialog/TakebackOfferDialog";
Expand All @@ -30,45 +30,28 @@ import InfoAlert from "./InfoAlert.js";
import "../index.css";
import store from "../store";

const useStyles = makeStyles((theme) => ({
container: {
flexGrow: 1,
padding: theme.spacing(2),
},
buttons: {
marginBottom: theme.spacing(2),
},
leftCol: {
marginRight: theme.spacing(2),
marginBottom: theme.spacing(2),
},
const useStyles = makeStyles({
paper: {
paddingTop: theme.spacing(1),
paddingLeft: theme.spacing(2),
paddingRight: theme.spacing(2),
paddingBottom: theme.spacing(2),
marginBottom: theme.spacing(2),
padding: 10,
},
}));
});

const Chess = ({ props }) => {
const classes = useStyles();

return (
<Provider store={store}>
<CssBaseline />
<Grid container className={classes.container}>
<Grid item xs={12} className={classes.buttons}>
<Grid container spacing={2}>
<Grid item xs={12}>
<Buttons props={props} />
</Grid>
<Grid item xs={12} md={3} className={classes.leftCol}>
<Grid item xs={12} md={3}>
<Paper className={classes.paper}>
<MainBreadcrumbs />
<History />
<GameClock />
<Grid container className={classes.container}>
<MoveValidator />
</Grid>
<MoveValidator />
<ButtonsPlayFriendMode />
</Paper>
<InfoAlert />
Expand Down
17 changes: 9 additions & 8 deletions src/components/Dialog/CreateInviteCodeDialog.js
Original file line number Diff line number Diff line change
@@ -1,23 +1,24 @@
import React from "react";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, TextField } from '@mui/material';
import { useDispatch, useSelector } from "react-redux";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, TextField } from '@material-ui/core';
import { makeStyles } from '@material-ui/core/styles';
import { makeStyles } from '@mui/styles';
import { wsMssgQuit, wsMssgStartPlayfriend } from '../../actions/serverActions';
import createInviteCodeDialogActions from '../../constants/createInviteCodeDialogActionTypes';
import Pgn from '../../utils/Pgn';

const useStyles = makeStyles((theme) => ({
root: {
const useStyles = makeStyles({
form: {
marginTop: 10,
'& .MuiTextField-root': {
margin: theme.spacing(1),
padding: 15,
},
},
}));
});

const CreateInviteCodeDialog = () => {
const classes = useStyles();
const state = useSelector(state => state);
const dispatch = useDispatch();
const classes = useStyles();

const handleCreateCode = (event) => {
event.preventDefault();
Expand All @@ -34,7 +35,7 @@ const CreateInviteCodeDialog = () => {
<Dialog open={state.createInviteCodeDialog.open} maxWidth="sm" fullWidth={true}>
<DialogTitle>Create invite code</DialogTitle>
<DialogContent>
<form className={classes.root} onSubmit={handleCreateCode}>
<form className={classes.form} onSubmit={handleCreateCode}>
<TextField
select
fullWidth
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DrawAcceptDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from "@material-ui/core";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle } from "@mui/material";
import { wsMssgDraw } from "../../actions/serverActions";
import drawAcceptDialogActionTypes from "../../constants/drawAcceptDialogActionTypes";
import Wording from "../../utils/Wording.js";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/DrawOfferDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DialogActions,
DialogContent,
DialogTitle,
} from "@material-ui/core";
} from "@mui/material";
import Wording from "../../utils/Wording.js";
import { useDispatch, useSelector } from "react-redux";
import { wsMssgDraw } from "../../actions/serverActions";
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/EnterInviteCodeDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { Button, Dialog, DialogActions, DialogContent, TextField } from "@material-ui/core";
import { Button, Dialog, DialogActions, DialogContent, TextField } from "@mui/material";
import { wsMssgAccept, wsMssgQuit } from "../../actions/serverActions";
import enterInviteCodeDialogActions from "../../constants/enterInviteCodeDialogActionTypes";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/FenDialog.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField } from '@material-ui/core';
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField } from '@mui/material';
import { useDispatch, useSelector } from "react-redux";
import fenDialogActions from '../../constants/fenDialogActionTypes';

Expand Down
4 changes: 2 additions & 2 deletions src/components/Dialog/HeuristicPictureDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ import {
DialogActions,
DialogContent,
DialogTitle,
} from "@material-ui/core";
import Alert from "@material-ui/lab/Alert";
} from "@mui/material";
import Alert from "@mui/material/Alert";
import HeuristicPicture from "../HeuristicPicture.js";
import { useDispatch, useSelector } from "react-redux";
import heuristicPictureDialogActions from "../../constants/heuristicPictureDialogActionTypes";
Expand Down
25 changes: 3 additions & 22 deletions src/components/Dialog/LoadFenDialog.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
import React from "react";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
TextField,
} from "@material-ui/core";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField } from "@mui/material";
import { useDispatch, useSelector } from "react-redux";
import { makeStyles } from "@material-ui/core/styles";
import { wsMssgStartLoadfen, wsMssgQuit } from "../../actions/serverActions";
import boardActionTypes from "../../constants/boardActionTypes";
import loadFenDialogActions from "../../constants/loadFenDialogActionTypes";
import modeActionTypes from "../../constants/modeActionTypes";

const useStyles = makeStyles((theme) => ({
root: {
"& .MuiTextField-root": {
margin: theme.spacing(1),
},
},
}));

const LoadFenDialog = () => {
const state = useSelector((state) => state);
const dispatch = useDispatch();
const classes = useStyles();

const handleLoad = (event) => {
event.preventDefault();
Expand All @@ -40,13 +23,11 @@ const LoadFenDialog = () => {
<Dialog open={state.loadFenDialog.open} maxWidth="sm" fullWidth={true}>
<DialogTitle>Load FEN</DialogTitle>
<DialogContent>
<form className={classes.root} onSubmit={handleLoad}>
<form onSubmit={handleLoad}>
<TextField fullWidth required name="fen" label="FEN string" />
<DialogActions>
<Button type="submit">Load</Button>
<Button
onClick={() => dispatch({ type: loadFenDialogActions.CLOSE })}
>
<Button onClick={() => dispatch({ type: loadFenDialogActions.CLOSE })}>
Cancel
</Button>
</DialogActions>
Expand Down
25 changes: 3 additions & 22 deletions src/components/Dialog/LoadPgnDialog.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,14 @@
import React from "react";
import {
Button,
Dialog,
DialogActions,
DialogContent,
DialogTitle,
TextField,
} from "@material-ui/core";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, TextField } from "@mui/material";
import { useDispatch, useSelector } from "react-redux";
import { makeStyles } from "@material-ui/core/styles";
import { wsMssgStartLoadpgn, wsMssgQuit } from "../../actions/serverActions";
import boardActionTypes from "../../constants/boardActionTypes";
import loadPgnDialogActions from "../../constants/loadPgnDialogActionTypes";
import modeActionTypes from "../../constants/modeActionTypes";

const useStyles = makeStyles((theme) => ({
root: {
"& .MuiTextField-root": {
margin: theme.spacing(1),
},
},
}));

const LoadPgnDialog = () => {
const state = useSelector((state) => state);
const dispatch = useDispatch();
const classes = useStyles();

const handleLoad = (event) => {
event.preventDefault();
Expand All @@ -40,7 +23,7 @@ const LoadPgnDialog = () => {
<Dialog open={state.loadPgnDialog.open} maxWidth="sm" fullWidth={true}>
<DialogTitle>Load PGN</DialogTitle>
<DialogContent>
<form className={classes.root} onSubmit={handleLoad}>
<form onSubmit={handleLoad}>
<TextField
fullWidth
required
Expand All @@ -51,9 +34,7 @@ const LoadPgnDialog = () => {
/>
<DialogActions>
<Button type="submit">Load</Button>
<Button
onClick={() => dispatch({ type: loadPgnDialogActions.CLOSE })}
>
<Button onClick={() => dispatch({ type: loadPgnDialogActions.CLOSE })}>
Cancel
</Button>
</DialogActions>
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/PgnDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
DialogContent,
DialogTitle,
TextField,
} from "@material-ui/core";
} from "@mui/material";
import { useDispatch, useSelector } from "react-redux";
import pgnDialogActions from "../../constants/pgnDialogActionTypes";

Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/PlayLikeGrandmasterDialog.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from "react";
import { useDispatch, useSelector } from "react-redux";
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, TextField } from '@material-ui/core';
import { Button, Dialog, DialogActions, DialogContent, DialogTitle, MenuItem, TextField } from '@mui/material';
import { wsMssgQuit, wsMssgResponse, wsMssgStartGrandmaster } from '../../actions/serverActions';
import playLikeGrandmasterDialogActions from '../../constants/playLikeGrandmasterDialogActionTypes';
import Pgn from '../../utils/Pgn';
Expand Down
2 changes: 1 addition & 1 deletion src/components/Dialog/RematchAcceptDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
DialogActions,
DialogContent,
DialogTitle,
} from "@material-ui/core";
} from "@mui/material";
import Wording from "../../utils/Wording.js";
import { useDispatch, useSelector } from "react-redux";
import { wsMssgRematch, wsMssgRestart } from "../../actions/serverActions";
Expand Down
Loading

0 comments on commit a02c4de

Please sign in to comment.