mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Make separate VirtualTableHeader
Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
9247f932dc
commit
0629ff3123
@ -11,12 +11,12 @@
|
||||
border-bottom: thin solid var(--hrColor);
|
||||
color: var(--textColorAccent);
|
||||
height: 33px;
|
||||
position: sticky;
|
||||
// position: sticky;
|
||||
top: 0;
|
||||
}
|
||||
|
||||
thead tr {
|
||||
margin: 0 var(--margin);
|
||||
// margin: 0 var(--margin);
|
||||
}
|
||||
|
||||
tr {
|
||||
|
||||
@ -4,13 +4,14 @@ import type { Table } from "@tanstack/react-table";
|
||||
import { flexRender } from '@tanstack/react-table';
|
||||
import { cssNames } from "../../utils";
|
||||
|
||||
interface TableHeaderProps<Data> {
|
||||
export interface TableHeaderProps<Data> {
|
||||
table: Table<Data>;
|
||||
className?: string;
|
||||
}
|
||||
|
||||
export function TableHeader<Data>({ table }: TableHeaderProps<Data>) {
|
||||
export function TableHeader<Data>({ table, className }: TableHeaderProps<Data>) {
|
||||
return (
|
||||
<thead>
|
||||
<thead className={className}>
|
||||
{table.getHeaderGroups().map(headerGroup => (
|
||||
<tr key={headerGroup.id}>
|
||||
{headerGroup.headers.map(header => (
|
||||
|
||||
@ -0,0 +1,11 @@
|
||||
.header {
|
||||
display: block;
|
||||
|
||||
tr {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
th {
|
||||
flex: 1 0;
|
||||
}
|
||||
}
|
||||
9
src/renderer/components/table/virtual-table-header.tsx
Normal file
9
src/renderer/components/table/virtual-table-header.tsx
Normal file
@ -0,0 +1,9 @@
|
||||
import styles from "./virtual-table-header.module.scss";
|
||||
import React from "react";
|
||||
import { TableHeader, TableHeaderProps } from "./table-header";
|
||||
|
||||
export function VirtualTableHeader<Data>(props: TableHeaderProps<Data>) {
|
||||
return (
|
||||
<TableHeader {...props} className={styles.header}/>
|
||||
)
|
||||
}
|
||||
@ -6,8 +6,8 @@
|
||||
import React from "react";
|
||||
import { flexRender, Row } from "@tanstack/react-table"
|
||||
import type { Table, Cell } from "@tanstack/react-table";
|
||||
import { TableHeader } from "./table-header";
|
||||
import { useVirtualizer } from "@tanstack/react-virtual";
|
||||
import { VirtualTableHeader } from "./virtual-table-header";
|
||||
|
||||
interface TableProps<T> {
|
||||
table: Table<T>;
|
||||
@ -34,7 +34,7 @@
|
||||
width: '100%',
|
||||
position: 'relative',
|
||||
}}>
|
||||
<TableHeader table={table}/>
|
||||
<VirtualTableHeader table={table}/>
|
||||
<tbody>
|
||||
{rowVirtualizer.getVirtualItems().map(virtualRow => {
|
||||
const row = rows[virtualRow.index] as Row<Data>
|
||||
|
||||
Loading…
Reference in New Issue
Block a user