Files
gpx.studio/website/src/lib/components/ui/scroll-area/scroll-area.svelte

35 lines
1.2 KiB
Svelte
Raw Normal View History

2024-04-14 14:53:57 +02:00
<script lang="ts">
2024-10-14 19:00:05 +02:00
import { ScrollArea as ScrollAreaPrimitive } from 'bits-ui';
import { Scrollbar } from './index.js';
import { cn } from '$lib/utils.js';
2024-04-14 14:53:57 +02:00
type $$Props = ScrollAreaPrimitive.Props & {
2024-10-14 19:00:05 +02:00
orientation?: 'vertical' | 'horizontal' | 'both';
2024-04-14 14:53:57 +02:00
scrollbarXClasses?: string;
scrollbarYClasses?: string;
2024-10-14 19:00:05 +02:00
viewportClasses?: string;
2024-04-14 14:53:57 +02:00
};
2024-10-14 19:00:05 +02:00
let className: $$Props['class'] = undefined;
2024-04-14 14:53:57 +02:00
export { className as class };
2024-10-14 19:00:05 +02:00
export let orientation = 'vertical';
export let scrollbarXClasses: string = '';
export let scrollbarYClasses: string = '';
export let viewportClasses: string = '';
2024-04-14 14:53:57 +02:00
</script>
2024-10-14 19:00:05 +02:00
<ScrollAreaPrimitive.Root {...$$restProps} class={cn('relative overflow-hidden', className)}>
<ScrollAreaPrimitive.Viewport class={cn('h-full w-full rounded-[inherit]', viewportClasses)}>
2024-04-14 14:53:57 +02:00
<ScrollAreaPrimitive.Content>
<slot />
</ScrollAreaPrimitive.Content>
</ScrollAreaPrimitive.Viewport>
2024-10-14 19:00:05 +02:00
{#if orientation === 'vertical' || orientation === 'both'}
2024-04-14 14:53:57 +02:00
<Scrollbar orientation="vertical" class={scrollbarYClasses} />
{/if}
2024-10-14 19:00:05 +02:00
{#if orientation === 'horizontal' || orientation === 'both'}
2024-04-14 14:53:57 +02:00
<Scrollbar orientation="horizontal" class={scrollbarXClasses} />
{/if}
<ScrollAreaPrimitive.Corner />
</ScrollAreaPrimitive.Root>