1
0
Fork 0
mirror of synced 2024-09-30 09:07:25 +13:00

table sorting for datatable

This commit is contained in:
Martin McKeaveney 2020-07-29 13:11:29 +01:00
parent 7e80c1b4b9
commit d53afb175b
3 changed files with 27 additions and 4 deletions

View file

@ -1,6 +1,8 @@
<script>
import { onMount } from "svelte"
import { cssVars, createClasses } from "./cssVars"
import ArrowUp from "./icons/ArrowUp.svelte"
import ArrowDown from "./icons/ArrowDown.svelte"
import fsort from "fast-sort"
export let _bb
@ -80,10 +82,14 @@
<tr>
{#each headers as header}
<th on:click={() => sortColumn(header)}>
{header}
{#if sort.column === header}
{#if sort.direction === 'asc'}v{:else}^{/if}
{/if}
<span>
{header}
{#if sort.column === header}
<svelte:component
style="height: 1em;"
this={sort.direction === 'asc' ? ArrowUp : ArrowDown} />
{/if}
</span>
</th>
{/each}
</tr>
@ -119,6 +125,12 @@
color: var(--color);
font-weight: bold;
text-transform: capitalize;
cursor: pointer;
}
th span {
display: flex;
align-items: center;
}
td,

View file

@ -0,0 +1 @@
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" width="18" height="18"><path fill="none" d="M0 0h24v24H0z"/><path d="M13 16.172l5.364-5.364 1.414 1.414L12 20l-7.778-7.778 1.414-1.414L11 16.172V4h2v12.172z"/></svg>

After

Width:  |  Height:  |  Size: 225 B

View file

@ -0,0 +1,10 @@
<svg
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="18"
height="18">
<path fill="none" d="M0 0h24v24H0z" />
<path
d="M13 7.828V20h-2V7.828l-5.364 5.364-1.414-1.414L12 4l7.778 7.778-1.414
1.414L13 7.828z" />
</svg>

After

Width:  |  Height:  |  Size: 249 B