Better game list style
This commit is contained in:
parent
db674430af
commit
dcde202bbb
4 changed files with 97 additions and 29 deletions
|
@ -55,7 +55,7 @@
|
||||||
"lint": "eslint src/",
|
"lint": "eslint src/",
|
||||||
"prettier": "prettier --write src/",
|
"prettier": "prettier --write src/",
|
||||||
"eject": "react-scripts eject",
|
"eject": "react-scripts eject",
|
||||||
"server": "nodemon --exec babel-node src/server/index.js ",
|
"server": "echo 'The server is now packaged in separate app. See https://github.com/jrmi/airboardgame-back'",
|
||||||
"i18n:scanner": "i18next-scanner --config i18next-scanner.config.js 'src/**/*.{js,jsx}'",
|
"i18n:scanner": "i18next-scanner --config i18next-scanner.config.js 'src/**/*.{js,jsx}'",
|
||||||
"cypress:open": "LANGUAGE=en cypress open",
|
"cypress:open": "LANGUAGE=en cypress open",
|
||||||
"cypress:run": "LANGUAGE=en cypress run",
|
"cypress:run": "LANGUAGE=en cypress run",
|
||||||
|
|
|
@ -1,12 +1,12 @@
|
||||||
body {
|
body {
|
||||||
max-width: 100vw;
|
/*max-width: 100vw;*/
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
background-color: #202b38;
|
background-color: #202b38;
|
||||||
}
|
}
|
||||||
|
|
||||||
#root {
|
#root {
|
||||||
width: 100vw;
|
/*width: 100vw;
|
||||||
height: 100vh;
|
height: 100vh;
|
||||||
overflow: hidden;
|
overflow: hidden;*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,12 @@ import AutoSave from "../components/AutoSave";
|
||||||
import ImageDropNPaste from "../components/ImageDropNPaste";
|
import ImageDropNPaste from "../components/ImageDropNPaste";
|
||||||
import { getComponent } from "../components/boardComponents";
|
import { getComponent } from "../components/boardComponents";
|
||||||
|
|
||||||
|
const StyledBoardView = styled.div`
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
overflow: hidden;
|
||||||
|
`;
|
||||||
|
|
||||||
const BoardContainer = styled.div`
|
const BoardContainer = styled.div`
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
|
@ -37,7 +43,7 @@ export const BoardView = ({ namespace, editMode = false }) => {
|
||||||
const [edit, setEdit] = React.useState(editMode);
|
const [edit, setEdit] = React.useState(editMode);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<StyledBoardView>
|
||||||
<NavBar
|
<NavBar
|
||||||
setMenuOpen={setMenuOpen}
|
setMenuOpen={setMenuOpen}
|
||||||
setShowHelpModal={setShowHelpModal}
|
setShowHelpModal={setShowHelpModal}
|
||||||
|
@ -78,7 +84,7 @@ export const BoardView = ({ namespace, editMode = false }) => {
|
||||||
/>
|
/>
|
||||||
</BoardContainer>
|
</BoardContainer>
|
||||||
</ImageDropNPaste>
|
</ImageDropNPaste>
|
||||||
</>
|
</StyledBoardView>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,51 @@ import { useTranslation } from "react-i18next";
|
||||||
import { IS_PRODUCTION } from "../utils/settings";
|
import { IS_PRODUCTION } from "../utils/settings";
|
||||||
import { getGames, deleteGame } from "../utils/api";
|
import { getGames, deleteGame } from "../utils/api";
|
||||||
|
|
||||||
|
import { confirmAlert } from "react-confirm-alert";
|
||||||
|
import "react-confirm-alert/src/react-confirm-alert.css";
|
||||||
|
|
||||||
|
import styled from "styled-components";
|
||||||
|
|
||||||
|
const GameView = styled.ul`
|
||||||
|
width: 50%;
|
||||||
|
margin: 0 auto;
|
||||||
|
position: relative;
|
||||||
|
& .new-game {
|
||||||
|
position: absolute;
|
||||||
|
top: 1em;
|
||||||
|
right: 2px;
|
||||||
|
}
|
||||||
|
& h1 {
|
||||||
|
color: hsl(210, 14%, 75%);
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
|
const GameList = styled.ul`
|
||||||
|
list-style: none;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
`;
|
||||||
|
|
||||||
|
const Game = styled.li`
|
||||||
|
width: 100%;
|
||||||
|
background-color: hsl(210, 26%, 19%);
|
||||||
|
color: hsl(210, 14%, 75%);
|
||||||
|
display: flex;
|
||||||
|
justify-content: space-between;
|
||||||
|
|
||||||
|
& .game-name {
|
||||||
|
margin: 0 1em;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .button {
|
||||||
|
margin: 0 2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
& .action {
|
||||||
|
padding: 0.6em 0;
|
||||||
|
}
|
||||||
|
`;
|
||||||
|
|
||||||
const GamesView = () => {
|
const GamesView = () => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const [gameList, setGameList] = React.useState([]);
|
const [gameList, setGameList] = React.useState([]);
|
||||||
|
@ -20,33 +65,50 @@ const GamesView = () => {
|
||||||
}, [t]);
|
}, [t]);
|
||||||
|
|
||||||
const handleRemove = (idToRemove) => async () => {
|
const handleRemove = (idToRemove) => async () => {
|
||||||
|
confirmAlert({
|
||||||
|
title: t("Confirmation"),
|
||||||
|
message: t("Do you really want to remove selected items ?"),
|
||||||
|
buttons: [
|
||||||
|
{
|
||||||
|
label: t("Yes"),
|
||||||
|
onClick: () => {
|
||||||
deleteGame(idToRemove);
|
deleteGame(idToRemove);
|
||||||
setGameList(gameList.filter(({ id }) => id !== idToRemove));
|
setGameList(gameList.filter(({ id }) => id !== idToRemove));
|
||||||
|
},
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: t("No"),
|
||||||
|
onClick: () => {},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<GameView>
|
||||||
<ul style={{ color: "#fff" }}>
|
<Link to={`/game/`} className="button new-game">
|
||||||
|
Create new game
|
||||||
|
</Link>
|
||||||
|
<h1>Game list</h1>
|
||||||
|
<GameList>
|
||||||
{gameList.map(({ name, id }) => (
|
{gameList.map(({ name, id }) => (
|
||||||
<li key={id}>
|
<Game key={id}>
|
||||||
{name}
|
<h2 className="game-name">{name}</h2>
|
||||||
<Link to={`/game/${id}/session/`} className="button">
|
<div className="action">
|
||||||
|
<Link to={`/game/${id}/session/`} className="button success">
|
||||||
play
|
play
|
||||||
</Link>
|
</Link>
|
||||||
<Link to={`/game/${id}/edit`} className="button">
|
<Link to={`/game/${id}/edit`} className="button">
|
||||||
edit
|
edit
|
||||||
</Link>
|
</Link>
|
||||||
<button onClick={handleRemove(id)} className="button">
|
<button onClick={handleRemove(id)} className="button error">
|
||||||
remove
|
X
|
||||||
</button>
|
</button>
|
||||||
</li>
|
</div>
|
||||||
|
</Game>
|
||||||
))}
|
))}
|
||||||
</ul>
|
</GameList>
|
||||||
|
</GameView>
|
||||||
<Link to={`/game/`} className="button">
|
|
||||||
New game
|
|
||||||
</Link>
|
|
||||||
</>
|
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue