Add buttons to mainapp. Add css for mainapp

This commit is contained in:
Ceda EI 2019-03-30 00:16:33 +05:30
parent 7af8cb0e93
commit 78e217043b
3 changed files with 60 additions and 8 deletions

View File

@ -6,9 +6,28 @@ import Stats from "./stats";
export default (player) => { export default (player) => {
function MainApp(props) { function MainApp(props) {
const [ playerStats, setPlayerStats ] = useState(null); const [ playerStats, setPlayerStats ] = useState(null);
// Possible values of display
// main: The main display with stats, buttons for list/add
const [ display ] = useState("main");
const token = localStorage.getItem("token"); const token = localStorage.getItem("token");
if (playerStats === null) if (playerStats === null)
player.player(token).then((res) => setPlayerStats(res)); player.player(token).then((res) => setPlayerStats(res));
let body;
if (display === "main")
body = (<>
<Stats playerStats={playerStats} />
<div className="stats lists nes-container with-title is-dark">
<p className="title">Quests</p>
<button className="nes-btn is-primary">Add Quests</button>
<button className="nes-btn is-primary">List Quests</button>
</div>
<div className="stats lists nes-container with-title is-dark">
<p className="title">Side Quests</p>
<button className="nes-btn is-primary">Add Side Quests</button>
<button className="nes-btn is-primary">List Side Quests</button>
</div>
</>);
return ( return (
<div className="main"> <div className="main">
<header> <header>
@ -20,7 +39,7 @@ export default (player) => {
}}>Logout</button> }}>Logout</button>
</header> </header>
<div className="body"> <div className="body">
<Stats playerStats={playerStats} /> {body}
</div> </div>
</div> </div>
); );

View File

@ -2,11 +2,12 @@ import React from "react";
export default function Stats(props) { export default function Stats(props) {
if (props.playerStats === null) { if (props.playerStats === null) {
return <img src="./loader.svg"></img>; return <div className="loader"><img alt="loader" src="./loader.svg"></img></div>;
} else { } else {
const { xp, quests_completed, total_quests, side_quests_completed, total_side_quests } = props.playerStats; const { xp, quests_completed, total_quests, side_quests_completed, total_side_quests } = props.playerStats;
return ( return (
<div className="stats lists"> <div className="stats lists nes-container with-title is-dark">
<p className="title">Player Stats</p>
<ul className="nes-list is-circle"> <ul className="nes-list is-circle">
<li> XP: {xp} </li> <li> XP: {xp} </li>
<li> Quests: {quests_completed}/{total_quests} </li> <li> Quests: {quests_completed}/{total_quests} </li>

View File

@ -1,7 +1,7 @@
body { body {
margin: 0; margin: 0;
padding: 0; padding: 0;
background-color: #383838; background-color: #303030;
color: #FFF; color: #FFF;
font-family: "Press Start 2P"; font-family: "Press Start 2P";
} }
@ -34,16 +34,48 @@ body {
padding: 1em 3em; padding: 1em 3em;
display: flex; display: flex;
justify-content: space-between; justify-content: space-between;
background-color: #000;
h1 {
font-family: "Ubuntu";
}
} }
.body { .body {
padding: 1em; padding: 1em;
div {
margin: 1em 0;
box-sizing: border-box;
button {
width: 48%;
margin: 0 1%;
box-sizing: border-box;
}
}
} }
} }
.nes-list.is-circle li::before { .nes-list.is-circle li::before {
color: #FFF; color: #FFF;
} }
.loader {
width: 100%;
display: flex;
justify-content: center;
align-content: center;
}
.full_screen {
height: 100vh;
}
@media (max-width: 600px) {
.main {
header {
padding: 1em 1em;
}
.body {
div {
button {
width: 98%;
margin: 0.25em 1%;
}
}
}
}
}