Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Display ranges after selecting speaker points #9

Merged
merged 1 commit into from
Nov 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/App.css
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,23 @@ ul {
padding: 10px;
text-align: center;
}

.score-range {
display: flex;
gap: 10px;
justify-content: center;
align-items: center;
}

.score-range span {
padding: 10px;
}

.score-range .neighbouring-score {
color: var(--decorative-color);
}

.score-range .selected-score {
font-size: 1.5em;
font-weight: bold;
}
37 changes: 21 additions & 16 deletions src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ import "./App.css";
import BracketDescription from "./components/BracketDescription";
import Footer from "./components/Footer";
import ScaleSelection from "./components/ScaleSelection";
import Score from "./components/Score";
import ScoreRange from "./components/ScoreRange";
import ScoreSelection from "./components/ScoreSelection";
import { useBinarySearch } from "./hooks/useBinarySearch";
import { isSpeakerBracket } from "./utils";
Expand Down Expand Up @@ -116,24 +118,27 @@ function App() {
</div>
)}

{phase === "done" &&
selectedBracketIndex !== null &&
exactScore !== null && (
<div>
<p>
You have selected a score of <strong>{exactScore}</strong>.
</p>
<BracketDescription
description={currentScale[selectedBracketIndex].description}
{phase === "done" && selectedBracketIndex !== null && (
<div>
<p>You have selected a score of...</p>
{isSpeakerBracket(currentScale[selectedBracketIndex]) ? (
<ScoreRange
bracket={currentScale[selectedBracketIndex]}
exactScore={exactScore}
/>
<div className="button-container">
<button type="reset" onClick={reset}>
Start Over
</button>
</div>
) : (
<Score bracket={currentScale[selectedBracketIndex]} />
)}
<BracketDescription
description={currentScale[selectedBracketIndex].description}
/>
<div className="button-container">
<button type="reset" onClick={reset}>
Start Over
</button>
</div>
)}

</div>
)}
<div>
<div className="button-container">
<button type="button" onClick={toggleShowScale}>
Expand Down
19 changes: 19 additions & 0 deletions src/components/Score.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import type React from "react";
import type { JudgeBracket } from "../types";

interface ScoreProps {
bracket: JudgeBracket;
}

const Score: React.FC<ScoreProps> = ({ bracket }) => {
const score = bracket.score;
return (
<div className="score-range">
<span key={score} className="selected-score">
{score}
</span>
</div>
);
};

export default Score;
31 changes: 31 additions & 0 deletions src/components/ScoreRange.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import type React from "react";
import type { SpeakerBracket } from "../types";

interface ScoreRangeProps {
bracket: SpeakerBracket;
exactScore: number | null;
}

const ScoreRange: React.FC<ScoreRangeProps> = ({ bracket, exactScore }) => {
const scores = Array.from(
{ length: bracket.maxScore - bracket.minScore + 1 },
(_, i) => bracket.minScore + i,
);

return (
<div className="score-range">
{scores.map((score) => (
<span
key={score}
className={
score === exactScore ? "selected-score" : "neighbouring-score"
}
>
{score}
</span>
))}
</div>
);
};

export default ScoreRange;
6 changes: 6 additions & 0 deletions src/index.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
color-scheme: light dark;
color: rgba(255, 255, 255, 0.87);
background-color: #242424;
--decorative-color: rgba(255, 255, 255, 0.6);

font-synthesis: none;
text-rendering: optimizeLegibility;
Expand Down Expand Up @@ -57,6 +58,7 @@ button:focus-visible {
:root {
color: #213547;
background-color: #ffffff;
--decorative-color: rgba(0, 0, 0, 0.5);
}
a:hover {
color: #747bff;
Expand All @@ -66,3 +68,7 @@ button:focus-visible {
color: #213547;
}
}

.footer {
color: var(--decorative-color);
}