The best way to control Claude Code, Codex and more from any computer or phone
Mirrored from https://github.com/Camo67/t3code.git
Synced Nov 21, 04:45 UTC
| 1 | import { ScrollArea as ScrollAreaPrimitive } from "@base-ui/react/scroll-area"; |
| 2 | |
| 3 | import { cn } from "~/lib/utils"; |
| 4 | |
| 5 | function getVirtualizedScrollFadeClassName({ top, bottom }: { top: boolean; bottom: boolean }) { |
| 6 | if (!top && !bottom) return undefined; |
| 7 | |
| 8 | return cn( |
| 9 | "virtualized-scroll-fade [--fade-size:1.5rem]", |
| 10 | top && |
| 11 | bottom && |
| 12 | "[--virtualized-scroll-fade-mask:linear-gradient(to_bottom,transparent,black_var(--fade-size),black_calc(100%-var(--fade-size)),transparent)]", |
| 13 | top && |
| 14 | !bottom && |
| 15 | "[--virtualized-scroll-fade-mask:linear-gradient(to_bottom,transparent,black_var(--fade-size))]", |
| 16 | !top && |
| 17 | bottom && |
| 18 | "[--virtualized-scroll-fade-mask:linear-gradient(to_bottom,black_calc(100%-var(--fade-size)),transparent)]", |
| 19 | ); |
| 20 | } |
| 21 | |
| 22 | function ScrollArea({ |
| 23 | className, |
| 24 | children, |
| 25 | scrollFade = false, |
| 26 | scrollFadePadding = true, |
| 27 | scrollbarGutter = false, |
| 28 | hideScrollbars = false, |
| 29 | chainVerticalScroll = false, |
| 30 | radius = "inherit", |
| 31 | viewportTabIndex, |
| 32 | ...props |
| 33 | }: ScrollAreaPrimitive.Root.Props & { |
| 34 | scrollFade?: boolean; |
| 35 | scrollFadePadding?: boolean; |
| 36 | scrollbarGutter?: boolean; |
| 37 | hideScrollbars?: boolean; |
| 38 | chainVerticalScroll?: boolean; |
| 39 | radius?: "inherit" | "none"; |
| 40 | viewportTabIndex?: number; |
| 41 | }) { |
| 42 | return ( |
| 43 | <ScrollAreaPrimitive.Root |
| 44 | className={cn( |
| 45 | "relative size-full min-h-0 overflow-hidden", |
| 46 | radius === "none" ? "rounded-none" : "rounded-[inherit]", |
| 47 | className, |
| 48 | )} |
| 49 | {...props} |
| 50 | > |
| 51 | <ScrollAreaPrimitive.Viewport |
| 52 | {...(viewportTabIndex === undefined ? {} : { tabIndex: viewportTabIndex })} |
| 53 | className={cn( |
| 54 | "h-full max-h-[inherit] overflow-auto overscroll-contain rounded-[inherit] outline-none transition-shadow focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring focus-visible:ring-offset-1 focus-visible:ring-offset-background data-has-overflow-x:overscroll-x-contain", |
| 55 | chainVerticalScroll && "overscroll-y-auto", |
| 56 | scrollFade && |
| 57 | "mask-t-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-start)))] mask-b-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-y-end)))] mask-l-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-start)))] mask-r-from-[calc(100%-min(var(--fade-size),var(--scroll-area-overflow-x-end)))] focus-visible:mask-none [--fade-size:1.5rem]", |
| 58 | scrollFade && scrollFadePadding && "scroll-p-[var(--fade-size)]", |
| 59 | scrollFade && !scrollFadePadding && "has-focus-visible:mask-none", |
| 60 | scrollbarGutter && "scrollbar-gutter-stable", |
| 61 | hideScrollbars && |
| 62 | "[-ms-overflow-style:none] [scrollbar-width:none] [&::-webkit-scrollbar]:hidden", |
| 63 | )} |
| 64 | data-slot="scroll-area-viewport" |
| 65 | > |
| 66 | {children} |
| 67 | </ScrollAreaPrimitive.Viewport> |
| 68 | {!hideScrollbars && ( |
| 69 | <> |
| 70 | <ScrollBar orientation="vertical" /> |
| 71 | <ScrollBar orientation="horizontal" /> |
| 72 | <ScrollAreaPrimitive.Corner data-slot="scroll-area-corner" /> |
| 73 | </> |
| 74 | )} |
| 75 | </ScrollAreaPrimitive.Root> |
| 76 | ); |
| 77 | } |
| 78 | |
| 79 | function ScrollBar({ |
| 80 | className, |
| 81 | orientation = "vertical", |
| 82 | ...props |
| 83 | }: ScrollAreaPrimitive.Scrollbar.Props) { |
| 84 | return ( |
| 85 | <ScrollAreaPrimitive.Scrollbar |
| 86 | className={cn( |
| 87 | "flex opacity-0 transition-opacity delay-300 data-[orientation=horizontal]:mx-1 data-[orientation=horizontal]:mb-px data-[orientation=horizontal]:h-1.5 data-[orientation=vertical]:my-1 data-[orientation=vertical]:mr-px data-[orientation=vertical]:w-1.5 data-[orientation=horizontal]:flex-col data-hovering:opacity-100 data-scrolling:opacity-100 data-hovering:delay-0 data-scrolling:delay-0 data-hovering:duration-100 data-scrolling:duration-100", |
| 88 | className, |
| 89 | )} |
| 90 | data-slot="scroll-area-scrollbar" |
| 91 | orientation={orientation} |
| 92 | {...props} |
| 93 | > |
| 94 | <ScrollAreaPrimitive.Thumb |
| 95 | className="relative flex-1 rounded-full bg-[var(--app-scrollbar-thumb)] transition-colors hover:bg-[var(--app-scrollbar-thumb-hover)]" |
| 96 | data-slot="scroll-area-thumb" |
| 97 | /> |
| 98 | </ScrollAreaPrimitive.Scrollbar> |
| 99 | ); |
| 100 | } |
| 101 | |
| 102 | export { getVirtualizedScrollFadeClassName, ScrollArea, ScrollBar }; |