From 9ad4dfded1d8d24ce18524913acacabad7c411f6 Mon Sep 17 00:00:00 2001 From: Josh Patra <30350506+SoPat712@users.noreply.github.com> Date: Sun, 20 Apr 2025 01:14:54 -0400 Subject: [PATCH] Add winning message, fix dropdown not disappearing --- src/lib/HeardleGame.svelte | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/src/lib/HeardleGame.svelte b/src/lib/HeardleGame.svelte index f8ac3c3..ffe8d07 100644 --- a/src/lib/HeardleGame.svelte +++ b/src/lib/HeardleGame.svelte @@ -309,7 +309,8 @@ if (selectedTrack.title.toLowerCase() === ans) { attemptInfos = [...attemptInfos, { status: 'correct', title: currentTrack.title }]; gameOver = true; - message = `✅ Correct! It was “${currentTrack.title}.”`; + // include try count in winning message + message = `✅ Correct! It was “${currentTrack.title}.” You got it in ${attemptCount} ${attemptCount === 1 ? 'try' : 'tries'}.`; widget.pause(); } else { attemptInfos = [...attemptInfos, { status: 'wrong', title: selectedTrack.title }]; @@ -345,10 +346,11 @@ window.scrollTo({ top: 0, behavior: 'smooth' }); } - // update suggestions reactively - $: suggestions = userInput - ? tracks.filter((t) => t.title.toLowerCase().includes(userInput.toLowerCase())).slice(0, 5) - : []; + // update suggestions reactively, but hide once a track is selected + $: suggestions = + userInput && !selectedTrack + ? tracks.filter((t) => t.title.toLowerCase().includes(userInput.toLowerCase())).slice(0, 5) + : []; @@ -482,6 +484,8 @@
{message}
{/if}