-
Notifications
You must be signed in to change notification settings - Fork 380
Expand file tree
/
Copy pathScrollContainer.tsx
More file actions
39 lines (34 loc) · 1.05 KB
/
ScrollContainer.tsx
File metadata and controls
39 lines (34 loc) · 1.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
import React from 'react'
import { cn } from '@sqlmesh-common/utils'
import type { LayoutDirection } from '@sqlmesh-common/types'
import './ScrollContainer.css'
export interface ScrollContainerProps
extends React.HTMLAttributes<HTMLDivElement> {
direction?: LayoutDirection
}
export const ScrollContainer = React.forwardRef<
HTMLDivElement,
ScrollContainerProps
>(({ children, className, direction = 'vertical', ...props }, ref) => {
const vertical = direction === 'vertical' || direction === 'both'
const horizontal = direction === 'horizontal' || direction === 'both'
return (
<div
ref={ref}
{...props}
data-component="ScrollContainer"
className={cn(
'w-full h-full',
vertical ? 'overflow-y-scroll scrollbar-w-[6px]' : 'overflow-y-hidden',
horizontal
? 'overflow-x-scroll scrollbar-h-[6px]'
: 'overflow-x-hidden',
className,
'scrollbar scrollbar-thumb-rounded-full',
)}
>
{children}
</div>
)
})
ScrollContainer.displayName = 'ScrollContainer'