Skip to content

Commit 2041952

Browse files
committed
Use RadioGroup for ImageDiff mode selector
1 parent da265cc commit 2041952

File tree

1 file changed

+12
-13
lines changed

1 file changed

+12
-13
lines changed

web/src/lib/components/diff/ImageDiff.svelte

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<script lang="ts">
2-
import { Slider } from "bits-ui";
2+
import { RadioGroup, Slider } from "bits-ui";
33
import Spinner from "$lib/components/Spinner.svelte";
44
import { getDimensions, type ImageDimensions } from "$lib/image";
55
import AddedOrRemovedImageLabel from "$lib/components/diff/AddedOrRemovedImageLabel.svelte";
@@ -55,22 +55,21 @@
5555
});
5656
</script>
5757

58+
{#snippet modeButton(forMode: Mode, iconClass: string)}
59+
<RadioGroup.Item
60+
value={forMode}
61+
class="flex items-center justify-center rounded-sm btn-ghost px-2 py-1 text-primary data-[state=checked]:btn-ghost-visible"
62+
>
63+
<span class="iconify {iconClass} me-1 size-4" aria-hidden="true"></span>{forMode}
64+
</RadioGroup.Item>
65+
{/snippet}
66+
5867
{#snippet modeSelector()}
59-
{#snippet modeButton(forMode: Mode, iconClass: string)}
60-
<button
61-
type="button"
62-
class="flex items-center justify-center rounded-sm btn-ghost px-2 py-1 text-primary data-[active=true]:btn-ghost-visible"
63-
onclick={() => (mode = forMode)}
64-
data-active={mode === forMode}
65-
>
66-
<span class="iconify {iconClass} me-1 size-4" aria-hidden="true"></span>{forMode}
67-
</button>
68-
{/snippet}
69-
<div class="mb-4 flex flex-row gap-1 rounded-lg bg-neutral p-1.5 shadow-sm">
68+
<RadioGroup.Root title="Comparison Mode" bind:value={mode} class="mb-4 flex flex-row gap-1 rounded-lg bg-neutral p-1.5 shadow-sm">
7069
{@render modeButton("slide", "octicon--image-16")}
7170
{@render modeButton("side-by-side", "octicon--columns-16")}
7271
{@render modeButton("fade", "octicon--image-16")}
73-
</div>
72+
</RadioGroup.Root>
7473
{/snippet}
7574

7675
{#snippet sideBySide(dims: DimensionData)}

0 commit comments

Comments
 (0)