Files
supabase/apps/studio/components/ui/DataTable/DataTableHeaderLayout.tsx
Joshen Lim 7f5865872a Enforce noUnusedLocals and noUnusedParameters in tsconfig.json + fix all related issues (#45264)
## Context

Enforce `noUnusedLocals` and `noUnusedParameters` in tsconfig.json + fix
all related issues
2026-04-27 17:42:34 +08:00

36 lines
902 B
TypeScript

import { forwardRef, PropsWithChildren, useEffect, useRef } from 'react'
import { cn } from 'ui'
export const DataTableHeaderLayout = forwardRef<
HTMLDivElement,
PropsWithChildren<{
setTopBarHeight: (height: number) => void
}>
>(({ setTopBarHeight, ...props }, _ref) => {
const topBarRef = useRef<HTMLDivElement>(null)
useEffect(() => {
const observer = new ResizeObserver(() => {
const rect = topBarRef.current?.getBoundingClientRect()
if (rect) {
setTopBarHeight(rect.height)
}
})
const topBar = topBarRef.current
if (!topBar) return
observer.observe(topBar)
return () => observer.unobserve(topBar)
}, [topBarRef])
return (
<div
ref={topBarRef}
className={cn('flex flex-col gap-4 bg-background p-2', 'top-0 z-10 pb-4')}
{...props}
/>
)
})
DataTableHeaderLayout.displayName = 'DataTableHeaderLayout'