Modern Docker Management, Designed for Everyone
Go composecontainer-managementcontainersdockerdocker-composedocker-managementgoself-hostedsveltekittypescriptweb-ui
<script lang="ts">
import type { WithoutChildren } from 'bits-ui';
import type { Component } from 'svelte';
import { Button, type Props } from '#lib/components/ui/button/index.js';
import { cn } from '#lib/utils.js';
import { getEmblaContext } from './context.js';
let {
ref = $bindable(null),
class: className,
variant = 'outline',
size = 'icon',
direction,
icon: Icon,
label,
...restProps
}: WithoutChildren<Props> & {
direction: 'previous' | 'next';
icon: Component;
label: string;
} = $props();
const emblaCtx = getEmblaContext();
const isNext = $derived(direction === 'next');
const canScroll = $derived(isNext ? emblaCtx.canScrollNext : emblaCtx.canScrollPrev);
const positionClass = $derived(
emblaCtx.orientation === 'horizontal'
? `${isNext ? '-end-12' : '-start-12'} top-1/2 -translate-y-1/2`
: `start-1/2 ${isNext ? '-bottom-12' : '-top-12'} -translate-x-1/2 rotate-90`
);
</script>
<Button
data-slot={`carousel-${direction}`}
{variant}
{size}
aria-disabled={!canScroll}
disabled={!canScroll}
class={cn('absolute size-8 touch-manipulation rounded-full', positionClass, className)}
onclick={isNext ? emblaCtx.scrollNext : emblaCtx.scrollPrev}
onkeydown={emblaCtx.handleKeyDown}
bind:ref
{...restProps}
>
<Icon class="size-4" />
<span class="sr-only">{label}</span>
</Button>