Files
calendar/packages/ui/components/scrollable/ScrollableArea.tsx
T
Keith WilliamsandGitHub 78d06c6d01 refactor: Move classNames from @calcom/lib to @calcom/ui (#19674)
* refactor: Move classNames from @calcom/lib to @calcom/ui

* Import fix

* Removed extra import of classNames

* Removed tailwind-merge from @calcom/lib
2025-03-03 15:54:33 +00:00

37 lines
1.0 KiB
TypeScript

"use client";
import type { PropsWithChildren } from "react";
import React, { useRef, useEffect, useState } from "react";
import classNames from "@calcom/ui/classNames";
const ScrollableArea = ({ children, className }: PropsWithChildren<{ className?: string }>) => {
const scrollableRef = useRef<HTMLDivElement>(null);
const [isOverflowingY, setIsOverflowingY] = useState(false);
useEffect(() => {
const scrollableElement = scrollableRef.current;
if (scrollableElement) {
const isElementOverflowing = scrollableElement.scrollHeight > scrollableElement.clientHeight;
console.log({ isElementOverflowing });
setIsOverflowingY(isElementOverflowing);
}
}, []);
return (
<div
ref={scrollableRef}
className={classNames(
"scroll-bar overflow-y-scroll ",
isOverflowingY && " relative ",
className // Pass in your max-w / max-h
)}>
{children}
{isOverflowingY && <div data-testid="overflow-indicator" />}
</div>
);
};
export { ScrollableArea };