mirror of
https://github.com/OpenCut-app/OpenCut.git
synced 2026-07-13 21:52:53 +02:00
feat: replace scroll-area from radix with one that actually works and doesn't cause layout issues
This commit is contained in:
@@ -229,7 +229,7 @@
|
|||||||
|
|
||||||
@utility scrollbar-thin {
|
@utility scrollbar-thin {
|
||||||
&::-webkit-scrollbar {
|
&::-webkit-scrollbar {
|
||||||
width: 8px;
|
width: 6px;
|
||||||
height: 8px;
|
height: 8px;
|
||||||
}
|
}
|
||||||
&::-webkit-scrollbar-track {
|
&::-webkit-scrollbar-track {
|
||||||
|
|||||||
@@ -1,53 +1,18 @@
|
|||||||
"use client";
|
|
||||||
|
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { ScrollArea as ScrollAreaPrimitive } from "radix-ui";
|
import { cn } from "@/lib/utils";
|
||||||
|
|
||||||
import { cn } from "../../lib/utils";
|
|
||||||
|
|
||||||
const ScrollArea = React.forwardRef<
|
const ScrollArea = React.forwardRef<
|
||||||
React.ElementRef<typeof ScrollAreaPrimitive.Root>,
|
HTMLDivElement,
|
||||||
React.ComponentPropsWithoutRef<typeof ScrollAreaPrimitive.Root> & {
|
React.HTMLAttributes<HTMLDivElement>
|
||||||
type?: "auto" | "always" | "scroll" | "hover";
|
>(({ className, children, ...props }, ref) => (
|
||||||
showHorizontalScrollbar?: boolean;
|
<div
|
||||||
}
|
|
||||||
>(({ className, children, type, showHorizontalScrollbar, ...props }, ref) => (
|
|
||||||
<ScrollAreaPrimitive.Root
|
|
||||||
ref={ref}
|
ref={ref}
|
||||||
className={cn("relative overflow-hidden", className)}
|
className={cn("overflow-auto scrollbar-thin", className)}
|
||||||
type={type}
|
|
||||||
{...props}
|
{...props}
|
||||||
>
|
>
|
||||||
<ScrollAreaPrimitive.Viewport className="h-full w-full rounded-[inherit]">
|
{children}
|
||||||
{children}
|
</div>
|
||||||
</ScrollAreaPrimitive.Viewport>
|
|
||||||
<ScrollBar />
|
|
||||||
{showHorizontalScrollbar && <ScrollBar orientation="horizontal" />}
|
|
||||||
<ScrollAreaPrimitive.Corner />
|
|
||||||
</ScrollAreaPrimitive.Root>
|
|
||||||
));
|
));
|
||||||
ScrollArea.displayName = ScrollAreaPrimitive.Root.displayName;
|
ScrollArea.displayName = "ScrollArea";
|
||||||
|
|
||||||
const ScrollBar = React.forwardRef<
|
export { ScrollArea };
|
||||||
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-px",
|
|
||||||
orientation === "horizontal" &&
|
|
||||||
"h-2.5 flex-col border-t border-t-transparent p-px",
|
|
||||||
className
|
|
||||||
)}
|
|
||||||
{...props}
|
|
||||||
>
|
|
||||||
<ScrollAreaPrimitive.ScrollAreaThumb className="relative flex-1 rounded-full bg-border" />
|
|
||||||
</ScrollAreaPrimitive.ScrollAreaScrollbar>
|
|
||||||
));
|
|
||||||
ScrollBar.displayName = ScrollAreaPrimitive.ScrollAreaScrollbar.displayName;
|
|
||||||
|
|
||||||
export { ScrollArea, ScrollBar };
|
|
||||||
|
|||||||
Reference in New Issue
Block a user