-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
46ff2dd
commit 2b888bc
Showing
5 changed files
with
75 additions
and
3 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Scrollbar from "./scroll-area-scrollbar.svelte"; | ||
import Root from "./scroll-area.svelte"; | ||
|
||
export { | ||
Root, | ||
Scrollbar, | ||
//, | ||
Root as ScrollArea, | ||
Scrollbar as ScrollAreaScrollbar, | ||
}; |
27 changes: 27 additions & 0 deletions
27
src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<script lang="ts"> | ||
import { ScrollArea as ScrollAreaPrimitive } from "bits-ui"; | ||
import { cn } from "$lib/utils.js"; | ||
type $$Props = ScrollAreaPrimitive.ScrollbarProps & { | ||
orientation?: "vertical" | "horizontal"; | ||
}; | ||
let className: $$Props["class"] = undefined; | ||
export let orientation: $$Props["orientation"] = "vertical"; | ||
export { className as class }; | ||
</script> | ||
|
||
<ScrollAreaPrimitive.Scrollbar | ||
{orientation} | ||
class={cn( | ||
"flex touch-none select-none transition-colors", | ||
orientation === "vertical" && "h-full w-2.5 border-l border-l-transparent p-px", | ||
orientation === "horizontal" && "h-2.5 w-full border-t border-t-transparent p-px", | ||
className | ||
)} | ||
> | ||
<slot /> | ||
<ScrollAreaPrimitive.Thumb | ||
class={cn("relative rounded-full bg-border", orientation === "vertical" && "flex-1")} | ||
/> | ||
</ScrollAreaPrimitive.Scrollbar> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<script lang="ts"> | ||
import { ScrollArea as ScrollAreaPrimitive } from "bits-ui"; | ||
import { Scrollbar } from "./index.js"; | ||
import { cn } from "$lib/utils.js"; | ||
type $$Props = ScrollAreaPrimitive.Props & { | ||
orientation?: "vertical" | "horizontal" | "both"; | ||
scrollbarXClasses?: string; | ||
scrollbarYClasses?: string; | ||
}; | ||
let className: $$Props["class"] = undefined; | ||
export { className as class }; | ||
export let orientation = "vertical"; | ||
export let scrollbarXClasses: string = ""; | ||
export let scrollbarYClasses: string = ""; | ||
</script> | ||
|
||
<ScrollAreaPrimitive.Root {...$$restProps} class={cn("relative overflow-hidden", className)}> | ||
<ScrollAreaPrimitive.Viewport class="h-full w-full rounded-[inherit]"> | ||
<ScrollAreaPrimitive.Content> | ||
<slot /> | ||
</ScrollAreaPrimitive.Content> | ||
</ScrollAreaPrimitive.Viewport> | ||
{#if orientation === "vertical" || orientation === "both"} | ||
<Scrollbar orientation="vertical" class={scrollbarYClasses} /> | ||
{/if} | ||
{#if orientation === "horizontal" || orientation === "both"} | ||
<Scrollbar orientation="horizontal" class={scrollbarXClasses} /> | ||
{/if} | ||
<ScrollAreaPrimitive.Corner /> | ||
</ScrollAreaPrimitive.Root> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters