|
9 | 9 | } from 'react-icons/fa'; |
10 | 10 |
|
11 | 11 | const MAX_TOSSES = 3; |
12 | | -const LEADERBOARD_KEY = 'cosmic-toss-leaderboard'; |
| 12 | +const LEADERBOARD_KEY = 'comet-toss-leaderboard'; |
13 | 13 |
|
14 | 14 | const scoringZones = [ |
15 | 15 | { label: 'Low Earth Orbit', icon: 'earth', points: 1 }, |
@@ -57,6 +57,14 @@ function App() { |
57 | 57 | setScore(score + zone.points); |
58 | 58 | } |
59 | 59 |
|
| 60 | + function removeToss(indexToRemove) { |
| 61 | + const tossToRemove = tosses[indexToRemove]; |
| 62 | + if (!tossToRemove) return; |
| 63 | + |
| 64 | + setTosses(tosses.filter((_, index) => index !== indexToRemove)); |
| 65 | + setScore(score - tossToRemove.points); |
| 66 | + } |
| 67 | + |
60 | 68 | function submitScore() { |
61 | 69 | if (!canSubmit) return; |
62 | 70 |
|
@@ -97,13 +105,13 @@ function App() { |
97 | 105 | <section className="game-panel" aria-labelledby="game-title"> |
98 | 106 | <div className="brand-bar"> |
99 | 107 | <span>Hack at UCI</span> |
100 | | - <span>Cosmic Toss Station</span> |
| 108 | + <span>Comet Toss Station</span> |
101 | 109 | </div> |
102 | 110 |
|
103 | 111 | <div className="title-block"> |
104 | 112 | <h1 id="game-title"> |
105 | 113 | <FaRocket className="title-icon" /> |
106 | | - Cosmic Toss |
| 114 | + Comet Toss |
107 | 115 | </h1> |
108 | 116 | </div> |
109 | 117 |
|
@@ -160,8 +168,17 @@ function App() { |
160 | 168 | <div className="toss-slot" key={index}> |
161 | 169 | {tosses[index] ? ( |
162 | 170 | <> |
163 | | - <ZoneIcon name={tosses[index].icon} /> |
164 | | - {tosses[index].points} |
| 171 | + <span className="toss-result"> |
| 172 | + <ZoneIcon name={tosses[index].icon} /> |
| 173 | + {tosses[index].points} |
| 174 | + </span> |
| 175 | + <button |
| 176 | + className="remove-toss" |
| 177 | + onClick={() => removeToss(index)} |
| 178 | + aria-label={`Remove toss ${index + 1}`} |
| 179 | + > |
| 180 | + <FaTimesCircle /> |
| 181 | + </button> |
165 | 182 | </> |
166 | 183 | ) : ( |
167 | 184 | `Toss ${index + 1}` |
|
0 commit comments