Files
web/packages/design-system/lib/components/Table/ScrollWrapper/index.tsx
Matilda Landström fe376c63f7 Merged in feat/SW-2847-table (pull request #2665)
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
2025-08-20 09:41:54 +00:00

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>
)
}