Skip to content

Commit

Permalink
make scoreboard its own component
Browse files Browse the repository at this point in the history
  • Loading branch information
mattgrunwald committed Nov 7, 2024
1 parent d44a2dc commit 63b479d
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 52 deletions.
37 changes: 0 additions & 37 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -47,40 +47,3 @@ div#game {
aspect-ratio: 1 / 1;
padding: 0.5rem;
}

.scoreboard-container {
display: flex;
justify-content: center;
width: 100%;
padding-top: 0.5rem;
}

.scoreboard {
display: block;
padding: 0 0.5rem;
width: var(--scoreboard-width);
}

.scoreboard .row {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}

.scoreboard p {
margin: 0;
}

.summary h1 {
margin-top: 0;
margin-bottom: 1rem;
}

.summary p {
margin-bottom: 0.5rem;
}

.summary button {
margin-top: 1rem;
}
17 changes: 2 additions & 15 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Header } from './components/Header';
import { InfoDialog } from './components/InfoDialog';
import { PicketSign } from './components/PicketSign';
import { ResultsDialog } from './components/ResultsDialog';
import { Scoreboard } from './components/Scoreboard';
import { Game, NewGame } from './game';

function App() {
Expand Down Expand Up @@ -72,21 +73,7 @@ function App() {
))}
</div>
</div>
<div className="scoreboard-container">
<div className="scoreboard">
<p className="time">
<strong>Time spent:</strong> {duration}
</p>
<div className="row">
<p className="attempts">
<strong>Picket signs flipped:</strong> {game.getAttempts()}
</p>
<p className="score">
<strong>Matches:</strong> {game.getScore()}
</p>
</div>
</div>
</div>
<Scoreboard game={game} duration={duration} />
{showDialog && (
<ResultsDialog
game={game}
Expand Down
23 changes: 23 additions & 0 deletions src/components/Scoreboard/Scoreboard.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
.scoreboard-container {
display: flex;
justify-content: center;
width: 100%;
padding-top: 0.5rem;
}

.scoreboard {
display: block;
padding: 0 0.5rem;
width: var(--scoreboard-width);
}

.scoreboard .row {
width: 100%;
display: flex;
flex-direction: row;
justify-content: space-between;
}

.scoreboard p {
margin: 0;
}
26 changes: 26 additions & 0 deletions src/components/Scoreboard/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
import { Game } from '../../game';
import './Scoreboard.css';

export const Scoreboard = ({
duration,
game
}: {
duration: string;
game: Game;
}) => (
<div className="scoreboard-container">
<div className="scoreboard">
<p className="time">
<strong>Time spent:</strong> {duration}
</p>
<div className="row">
<p className="attempts">
<strong>Picket signs flipped:</strong> {game.getAttempts()}
</p>
<p className="score">
<strong>Matches:</strong> {game.getScore()}
</p>
</div>
</div>
</div>
);

0 comments on commit 63b479d

Please sign in to comment.