Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

1023 B
Raw Blame
import { ReactNode } from 'react'

import { cn } from 'lib/utils/css-classes'

import { ColumnResizeHandle, ColumnResizeHandleProps } from './ColumnResizeHandle'

export interface TableHeaderCellProps {
    width: number
    align?: 'right'
    /** Omit on the last column, where there is nothing to the right to give or take space. */
    resize?: Omit<ColumnResizeHandleProps, 'width'>
    children: ReactNode
}

/** Header cell of a tracing virtualized table, with the resize grab bar on its right edge. */
export function TableHeaderCell({ width, align, resize, children }: TableHeaderCellProps): JSX.Element {
    return (
        <div
            className="relative flex h-full shrink-0 items-center"
            // eslint-disable-next-line react/forbid-dom-props
            style={{ width }}
        >
            <div className={cn('w-full truncate px-2 text-xs', align === 'right' && 'text-right')}>{children}</div>
            {resize && <ColumnResizeHandle width={width} {...resize} />}
        </div>
    )
}