Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 253
Feat: Bulk Deletion#485
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Uh oh!
There was an error while loading. Please reload this page.
Feat: Bulk Deletion #485
Changes from all commits
263e32892af191d0693ad382b4738d8d69068f8fe7d5e26cac8b604887a4ef3File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading. Please reload this page.
Jump to
Uh oh!
There was an error while loading. Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,37 @@ | ||
| <script lang="ts"> | ||
| import { portal } from '$lib/actions/portal'; | ||
| import { fly } from 'svelte/transition'; | ||
| export let show = false; | ||
| </script> | ||
| {#if show} | ||
| <div class="floating-action-bar" transition:fly|local={{ y: '6rem' }} use:portal> | ||
| <slot /> | ||
| </div> | ||
| {/if} | ||
| <style lang="scss"> | ||
| .floating-action-bar { | ||
| position: fixed; | ||
| bottom: 2rem; | ||
| left: 50%; | ||
| transform: translateX(-50%); | ||
| z-index: 100; | ||
| border-radius: 0.5rem; | ||
| padding: 0.75rem 1rem; | ||
| } | ||
| :global(.theme-dark) .floating-action-bar { | ||
| border: 1px solid hsl(var(--color-neutral-200)); | ||
| background: hsl(var(--color-neutral-300)); | ||
| box-shadow: 0px 6px 16px 8px #14141f; | ||
| } | ||
| :global(.theme-light) .floating-action-bar { | ||
| border: 1px solid hsl(var(--color-neutral-30)); | ||
| background: hsl(var(--color-neutral-0)); | ||
| box-shadow: 0px 6px 16px 0px rgba(55, 59, 77, 0.14); | ||
| } | ||
| </style> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| <script lang="ts"> | ||
| import { toggle } from '$lib/helpers/array'; | ||
| import { isHTMLInputElement } from '$lib/helpers/types'; | ||
| import { TableCell } from '.'; | ||
| import { InputCheckbox } from '../forms'; | ||
| export let id: string; | ||
| export let selectedIds: string[] = []; | ||
| </script> | ||
| <TableCell> | ||
| <InputCheckbox | ||
| id="select-{id}" | ||
| value={selectedIds.includes(id)} | ||
| on:click={(e) => { | ||
| // Prevent the link from being followed | ||
| e.preventDefault(); | ||
| const el = e.currentTarget; | ||
| if (!isHTMLInputElement(el)) return; | ||
| selectedIds = toggle(selectedIds, id); | ||
| // Hack to make sure the checkbox is checked, independent of the | ||
| // preventDefault() call above | ||
| window.setTimeout(() => { | ||
| el.checked = selectedIds.includes(id); | ||
| }); | ||
| }} /> | ||
| </TableCell> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| <script lang="ts"> | ||
| import { isHTMLInputElement } from '$lib/helpers/types'; | ||
| import { TableCellHead } from '.'; | ||
| import { InputCheckbox } from '../forms'; | ||
| export let selected: string[] = []; | ||
| export let pageItemsIds: string[] = []; | ||
| function handleClick(e: MouseEvent) { | ||
| if (!isHTMLInputElement(e.target)) return; | ||
| if (e.target.checked) { | ||
| const set = new Set(selected); | ||
| pageItemsIds.forEach((id) => set.add(id)); | ||
| selected = Array.from(set); | ||
| } else { | ||
| selected = selected.filter((id) => { | ||
| return !pageItemsIds.includes(id); | ||
| }); | ||
| } | ||
| } | ||
| $: someSelected = pageItemsIds.some((id) => selected.includes(id)); | ||
| $: allSelected = pageItemsIds.every((id) => selected.includes(id)); | ||
| </script> | ||
| <TableCellHead width={10}> | ||
| <InputCheckbox | ||
| id="select-all" | ||
| indeterminate={someSelected && !allSelected} | ||
| value={allSelected} | ||
| on:click={handleClick} /> | ||
| </TableCellHead> |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -2,6 +2,7 @@ | ||
| import type { Action } from 'svelte/action'; | ||
| export let isSticky = false; | ||
| export let noMargin = false; | ||
Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. any reason we use ContributorAuthor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While I do agree, this is something that's present console wise. If we change it here, we would have to change it everywhere, which is fine by me, but I'd like to run it by Torsten. Also, if we do change it, I'd argue for hasMargin instead of just margin. Margin sounds like I'm going to pass in a numeric value Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yea sounds fair 👍 if this pattern is already being followed we can delay this decision for later. | ||
| let isOverflowing = false; | ||
| const hasOverflow: Action<HTMLDivElement> = (node) => { | ||
| @@ -37,8 +38,8 @@ | ||
| }; | ||
| </script> | ||
| <div class="table-with-scroll u-margin-block-start-32" data-private> | ||
| <div class="table-wrapper" use:hasOverflow> | ||
| <div class="table-with-scroll {noMargin ? '' : 'u-margin-block-start-32'}" data-private> | ||
| <div class="table-wrapper" use:hasOverflow={(v) => (isOverflowing = v)}> | ||
| <table class="table" class:is-sticky-scroll={isSticky && isOverflowing}> | ||
| <slot /> | ||
| </table> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,16 @@ | ||
| import type { Writable } from 'svelte/store'; | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| export type DeepKeys<T extends Record<string, any>> = { | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| [K in keyof T]: T[K] extends Record<string, any> ? `${K}.${DeepKeys<T[K]>}` : K; | ||
| }[keyof T]; | ||
| export type WritableValue<T> = T extends Writable<infer U> ? U : never; | ||
| export function isHTMLElement(el: unknown): el is HTMLElement { | ||
| return el instanceof HTMLElement; | ||
| } | ||
| export function isHTMLInputElement(el: unknown): el is HTMLInputElement { | ||
| return el instanceof HTMLInputElement; | ||
| } |
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't
on:clickhave a handler ?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nope, this forwards the event in case you need it