fix(SW-2847): move ScrollWrapper to design system and Table component * fix(SW-2847): move ScrollWrapper to design system and Table component Approved-by: Erik Tiekstra
35 lines
856 B
TypeScript
35 lines
856 B
TypeScript
'use client'
|
|
|
|
import { useMemo } from 'react'
|
|
|
|
import styles from './scrollWrapper.module.css'
|
|
|
|
import useScrollShadows from '@scandic-hotels/common/hooks/useScrollShadows'
|
|
|
|
export default function ScrollWrapper({
|
|
className,
|
|
children,
|
|
}: React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>>) {
|
|
const { containerRef, showLeftShadow, showRightShadow } =
|
|
useScrollShadows<HTMLDivElement>()
|
|
|
|
const classNames = useMemo(() => {
|
|
const cls = [styles.scrollWrapper, className]
|
|
if (showLeftShadow) {
|
|
cls.push(styles.leftShadow)
|
|
}
|
|
if (showRightShadow) {
|
|
cls.push(styles.rightShadow)
|
|
}
|
|
return cls.join(' ')
|
|
}, [showLeftShadow, showRightShadow, className])
|
|
|
|
return (
|
|
<div className={classNames}>
|
|
<div className={styles.content} ref={containerRef}>
|
|
{children}
|
|
</div>
|
|
</div>
|
|
)
|
|
}
|