Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 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 40 41 42 43 44 45 46 47 48 49 50 51 | 1x 70x 70x 70x 70x 70x 70x 70x 70x 70x | import { StackProps } from "@mui/material";
import { Stack, styled } from "@mui/material";
import { checkoutScrollbarStyles } from "@sections/PayBuilder/Checkout/helpers";
import { useLayoutEffect, useRef, useState } from "react";
const ScrollableContent = ({ children, sx, ...rest }: StackProps) => {
const [scrollbarWidth, setScrollbarWidth] = useState(0);
const ref = useRef<HTMLDivElement | null>(null);
useLayoutEffect(() => {
const el = ref.current;
Iif (!el) return;
const width = el.offsetWidth - el.clientWidth;
setScrollbarWidth(width);
}, [children]);
return (
<Content
ref={ref}
sx={{
paddingRight: `calc(40px - ${scrollbarWidth}px)`,
...sx,
}}
{...rest}
>
{children}
</Content>
);
};
export default ScrollableContent;
export const Content = styled(Stack)(({ theme }) => ({
maxHeight: "38vh",
overflowY: "auto",
msOverflowStyle: "none",
paddingLeft: "40px",
gap: "12px",
...checkoutScrollbarStyles,
"&::-webkit-scrollbar": {
width: "8px",
backgroundColor: "transparent",
},
[theme.breakpoints.down("md")]: {
height: "100%",
maxHeight: "100%",
overflowY: "hidden",
},
}));
|