feat: tweak file table col sizes

This commit is contained in:
2025-09-15 23:27:56 +00:00
parent 9d62de2c99
commit 8f82f8d5ad

View File

@@ -72,6 +72,7 @@ const columns: ColumnDef<DirectoryItem>[] = [
), ),
enableSorting: false, enableSorting: false,
enableHiding: false, enableHiding: false,
size: 24,
}, },
{ {
header: "Name", header: "Name",
@@ -82,13 +83,14 @@ const columns: ColumnDef<DirectoryItem>[] = [
return <FileNameCell initialName={row.original.doc.name} /> return <FileNameCell initialName={row.original.doc.name} />
case "directory": case "directory":
return ( return (
<div className="flex items-center gap-2"> <div className="flex w-full items-center gap-2">
<DirectoryIcon className="size-4" /> <DirectoryIcon className="size-4" />
{row.original.doc.name} {row.original.doc.name}
</div> </div>
) )
} }
}, },
size: 1000,
}, },
{ {
header: "Size", header: "Size",
@@ -217,7 +219,10 @@ export function FileTableContent() {
{table.getHeaderGroups().map((headerGroup) => ( {table.getHeaderGroups().map((headerGroup) => (
<TableRow key={headerGroup.id}> <TableRow key={headerGroup.id}>
{headerGroup.headers.map((header) => ( {headerGroup.headers.map((header) => (
<TableHead key={header.id}> <TableHead
key={header.id}
style={{ width: header.getSize() }}
>
{header.isPlaceholder {header.isPlaceholder
? null ? null
: flexRender( : flexRender(
@@ -240,7 +245,10 @@ export function FileTableContent() {
}} }}
> >
{row.getVisibleCells().map((cell) => ( {row.getVisibleCells().map((cell) => (
<TableCell key={cell.id}> <TableCell
key={cell.id}
style={{ width: cell.column.getSize() }}
>
{flexRender( {flexRender(
cell.column.columnDef.cell, cell.column.columnDef.cell,
cell.getContext(), cell.getContext(),
@@ -250,14 +258,7 @@ export function FileTableContent() {
</TableRow> </TableRow>
)) ))
) : ( ) : (
<TableRow> <NoResultsRow />
<TableCell
colSpan={columns.length}
className="text-center"
>
No results.
</TableCell>
</TableRow>
)} )}
<NewItemRow /> <NewItemRow />
</TableBody> </TableBody>
@@ -266,6 +267,20 @@ export function FileTableContent() {
) )
} }
function NoResultsRow() {
const newItemKind = useAtomValue(newItemKindAtom)
if (newItemKind) {
return null
}
return (
<TableRow>
<TableCell colSpan={columns.length} className="text-center">
No results.
</TableCell>
</TableRow>
)
}
function NewItemRow() { function NewItemRow() {
const inputRef = useRef<HTMLInputElement>(null) const inputRef = useRef<HTMLInputElement>(null)
const newItemFormId = useId() const newItemFormId = useId()
@@ -363,7 +378,7 @@ function NewItemRow() {
function FileNameCell({ initialName }: { initialName: string }) { function FileNameCell({ initialName }: { initialName: string }) {
return ( return (
<div className="flex items-center gap-2"> <div className="flex w-full items-center gap-2">
<TextFileIcon className="size-4" /> <TextFileIcon className="size-4" />
{initialName} {initialName}
</div> </div>