mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-07-13 08:06:24 +08:00
7b173a68d5
fix AF-1934
69 lines
1.7 KiB
TypeScript
69 lines
1.7 KiB
TypeScript
import * as ScrollArea from '@radix-ui/react-scroll-area';
|
|
import clsx from 'clsx';
|
|
import type { RefAttributes } from 'react';
|
|
import { forwardRef } from 'react';
|
|
|
|
import * as styles from './index.css';
|
|
|
|
export const ScrollableRoot = forwardRef<
|
|
HTMLDivElement,
|
|
ScrollArea.ScrollAreaProps & RefAttributes<HTMLDivElement>
|
|
>(({ children, className, ...props }, ref) => {
|
|
return (
|
|
<ScrollArea.Root
|
|
{...props}
|
|
ref={ref}
|
|
className={clsx(className, styles.scrollableContainerRoot)}
|
|
>
|
|
{children}
|
|
</ScrollArea.Root>
|
|
);
|
|
});
|
|
|
|
ScrollableRoot.displayName = 'ScrollableRoot';
|
|
|
|
export const ScrollableViewport = forwardRef<
|
|
HTMLDivElement,
|
|
ScrollArea.ScrollAreaViewportProps & RefAttributes<HTMLDivElement>
|
|
>(({ children, className, ...props }, ref) => {
|
|
return (
|
|
<ScrollArea.Viewport
|
|
{...props}
|
|
ref={ref}
|
|
className={clsx(className, styles.scrollableViewport)}
|
|
>
|
|
{children}
|
|
</ScrollArea.Viewport>
|
|
);
|
|
});
|
|
|
|
ScrollableViewport.displayName = 'ScrollableViewport';
|
|
|
|
export const ScrollableScrollbar = forwardRef<
|
|
HTMLDivElement,
|
|
ScrollArea.ScrollAreaScrollbarProps & RefAttributes<HTMLDivElement>
|
|
>(({ children, className, ...props }, ref) => {
|
|
return (
|
|
<ScrollArea.Scrollbar
|
|
orientation="vertical"
|
|
{...props}
|
|
ref={ref}
|
|
className={clsx(
|
|
className,
|
|
BUILD_CONFIG.isMobileEdition ? styles.mobileScrollbar : styles.scrollbar
|
|
)}
|
|
>
|
|
<ScrollArea.Thumb className={styles.scrollbarThumb} />
|
|
{children}
|
|
</ScrollArea.Scrollbar>
|
|
);
|
|
});
|
|
|
|
ScrollableScrollbar.displayName = 'ScrollableScrollbar';
|
|
|
|
export const Scrollable = {
|
|
Root: ScrollableRoot,
|
|
Viewport: ScrollableViewport,
|
|
Scrollbar: ScrollableScrollbar,
|
|
};
|