feat(*): Enable sliding filters bar for smaller viewports

This commit is contained in:
Josh Creek
2024-07-15 19:18:37 +01:00
parent 7b5a948910
commit d3b7e7f5a9
+58 -44
View File
@@ -27,6 +27,7 @@
let showOrigins = true;
let showForms = true;
let drawerOpen = false;
function toggleOrigins() {
showOrigins = !showOrigins;
@@ -152,19 +153,67 @@
{#if !localUser}
<p>Please <a href="/signin" class="underline text-primary hover:text-secondary">sign in</a></p>
{:else}
<div class="flex">
<aside class="w-64 bg-gray-800 text-white p-4 fixed h-5/6">
<div class="drawer lg:drawer-open">
<input id="my-drawer" type="checkbox" class="drawer-toggle" bind:checked={drawerOpen} />
<div class="drawer-content flex flex-col items-center justify-center md:ml-64">
<label
for="my-drawer"
class="btn btn-secondary drawer-button lg:hidden fixed -left-10 top-1/2 -rotate-90"
>
{drawerOpen ? 'Close Filters' : 'Open Filters'}
</label>
<main class="flex-1 p-4 w-full">
<div class="max-w-min mx-auto">
{#if combinedData && combinedData.length > 0}
{#each combinedData as { pokedexEntry, catchRecord }}
<PokedexEntryCatchRecord
{pokedexEntry}
{showOrigins}
{showForms}
bind:catchRecord
on:updateCatch={updateACatch}
/>
{/each}
{:else if failedToLoad}
{#if creatingRecords && totalRecordsCreated > 0}
<p>Processed {totalRecordsCreated} Pokédex entries so far...</p>
<p>Please be patient, this may take some time.</p>
{:else if creatingRecords}
<p>Processing...</p>
<p>Please be patient, this may take some time.</p>
{:else}
<h1>Failed to load</h1>
<p>
If you're seeing this, you probably haven't created your Pokédex data yet. Please do
so by clicking this button.
</p>
<button class="btn" on:click={createCatchRecords}>Create Pokédex data</button>
{/if}
{:else}
<div class="min-w-max mx-auto">
<h1>Loading Pokédex</h1>
<span class="loading loading-spinner loading-xl"></span>
</div>
{/if}
</div>
</main>
</div>
<div class="drawer-side lg:relative">
<label for="my-drawer" class="drawer-overlay lg:hidden"></label>
<aside
class="menu bg-gray-800 text-white min-h-full w-64 p-4 lg:fixed xs:top-0 lg:left-0 h-full lg:h-5/6"
>
<h2 class="text-2xl font-semibold mb-4">Filters</h2>
<ul>
<li class="mb-2">
<button class="block p-2 hover:bg-gray-700 rounded" on:click={() => toggleForms()}
>Toggle Forms (Currently {showForms ? 'On' : 'Off'})</button
>
<button class="block p-2 hover:bg-gray-700 rounded" on:click={() => toggleForms()}>
Toggle Forms (Currently {showForms ? 'On' : 'Off'})
</button>
</li>
<li class="mb-2">
<button class="block p-2 hover:bg-gray-700 rounded" on:click={() => toggleOrigins()}
>Toggle Origins (Currently {showOrigins ? 'On' : 'Off'})</button
>
<button class="block p-2 hover:bg-gray-700 rounded" on:click={() => toggleOrigins()}>
Toggle Origins (Currently {showOrigins ? 'On' : 'Off'})
</button>
</li>
</ul>
<div class="mb-4">
@@ -246,41 +295,6 @@
<Pagination bind:currentPage bind:itemsPerPage bind:totalPages />
</div>
</aside>
<main class="flex-1 p-4 ml-64">
<div class="max-w-min mx-auto">
{#if combinedData && combinedData.length > 0}
{#each combinedData as { pokedexEntry, catchRecord }}
<PokedexEntryCatchRecord
{pokedexEntry}
{showOrigins}
{showForms}
bind:catchRecord
on:updateCatch={updateACatch}
/>
{/each}
{:else if failedToLoad}
{#if creatingRecords && totalRecordsCreated > 0}
<p>Processed {totalRecordsCreated} Pokédex entries so far...</p>
<p>Please be patient, this may take some time.</p>
{:else if creatingRecords}
<p>Processing...</p>
<p>Please be patient, this may take some time.</p>
{:else}
<h1>Failed to load</h1>
<p>
If you're seeing this, you probably haven't created your Pokédex data yet. Please do
so by clicking this button.
</p>
<button class="btn" on:click={createCatchRecords}>Create Pokédex data</button>
{/if}
{:else}
<div class="min-w-max mx-auto">
<h1>Loading Pokédex</h1>
<span class="loading loading-spinner loading-xl"></span>
</div>
{/if}
</div>
</main>
</div>
</div>
{/if}