diff options
Diffstat (limited to 'src/components/Result')
| -rw-r--r-- | src/components/Result/index.tsx | 40 |
1 files changed, 31 insertions, 9 deletions
diff --git a/src/components/Result/index.tsx b/src/components/Result/index.tsx index 19f9386..6b4560a 100644 --- a/src/components/Result/index.tsx +++ b/src/components/Result/index.tsx @@ -14,17 +14,19 @@ interface SolutionProps { didGuess: boolean; currentTry: number; todaysSolution: Song; + isUnlimited?: boolean; } function Solution({ didGuess, todaysSolution, currentTry, + isUnlimited, }: SolutionProps) { return ( <> <Styled.SongTitle> - Today's song is {todaysSolution.artist} - {todaysSolution.name} + {isUnlimited ? "The song was" : "Today's song is"} {todaysSolution.artist} - {todaysSolution.name} </Styled.SongTitle> {didGuess && ( @@ -86,6 +88,8 @@ interface Props { currentTry: number; todaysSolution: Song; guesses: GuessType[]; + mode?: "daily" | "unlimited"; + onPlayAgain?: () => void; } export function Result({ @@ -93,6 +97,8 @@ export function Result({ todaysSolution, guesses, currentTry, + mode = "daily", + onPlayAgain, }: Props) { const hoursToNextDay = Math.floor( (new Date(new Date().setHours(24, 0, 0, 0)).getTime() - @@ -102,6 +108,8 @@ export function Result({ 60 ); + const isUnlimited = mode === "unlimited"; + if (didGuess) { const textForTry = ["Perfect!", "Wow!", "Super!", "Congrats!", "Nice!"]; @@ -113,13 +121,20 @@ export function Result({ todaysSolution={todaysSolution} didGuess={didGuess} currentTry={currentTry} + isUnlimited={isUnlimited} /> - <ShareButton guesses={guesses} variant="green" /> + {!isUnlimited && <ShareButton guesses={guesses} variant="green" />} - <Styled.TimeToNext> - Remember to come back in {hoursToNextDay} hours! - </Styled.TimeToNext> + {isUnlimited && onPlayAgain ? ( + <Button variant="green" onClick={onPlayAgain}> + Play Again + </Button> + ) : ( + <Styled.TimeToNext> + Remember to come back in {hoursToNextDay} hours! + </Styled.TimeToNext> + )} </> ); } @@ -132,13 +147,20 @@ export function Result({ todaysSolution={todaysSolution} didGuess={didGuess} currentTry={currentTry} + isUnlimited={isUnlimited} /> - <ShareButton guesses={guesses} variant="red" /> + {!isUnlimited && <ShareButton guesses={guesses} variant="red" />} - <Styled.TimeToNext> - Try again in {hoursToNextDay} hours. - </Styled.TimeToNext> + {isUnlimited && onPlayAgain ? ( + <Button variant="red" onClick={onPlayAgain}> + Play Again + </Button> + ) : ( + <Styled.TimeToNext> + Try again in {hoursToNextDay} hours. + </Styled.TimeToNext> + )} </> ); } |
