Skip to content

Commit 2605d07

Browse files
committed
#112 Add Select All and Deselect All in columns menu
1 parent d37f7f0 commit 2605d07

File tree

1 file changed

+35
-6
lines changed

1 file changed

+35
-6
lines changed
Lines changed: 35 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
<script lang="ts">
2+
import Fa from 'svelte-fa';
3+
import { faEye } from '@fortawesome/free-solid-svg-icons';
24
import { popup } from '@skeletonlabs/skeleton';
35
import type { PopupSettings } from '@skeletonlabs/skeleton';
46
@@ -8,26 +10,53 @@
810
const popupCombobox: PopupSettings = {
911
event: 'click',
1012
target: `${tableId}-columns-menu`,
11-
placement: 'bottom'
13+
placement: 'bottom',
14+
closeQuery: ''
15+
};
16+
17+
const selectAll = () => {
18+
columns = columns.map((column) => ({ ...column, visible: true }));
19+
};
20+
21+
const deselectAll = () => {
22+
columns = columns.map((column) => ({ ...column, visible: false }));
23+
columns[0].visible = true;
1224
};
1325
</script>
1426

1527
<button
1628
type="button"
17-
class="btn btn-sm variant-filled-primary rounded-full order-last"
29+
class="btn btn-sm variant-filled-primary rounded-full order-last gap-2"
1830
aria-label="Open menu to hide/show columns"
19-
use:popup={popupCombobox}>Columns</button
31+
use:popup={popupCombobox}><Fa icon={faEye} /> Columns</button
2032
>
21-
2233
<div
23-
class="bg-white dark:bg-surface-500 p-4 rounded-md shadow-md z-10"
34+
class="bg-white dark:bg-surface-500 p-4 px-5 rounded-md shadow-md z-10 border border-primary-500"
2435
data-popup="{tableId}-columns-menu"
2536
>
37+
<div class="flex items-center gap-4 pb-5 grow justify-between">
38+
<button
39+
on:click|preventDefault={selectAll}
40+
type="button"
41+
class="btn p-0 text-sm grow underline text-primary-500"
42+
>
43+
Select All
44+
</button>
45+
<div class="border border-r border-neutral-200 h-6" />
46+
<button
47+
on:click|preventDefault={deselectAll}
48+
type="button"
49+
class="btn p-0 text-sm grow underline text-neutral-500"
50+
>
51+
Deselect All
52+
</button>
53+
</div>
2654
{#each columns as column}
2755
<div class="flex gap-3 items-center">
2856
<input
2957
aria-label={`${column.visible ? 'Hide' : 'Show'} ${column.label} column`}
3058
type="checkbox"
59+
class="checkbox"
3160
bind:checked={column.visible}
3261
title={`${column.visible ? 'Hide' : 'Show'} ${column.label} column`}
3362
disabled={columns.filter((c) => c.visible).length === 1 && column.visible}
@@ -36,5 +65,5 @@
3665
</div>
3766
{/each}
3867

39-
<div class="arrow bg-white dark:bg-surface-500" />
68+
<div class="arrow bg-white dark:bg-surface-500 border-l border-t border-primary-500" />
4069
</div>

0 commit comments

Comments
 (0)