Skip to content

Commit

Permalink
feat: ✨ style selected checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderl19 committed Mar 17, 2024
1 parent 78ee809 commit 83753c8
Showing 1 changed file with 34 additions and 19 deletions.
53 changes: 34 additions & 19 deletions src/routes/(nav)/contacts/[[selectedMember]]/Table.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
createColumnHelper,
} from "@tanstack/svelte-table";
import type { SortingState, RowSelectionState, TableOptions } from "@tanstack/svelte-table";
import { CheckSquare, Square } from "lucide-svelte";
import { Check } from "lucide-svelte";
import { getContext } from "svelte";
import { writable } from "svelte/store";
Expand Down Expand Up @@ -134,14 +134,14 @@
<tr>
<th class="padding-left">
<button
class="select"
class:is-selected={$table.getIsAllPageRowsSelected()}
on:click={() => {
$table.toggleAllPageRowsSelected();
}}
>
{#if $table.getIsAllPageRowsSelected()}
<CheckSquare />
{:else}
<Square />
<Check size={16} />
{/if}
</button>
</th>
Expand Down Expand Up @@ -178,19 +178,19 @@
<tbody>
{#each $table.getRowModel().rows.slice(0, 10) as row}
<tr class:selected={row.getIsSelected()}>
<th class="padding-left">
<td class="padding-left">
<button
class="select"
class:is-selected={row.getIsSelected()}
on:click={() => {
row.toggleSelected();
}}
>
{#if row.getIsSelected()}
<CheckSquare />
{:else}
<Square />
<Check size={16} />
{/if}
</button>
</th>
</td>
{#each row.getVisibleCells() as cell}
<td>
{#if cell.column.id === "notes"}
Expand All @@ -215,8 +215,31 @@
min-width: 100%;
border-spacing: 0;
tbody tr:hover {
background-color: var(--gray100);
.select {
all: unset;
border: 1px solid var(--gray600);
border-radius: 4px;
height: 16px;
width: 16px;
color: var(--background);
&.is-selected {
background-color: var(--gray600);
}
}
tbody tr {
&.selected {
background-color: var(--pink100);
&:hover {
background-color: var(--pink200);
}
}
&:hover {
background-color: var(--gray100);
}
}
th,
Expand Down Expand Up @@ -259,13 +282,5 @@
border-left: $border;
border-bottom: $border;
}
.selected {
background-color: var(--pink300);
&:hover {
background-color: var(--pink200);
}
}
}
</style>

0 comments on commit 83753c8

Please sign in to comment.