diff --git a/src/lib/components/GuessesTable.svelte b/src/lib/components/GuessesTable.svelte index d0fffb4..3038617 100644 --- a/src/lib/components/GuessesTable.svelte +++ b/src/lib/components/GuessesTable.svelte @@ -15,77 +15,124 @@ $props(); let hasGuesses = $derived(guesses.length > 0); + + function getBoxColor(isCorrect: boolean, isAdjacent?: boolean): string { + if (isCorrect) return "bg-green-500 border-green-600"; + if (isAdjacent) return "bg-yellow-500 border-yellow-600"; + return "bg-red-500 border-red-600"; + } + + function getBoxContent( + guess: Guess, + column: "book" | "testament" | "section", + ): string { + switch (column) { + case "book": + return guess.book.name; + case "testament": + return ( + guess.book.testament.charAt(0).toUpperCase() + + guess.book.testament.slice(1).toLowerCase() + ); + case "section": + return guess.book.section; + } + } {#if hasGuesses} -
| Book | + +Testament | + + +Section | -
|---|---|---|
| - {guess.book.id === correctBookId ? "✅" : "❌"} - {guess.book.name} - | -- {guess.testamentMatch ? "✅" : "❌"} - {guess.book.testament.charAt(0).toUpperCase() + - guess.book.testament.slice(1).toLowerCase()} - | -- {guess.sectionMatch ? "✅" : "❌"} - {guess.adjacent ? "‼️ " : ""}{guess.book.section} - | -