feat: add sticky table header

This commit is contained in:
Xyphyn committed 2023-08-22 18:56:17 -07:00
1 parent 114856a052
commit 12b1329364
3 files changed
+99 -33

No files matched your search

+49 -23
View File
@@ -1,39 +1,65 @@
<script lang="ts">
import Card from '$lib/components/ui/Card.svelte'
import { ExclamationTriangle, Icon } from 'svelte-hero-icons'
import ModlogItem from './ModlogItem.svelte'
import Pageination from '$lib/components/ui/Pageination.svelte'
import { searchParam } from '$lib/util.js'
import { page } from '$app/stores'
export let data
</script>
<svelte:head>
<title>Modlog</title>
</svelte:head>
<div class="flex flex-col gap-4">
<h1 class="font-bold text-2xl">Modlog</h1>
{#if data.modlog}
<table class="table border-collapse">
<colgroup>
<col />
<col />
<col />
<col />
<col />
</colgroup>
<thead class="text-left">
<tr>
<th>Action</th>
<th>Moderator</th>
<th>Moderatee</th>
<th>Community</th>
<th>Link</th>
</tr>
</thead>
{#each data.modlog as modlog}
<ModlogItem item={modlog} />
{/each}
</table>
<div class="">
<table
class="table overflow-x-auto table-fixed relative"
style="width: 100%;"
>
<colgroup class="table-fixed">
<col width="20%" />
<col width="30%" />
<col width="25%" class="overflow-x-auto" />
<col width="30%" />
<col width="30%" />
<col width="40%" />
<col width="50%" />
<col width="30%" />
</colgroup>
<thead class="text-left sticky top-16">
<tr class="sticky top-16 rounded-t-lg overflow-hidden">
<th>Time</th>
<th>Moderator</th>
<th>Action</th>
<th>User</th>
<th>Community</th>
<th>Content</th>
<th>Reason</th>
<th>Link</th>
</tr>
</thead>
<tbody class="text-xs">
{#each data.modlog as modlog}
<ModlogItem item={modlog} />
{/each}
</tbody>
</table>
</div>
{/if}
<Pageination
page={data.page}
on:change={(e) => searchParam($page.url, 'page', e.detail.toString())}
/>
</div>
<style lang="postcss">
:global(.table thead tr th) {
@apply border border-slate-200 dark:border-zinc-800 px-4 py-2;
@apply border border-slate-200 dark:border-zinc-800 px-4 py-2 bg-slate-100;
}
:global(.table tr td) {
@@ -45,6 +71,6 @@
}
:global(.dark thead tr th) {
@apply border-zinc-800;
@apply border-zinc-800 bg-zinc-900;
}
</style>