diff --git a/src/App.tsx b/src/App.tsx index 5a3c546..f0816d2 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -15,7 +15,7 @@ import { saveGameStateToLocalStorage, } from './lib/localStorage' -const ALERT_TIME_MS = 2000; +const ALERT_TIME_MS = 2000 function App() { const [currentGuess, setCurrentGuess] = useState('') @@ -50,16 +50,18 @@ function App() { useEffect(() => { if (isGameWon) { - setSuccessAlert(WIN_MESSAGES[Math.floor(Math.random()*WIN_MESSAGES.length)]); + setSuccessAlert( + WIN_MESSAGES[Math.floor(Math.random() * WIN_MESSAGES.length)] + ) setTimeout(() => { - setSuccessAlert(''); - setIsStatsModalOpen(true); - }, ALERT_TIME_MS); + setSuccessAlert('') + setIsStatsModalOpen(true) + }, ALERT_TIME_MS) } if (isGameLost) { setTimeout(() => { - setIsStatsModalOpen(true); - }, ALERT_TIME_MS); + setIsStatsModalOpen(true) + }, ALERT_TIME_MS) } }, [isGameWon, isGameLost]) @@ -74,7 +76,9 @@ function App() { } const onEnter = () => { - if (isGameWon || isGameLost) { return; } + if (isGameWon || isGameLost) { + return + } if (!(currentGuess.length === 5)) { setIsNotEnoughLetters(true) return setTimeout(() => { @@ -139,8 +143,8 @@ function App() { isGameLost={isGameLost} isGameWon={isGameWon} handleShare={() => { - setSuccessAlert("Game copied to clipboard"); - return setTimeout(() => setSuccessAlert(''), ALERT_TIME_MS); + setSuccessAlert('Game copied to clipboard') + return setTimeout(() => setSuccessAlert(''), ALERT_TIME_MS) }} /> - + diff --git a/src/components/modals/StatsModal.tsx b/src/components/modals/StatsModal.tsx index fb0c5af..770c6cc 100644 --- a/src/components/modals/StatsModal.tsx +++ b/src/components/modals/StatsModal.tsx @@ -1,4 +1,4 @@ -import Countdown from "react-countdown" +import Countdown from 'react-countdown' import { StatBar } from '../stats/StatBar' import { Histogram } from '../stats/Histogram' import { GameStats } from '../../lib/localStorage' @@ -16,7 +16,15 @@ type Props = { handleShare: () => void } -export const StatsModal = ({ isOpen, handleClose, guesses, gameStats, isGameLost, isGameWon, handleShare }: Props) => { +export const StatsModal = ({ + isOpen, + handleClose, + guesses, + gameStats, + isGameLost, + isGameWon, + handleShare, +}: Props) => { if (gameStats.totalGames <= 0) { return ( @@ -31,24 +39,28 @@ export const StatsModal = ({ isOpen, handleClose, guesses, gameStats, isGameLost Guess Distribution - {(isGameLost || isGameWon) && -
-
-
New word in
- -
- + {(isGameLost || isGameWon) && ( +
+
+
New word in
+
- } + +
+ )} ) } diff --git a/src/constants/strings.ts b/src/constants/strings.ts index 7414730..13411b6 100644 --- a/src/constants/strings.ts +++ b/src/constants/strings.ts @@ -1 +1 @@ -export const WIN_MESSAGES = ["Great Job!", "Awesome", "Well done!"]; +export const WIN_MESSAGES = ['Great Job!', 'Awesome', 'Well done!'] diff --git a/src/lib/share.ts b/src/lib/share.ts index 9d55706..7e7b6ee 100644 --- a/src/lib/share.ts +++ b/src/lib/share.ts @@ -3,7 +3,7 @@ import { solutionIndex } from './words' export const shareStatus = (guesses: string[], lost: boolean) => { navigator.clipboard.writeText( - `Not Wordle ${solutionIndex} ${lost?"X":guesses.length}/6\n\n` + + `Not Wordle ${solutionIndex} ${lost ? 'X' : guesses.length}/6\n\n` + generateEmojiGrid(guesses) ) } diff --git a/src/lib/words.ts b/src/lib/words.ts index ba8122b..140f0c9 100644 --- a/src/lib/words.ts +++ b/src/lib/words.ts @@ -18,7 +18,7 @@ export const getWordOfDay = () => { const now = Date.now() const msInDay = 86400000 const index = Math.floor((now - epochMs) / msInDay) - const nextday = (index+1)*msInDay + epochMs; + const nextday = (index + 1) * msInDay + epochMs return { solution: WORDS[index].toUpperCase(),