-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Moved the replay page into a popup and added a button on the Navbar t…
…o open it
- Loading branch information
Showing
6 changed files
with
119 additions
and
4 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
.replay-button { | ||
text-transform: uppercase; | ||
color: var(--primary); | ||
height: max-content; | ||
border-radius: 4rem; | ||
padding: 0.2rem 0.3rem; | ||
margin-left: 0.5rem; | ||
|
||
font-size: 0.5rem; | ||
font-weight: 600; | ||
cursor: pointer; | ||
} | ||
|
||
#stopped { | ||
background-color: rgb(181, 0, 0); | ||
} | ||
|
||
#playing { | ||
background-color: rgb(0, 132, 0); | ||
} | ||
|
||
.replay-popup { | ||
background-color: var(--primary); | ||
padding: 1rem; | ||
border-style: solid; | ||
border-radius: 0.25rem; | ||
width: 20rem; | ||
} | ||
.replay-popup-titlebar { | ||
display: flex; | ||
justify-content: space-between; | ||
align-items: center; | ||
} | ||
|
||
.replay-popup-titlebar button { | ||
font-size: 1rem; | ||
background-color: var(--primary); | ||
color: var(--secondary); | ||
cursor: pointer; | ||
} | ||
|
||
.replay-popup-titlebar button:hover { | ||
background-color: #3d3d3d; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import { useState } from 'react'; | ||
import { useKey } from "../../hooks/useKey"; | ||
import Popup from "reactjs-popup" | ||
import ReplayItem from "./ReplayItem"; | ||
import "./ReplayPopup.css"; | ||
|
||
export default function ReplayPopup({status, websocketRef}) { | ||
console.log(status) | ||
// Setup list of replays | ||
let replays = <></>; | ||
if(status.mission_list != undefined) { | ||
replays = status.mission_list.map((mission) => ( | ||
<ReplayItem name={mission.name} key={mission.key} websocketRef={websocketRef} /> | ||
)); | ||
} | ||
// Check if we are currently playing the replay and set the button color accordingly | ||
let buttonState = status.status == 1 ? 'playing' : 'stopped'; | ||
|
||
// Get the status icon for the replay status | ||
let buttonText = "Replay "; | ||
if (status.status == 1) { | ||
// Playing | ||
buttonText += "\u23F5"; | ||
} else { | ||
// Stopped / Finished / No Replay Loaded | ||
buttonText += "\u23F9"; | ||
} | ||
|
||
// Setup open state to have keybind | ||
const [open, setOpen] = useState(false); | ||
useKey("KeyR", "shift", () => {setOpen(!open)}); | ||
return ( | ||
<div> | ||
<p className="replay-button" id={buttonState} onClick={() => {setOpen(!open)}}>{buttonText}</p> | ||
<Popup open={open} position="center center" modal> | ||
<div className="replay-popup"> | ||
<div className="replay-popup-titlebar"> | ||
<h2>Replays</h2> | ||
<button onClick={() => {setOpen(!open)}}>×</button> | ||
</div> | ||
<hr /> | ||
<div className="replay-popup-replaylist"> | ||
{replays} | ||
</div> | ||
</div> | ||
</Popup> | ||
</div> | ||
); | ||
} |