aboutsummaryrefslogtreecommitdiffstats
path: root/packages/web/components/ui/scroll-area.tsx
diff options
context:
space:
mode:
authorMohamedBassem <me@mbassem.com>2024-03-01 18:00:58 +0000
committerMohamedBassem <me@mbassem.com>2024-03-01 18:00:58 +0000
commit75d315dda4232ee3b89abf054f0b6ee10105ffe3 (patch)
treef0796a136578f3b5aa82b4b3313e54fa3061ff5f /packages/web/components/ui/scroll-area.tsx
parent588471d65039e6920751ac2add8874ee932bc2f1 (diff)
downloadkarakeep-75d315dda4232ee3b89abf054f0b6ee10105ffe3.tar.zst
feature: Add support for creating and updating lists
Diffstat (limited to 'packages/web/components/ui/scroll-area.tsx')
-rw-r--r--packages/web/components/ui/scroll-area.tsx48
1 files changed, 48 insertions, 0 deletions
diff --git a/packages/web/components/ui/scroll-area.tsx b/packages/web/components/ui/scroll-area.tsx
new file mode 100644
index 00000000..32cb6022
--- /dev/null
+++ b/packages/web/components/ui/scroll-area.tsx
@@ -0,0 +1,48 @@
+"use client";
+
+import * as React from "react";
+import * as ScrollAreaPrimitive from "@radix-ui/react-scroll-area";
+
+import { cn } from "@/lib/utils";
+
+const ScrollArea = React.forwardRef<
+ React.ElementRef<typeof ScrollAreaPrimitive.Root>,
+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root>
+>(({ className, children, ...props }, ref) => (
+ <ScrollAreaPrimitive.Root
+ ref={ref}
+ className={cn("relative overflow-hidden", className)}
+ {...props}
+ >
+ <ScrollAreaPrimitive.Viewport className="size-full rounded-[inherit]">
+ {children}
+ </ScrollAreaPrimitive.Viewport>
+ <ScrollBar />
+ <ScrollAreaPrimitive.Corner />
+ </ScrollAreaPrimitive.Root>
+));
+ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
+
+const ScrollBar = React.forwardRef<
+ React.ElementRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>,
+ React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.ScrollAreaScrollbar>
+>(({ className, orientation = "vertical", ...props }, ref) => (
+ <ScrollAreaPrimitive.ScrollAreaScrollbar
+ ref={ref}
+ orientation={orientation}
+ className={cn(
+ "flex touch-none select-none transition-colors",
+ orientation === "vertical" &&
+ "h-full w-2.5 border-l border-l-transparent p-[1px]",
+ orientation === "horizontal" &&
+ "h-2.5 flex-col border-t border-t-transparent p-[1px]",
+ className,
+ )}
+ {...props}
+ >
+ <ScrollAreaPrimitive.ScrollAreaThumb className="bg-border relative flex-1 rounded-full" />
+ </ScrollAreaPrimitive.ScrollAreaScrollbar>
+));
+ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
+
+export { ScrollArea, ScrollBar };