Skip to content

Commit d8a8975

Browse files
committed
pause toggle colors
1 parent 06c254a commit d8a8975

3 files changed

Lines changed: 21 additions & 10 deletions

File tree

src/lib/components/utils/MultiPauseToggle.svelte

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,9 @@
11
<script lang="ts">
2-
import { Asterisk, Pause, Play } from '@lucide/svelte';
2+
import { Asterisk, LoaderCircle, Pause, Play } from '@lucide/svelte';
33
import { shockersV1Api } from '$lib/api';
44
import type { BooleanLegacyDataResponse } from '$lib/api/internal/v1';
55
import { Button } from '$lib/components/ui/button';
66
import { toast } from 'svelte-sonner';
7-
import LoadingCircle from '../svg/LoadingCircle.svelte';
8-
import { onMount } from 'svelte';
9-
107
interface Props {
118
shockers: PauseToggleProps[];
129
onPausedChange: (paused: boolean) => void;
@@ -32,7 +29,8 @@
3229
});
3330
3431
35-
function handleClick() {
32+
function handleClick(e: MouseEvent) {
33+
e.stopPropagation();
3634
if(requestInProgress) return;
3735
requestInProgress = true;
3836
@@ -78,9 +76,9 @@
7876
7977
</script>
8078

81-
<Button disabled={requestInProgress} onclick={handleClick}>
79+
<Button disabled={requestInProgress} onclick={handleClick} class="size-9" variant={pausedBooleans() === 'allTrue' ? 'destructive' : 'default'}>
8280
{#if requestInProgress}
83-
<LoadingCircle />
81+
<LoaderCircle class="animate-spin" />
8482
{:else if pausedBooleans() === "allTrue"}
8583
<Play />
8684
{:else if pausedBooleans() === "allFalse"}

src/lib/components/utils/PauseToggle.svelte

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { Pause, Play } from '@lucide/svelte';
2+
import { LoaderCircle, Pause, Play } from '@lucide/svelte';
33
import { shockersV1Api } from '$lib/api';
44
import type { BooleanLegacyDataResponse } from '$lib/api/internal/v1';
55
import { Button } from '$lib/components/ui/button';
@@ -44,9 +44,9 @@
4444
}
4545
</script>
4646

47-
<Button onclick={handleClick}>
47+
<Button onclick={handleClick} disabled={requestInProgress} class="size-9" variant={paused ? 'destructive' : 'default'}>
4848
{#if requestInProgress}
49-
<LoadingCircle />
49+
<LoaderCircle class="animate-spin" />
5050
{:else if paused}
5151
<Play />
5252
{:else}

src/routes/(authenticated)/shares/user/UserShareItem.svelte

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,19 @@
336336
</Tooltip.Content>
337337
</Tooltip.Root>
338338
</Table.Cell>
339+
<Table.Cell>
340+
<MultiPauseToggle
341+
shockers={shares.map((share) => ({
342+
shockerId: share.id,
343+
paused: share.paused,
344+
userShareUserId: userShare.id,
345+
}))}
346+
onPausedChange={(paused) => {
347+
shares.forEach((share) => (share.paused = paused)); // Update the local copy of the shares
348+
userShare.shares.forEach((share) => (share.paused = paused)); // Update the actual lists shares
349+
}}
350+
/>
351+
</Table.Cell>
339352
</Table.Row>
340353

341354
<style>

0 commit comments

Comments
 (0)