@hypothesis/frontend-shared
Version:
Shared components, styles and utilities for Hypothesis projects
45 lines • 1.43 kB
JavaScript
var _jsxFileName = "/home/runner/work/frontend-shared/frontend-shared/src/components/data/TableHead.tsx";
import classnames from 'classnames';
import { useContext, useMemo } from 'preact/hooks';
import { downcastRef } from '../../util/typing';
import TableContext from './TableContext';
import TableSectionContext from './TableSectionContext';
import { jsxDEV as _jsxDEV } from "preact/jsx-dev-runtime";
/**
* Render a table head section
*/
export default function TableHead({
children,
classes,
elementRef,
...htmlAttributes
}) {
const tableContext = useContext(TableContext);
const sectionContext = useMemo(() => ({
section: 'head'
}), []);
return _jsxDEV(TableSectionContext.Provider, {
value: sectionContext,
children: _jsxDEV("thead", {
"data-component": "TableHead",
...htmlAttributes,
ref: downcastRef(elementRef),
className: classnames(
// This ensures the header is drawn on top of positioned content
// in table cells.
'z-1', 'bg-grey-2', {
'sticky top-0': tableContext === null || tableContext === void 0 ? void 0 : tableContext.stickyHeader
}, classes),
children: children
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 35,
columnNumber: 7
}, this)
}, void 0, false, {
fileName: _jsxFileName,
lineNumber: 34,
columnNumber: 5
}, this);
}
//# sourceMappingURL=TableHead.js.map