added discord link and shrunk guessesgrid for more than three guesses

This commit is contained in:
George Powell
2026-03-19 10:53:57 -04:00
parent b6b41b6ba9
commit 67d9757f98
3 changed files with 198 additions and 21 deletions

View File

@@ -5,9 +5,12 @@
let {
guesses,
correctBookId,
}: { guesses: Guess[]; correctBookId: string } = $props();
isWon = false,
}: { guesses: Guess[]; correctBookId: string; isWon?: boolean } = $props();
let hasGuesses = $derived(guesses.length > 0);
let showMinimized = $derived(isWon && guesses.length > 3);
let expanded = $state(false);
function getBoxColor(isCorrect: boolean, isAdjacent?: boolean): string {
if (isCorrect) return "bg-green-500 border-green-600";
@@ -104,31 +107,35 @@
</div>
</div>
{#each guesses as guess, rowIndex (guess.book.id)}
{#if showMinimized && !expanded}
<!-- Minimized view: first guess, divider, last two guesses -->
<!-- First guess (no animation since post-win) -->
{@const firstGuess = guesses[0]}
<div class="flex gap-2 justify-center">
<!-- Testament Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.testamentMatch,
firstGuess.testamentMatch,
)}"
style="animation-delay: {rowIndex * 1000 + 0 * 500}ms"
style="animation: none; opacity: 1; transform: none;"
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "testament")}</span
>{getBoxContent(firstGuess, "testament")}</span
>
</div>
<!-- Section Column -->
<div
class="relative w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.sectionMatch,
guess.adjacent,
firstGuess.sectionMatch,
firstGuess.adjacent,
)}"
style="animation-delay: {rowIndex * 1000 + 1 * 500}ms"
style="animation: none; opacity: 1; transform: none;"
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "section")}
{#if guess.adjacent}
>{getBoxContent(firstGuess, "section")}
{#if firstGuess.adjacent}
‼️
{/if}
</span>
@@ -137,29 +144,173 @@
<!-- First Letter Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.firstLetterMatch,
firstGuess.firstLetterMatch,
)}"
style="animation-delay: {rowIndex * 1000 + 2 * 500}ms"
style="animation: none; opacity: 1; transform: none;"
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "firstLetter")}</span
>{getBoxContent(firstGuess, "firstLetter")}</span
>
</div>
<!-- Book Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-4 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-lg animate-flip-in"
style="animation-delay: {rowIndex * 1000 +
3 * 500}ms; {getBookBoxStyle(guess)}"
style="animation: none; opacity: 1; transform: none; {getBookBoxStyle(firstGuess)}"
>
<span class="text-center leading-tight px-1 text-shadow-lg"
>{getBoxContent(guess, "book")}</span
>{getBoxContent(firstGuess, "book")}</span
>
</div>
</div>
{/each}
<!-- Expand/collapse divider -->
<button
type="button"
class="w-full flex items-center gap-3 py-1 cursor-pointer group"
onclick={() => (expanded = true)}
>
<div class="flex-1 h-px bg-gray-300 dark:bg-gray-600 group-hover:bg-gray-400 dark:group-hover:bg-gray-500 transition-colors"></div>
<span class="text-xs font-medium text-gray-500 dark:text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-200 transition-colors whitespace-nowrap select-none">
expand guesses ▼
</span>
<div class="flex-1 h-px bg-gray-300 dark:bg-gray-600 group-hover:bg-gray-400 dark:group-hover:bg-gray-500 transition-colors"></div>
</button>
<!-- Last two guesses (no animation since post-win) -->
{#each guesses.slice(-2) as guess (guess.book.id)}
<div class="flex gap-2 justify-center">
<!-- Testament Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.testamentMatch,
)}"
style="animation: none; opacity: 1; transform: none;"
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "testament")}</span
>
</div>
<!-- Section Column -->
<div
class="relative w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.sectionMatch,
guess.adjacent,
)}"
style="animation: none; opacity: 1; transform: none;"
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "section")}
{#if guess.adjacent}
‼️
{/if}
</span>
</div>
<!-- First Letter Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.firstLetterMatch,
)}"
style="animation: none; opacity: 1; transform: none;"
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "firstLetter")}</span
>
</div>
<!-- Book Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-4 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-lg animate-flip-in"
style="animation: none; opacity: 1; transform: none; {getBookBoxStyle(guess)}"
>
<span class="text-center leading-tight px-1 text-shadow-lg"
>{getBoxContent(guess, "book")}</span
>
</div>
</div>
{/each}
{:else}
<!-- Full view: all guesses -->
{#each guesses as guess, rowIndex (guess.book.id)}
<div class="flex gap-2 justify-center">
<!-- Testament Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.testamentMatch,
)}"
style={showMinimized
? "animation: none; opacity: 1; transform: none;"
: `animation-delay: ${rowIndex * 1000 + 0 * 500}ms`}
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "testament")}</span
>
</div>
<!-- Section Column -->
<div
class="relative w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.sectionMatch,
guess.adjacent,
)}"
style={showMinimized
? "animation: none; opacity: 1; transform: none;"
: `animation-delay: ${rowIndex * 1000 + 1 * 500}ms`}
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "section")}
{#if guess.adjacent}
‼️
{/if}
</span>
</div>
<!-- First Letter Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-2 border-opacity-80 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-md animate-flip-in {getBoxColor(
guess.firstLetterMatch,
)}"
style={showMinimized
? "animation: none; opacity: 1; transform: none;"
: `animation-delay: ${rowIndex * 1000 + 2 * 500}ms`}
>
<span class="text-center leading-tight px-1 text-shadow-sm"
>{getBoxContent(guess, "firstLetter")}</span
>
</div>
<!-- Book Column -->
<div
class="w-1/4 shrink-0 h-16 sm:h-20 md:h-24 border-4 rounded-lg flex items-center justify-center text-white font-bold text-base sm:text-lg md:text-xl shadow-lg animate-flip-in"
style={showMinimized
? `animation: none; opacity: 1; transform: none; ${getBookBoxStyle(guess)}`
: `animation-delay: ${rowIndex * 1000 + 3 * 500}ms; ${getBookBoxStyle(guess)}`}
>
<span class="text-center leading-tight px-1 text-shadow-lg"
>{getBoxContent(guess, "book")}</span
>
</div>
</div>
{#if showMinimized && expanded && rowIndex === 0}
<!-- Collapse divider shown right below the final (correct) guess -->
<button
type="button"
class="w-full flex items-center gap-3 py-1 cursor-pointer group"
onclick={() => (expanded = false)}
>
<div class="flex-1 h-px bg-gray-300 dark:bg-gray-600 group-hover:bg-gray-400 dark:group-hover:bg-gray-500 transition-colors"></div>
<span class="text-xs font-medium text-gray-500 dark:text-gray-400 group-hover:text-gray-700 dark:group-hover:text-gray-200 transition-colors whitespace-nowrap select-none">
collapse guesses ▲
</span>
<div class="flex-1 h-px bg-gray-300 dark:bg-gray-600 group-hover:bg-gray-400 dark:group-hover:bg-gray-500 transition-colors"></div>
</button>
{/if}
{/each}
{/if}
</div>
<!-- </div> -->
{/if}
<style>

View File

@@ -334,7 +334,7 @@
<p class="signin-text">
Sign in to save your streak &amp; track your progress
</p>
<form method="POST" action="/auth/apple">
<form method="POST" action="/auth/apple" class="w-full">
<input type="hidden" name="anonymousId" value={anonymousId} />
<button
type="submit"
@@ -662,7 +662,8 @@
align-items: center;
justify-content: center;
gap: 0.5rem;
padding: 0.6rem 4rem;
padding: 0.6rem 1rem;
width: 100%;
margin-bottom: 0.6rem;
background: #000;
color: #fff;