Skip to content

Commit

Permalink
hover to open number link when guessed
Browse files Browse the repository at this point in the history
  • Loading branch information
ArhanChaudhary committed Aug 23, 2024
1 parent a9a85a9 commit c6a16dc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/routes/+page.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
modals = [
...modals,
{
value: guess.toString(),
value: guess,
message: 'You have already guessed this number.',
guessType: GuessType.technicallyIncorrect
}
Expand Down Expand Up @@ -114,7 +114,14 @@
];
number.guessed = true;
guesses++;
numbersEl.querySelector(`span[data-value="${number.value}"]`)!.classList.add('bg-green-300');
let numberEl = numbersEl.querySelector(`[data-value="${number.value}"]`)!;
let a = document.createElement('a');
a.href = number.link;
a.textContent = guess;
a.classList.add('bg-green-300', 'hover:bg-green-500');
a.setAttribute('target', '_blank');
a.setAttribute('rel', 'noopener noreferrer');
numberEl.replaceWith(a);
if (data.numbers.every(({ guessed }) => guessed)) {
let endTime = performance.now();
let deltaString = deltaToString((endTime - startTime) / 1000);
Expand Down

0 comments on commit c6a16dc

Please sign in to comment.