feat(SW-441): Added table block component
This commit is contained in:
committed by
Pontus Dreij
parent
ef411b4cf9
commit
dfd40aa7aa
35
components/TempDesignSystem/ScrollWrapper/index.tsx
Normal file
35
components/TempDesignSystem/ScrollWrapper/index.tsx
Normal file
@@ -0,0 +1,35 @@
|
||||
"use client"
|
||||
|
||||
import { useMemo } from "react"
|
||||
|
||||
import useScrollShadows from "@/hooks/useScrollShadows"
|
||||
|
||||
import { ScrollWrapperProps } from "./scrollWrapper"
|
||||
|
||||
import styles from "./scrollWrapper.module.css"
|
||||
|
||||
export default function ScrollWrapper({
|
||||
className,
|
||||
children,
|
||||
}: ScrollWrapperProps) {
|
||||
const { containerRef, showLeftShadow, showRightShadow } = useScrollShadows()
|
||||
|
||||
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>
|
||||
)
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
.scrollWrapper {
|
||||
position: relative;
|
||||
overflow: hidden;
|
||||
}
|
||||
|
||||
.scrollWrapper::before,
|
||||
.scrollWrapper::after {
|
||||
content: "";
|
||||
position: absolute;
|
||||
top: 0;
|
||||
height: 100%;
|
||||
pointer-events: none;
|
||||
z-index: 1;
|
||||
transition: opacity 0.2s ease;
|
||||
opacity: 0;
|
||||
width: 50px;
|
||||
}
|
||||
|
||||
.scrollWrapper.leftShadow::before {
|
||||
left: 0;
|
||||
background: linear-gradient(to right, rgba(0, 0, 0, 0.3), transparent);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.scrollWrapper.rightShadow::after {
|
||||
right: 0;
|
||||
background: linear-gradient(to left, rgba(0, 0, 0, 0.3), transparent);
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.content {
|
||||
overflow-x: auto;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
export interface ScrollWrapperProps
|
||||
extends React.PropsWithChildren<React.HTMLAttributes<HTMLDivElement>> {}
|
||||
Reference in New Issue
Block a user