Skip to content

Commit

Permalink
scrollable output
Browse files Browse the repository at this point in the history
  • Loading branch information
justind000 committed Jul 6, 2024
1 parent 46ff2dd commit 2b888bc
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 3 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions src/lib/components/ui/scroll-area/index.ts
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 src/lib/components/ui/scroll-area/scroll-area-scrollbar.svelte
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>
32 changes: 32 additions & 0 deletions src/lib/components/ui/scroll-area/scroll-area.svelte
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>
5 changes: 4 additions & 1 deletion src/routes/+layout.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@
import { CircuitBoard } from 'lucide-svelte';
import { ModeWatcher } from 'mode-watcher';
import { platform } from '@tauri-apps/api/os';
import { ScrollArea } from "$lib/components/ui/scroll-area/index.js";
import '../app.css';
const sidebarNavItems = [
Expand Down Expand Up @@ -274,6 +275,7 @@
<Sheet.Root>
<Sheet.Trigger disabled={$make_disabled}><Button class="w-full" on:click={make_files} disabled={$make_disabled}>Make</Button></Sheet.Trigger>
<Sheet.Content side="bottom">
<ScrollArea class="h-[400px] overflow-scroll overscroll-auto">
<Sheet.Header>
<Sheet.Title>Output</Sheet.Title>
<Sheet.Description>
Expand All @@ -283,6 +285,7 @@
</div>
</Sheet.Description>
</Sheet.Header>
</ScrollArea>
</Sheet.Content>
</Sheet.Root>
</nav>
Expand Down

0 comments on commit 2b888bc

Please sign in to comment.