Skip to content

Commit

Permalink
fix(console): small table ui improvement (#6983)
Browse files Browse the repository at this point in the history
Hide the table heading when there aren't any rows.
  • Loading branch information
skyrpex authored Aug 5, 2024
1 parent 6c42f56 commit e63ae89
Showing 1 changed file with 27 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ export const TableInteraction = memo(
.map((name) => ({ name, type: "text" }));
}, [rows]);

const hasRows = rows && rows.length > 0;

return (
<div className="inline-block align-middle w-full mt-1">
<div
Expand Down Expand Up @@ -51,39 +53,41 @@ export const TableInteraction = memo(
}}
>
<thead>
<tr
className={classNames(
theme.bgInput,
"px-1 sticky top-[4px] z-10 border-spacing-x-0",
)}
>
{columns.map(({ name }) => (
{hasRows && (
<tr
className={classNames(
theme.bgInput,
"px-1 sticky top-[4px] z-10 border-spacing-x-0",
)}
>
{columns.map(({ name }) => (
<th
key={name}
className={classNames(
"text-sm px-1.5",
"border-b border-slate-300 dark:border-slate-700",
"text-left",
)}
>
{name}
</th>
))}
<th
key={name}
className={classNames(
"text-sm px-1.5",
"w-0",
"border-b border-slate-300 dark:border-slate-700",
"text-left",
)}
>
{name}
</th>
))}
<th
className={classNames(
"w-0",
"border-b border-slate-300 dark:border-slate-700",
)}
></th>
</tr>
></th>
</tr>
)}
</thead>
<tbody className="spacing-y-1">
{rows?.length === 0 && (
{!hasRows && (
<tr>
<td
colSpan={columns.length + 1}
className={classNames(
"text-center text-xs pt-4",
"text-center text-xs py-4",
theme.text2,
)}
>
Expand Down

0 comments on commit e63ae89

Please sign in to comment.