Skip to content

Commit

Permalink
feat: define a height limit for tables
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielborgesdm committed May 24, 2024
1 parent 5a1a7c0 commit ea8cd21
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 68 deletions.
76 changes: 40 additions & 36 deletions frontend/src/pages/Authors/Authors.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -38,45 +38,49 @@ const Authors: React.FC = () => {
</button>
</div>
<hr />
<table className="w-full text-sm text-left rtl:text-right text-gray-500">
<thead className="text-xs uppercase ">
<tr>
<div className='block max-h-[78dvh] overflow-y-auto'>
<table className="w-full text-sm text-left rtl:text-right text-gray-500">
<thead className="text-xs uppercase ">
<tr>

<th scope="col" className="px-1 py-3">
Author
</th>
<th scope="col" className="px-1 py-3">
Nationality
</th>
<th scope="col" className="px-1 py-3">
Birth date
</th>
<th scope="col" className="px-1 py-3">
E-mail
</th>
</tr>
</thead>
<tbody>{authors?.length > 0 && authors.map(({ name, nationality, birthDate, email, id }: Author) => (
shouldFilterInWith(name, nationality, birthDate, email, id)
&& (
<tr key={id} className="border-b hover:bg-gray-50">
<th scope="row" className="px-1 py-4 font-medium text-gray-900 whitespace-nowrap">
{name}
<th scope="col" className="px-1 py-3">
Author
</th>
<th scope="col" className="px-1 py-3">
Nationality
</th>
<th scope="col" className="px-1 py-3">
Birth date
</th>
<th scope="col" className="px-1 py-3">
E-mail
</th>
<td className="px-1 py-4">
{nationality}
</td>
<td className="px-1 py-4">
{birthDate}
</td>
<td className="px-1 py-4">
{email}
</td>
</tr>
)
))}</tbody>
</table>
</div>
</thead>
<tbody>
{authors?.length > 0 && authors.map(({ name, nationality, birthDate, email, id }: Author) => (
shouldFilterInWith(name, nationality, birthDate, email, id)
&& (
<tr key={id} className="border-b hover:bg-gray-50">
<th scope="row" className="px-1 py-4 font-medium text-gray-900 whitespace-nowrap">
{name}
</th>
<td className="px-1 py-4">
{nationality}
</td>
<td className="px-1 py-4">
{birthDate}
</td>
<td className="px-1 py-4">
{email}
</td>
</tr>
)
))}
</tbody>
</table>
</div>
</div >
);
};

Expand Down
67 changes: 35 additions & 32 deletions frontend/src/pages/Books/Books.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,41 +41,44 @@ const Books: React.FC = () => {
</button>
</div>
<hr />
<table className="w-full text-sm text-left rtl:text-right text-gray-500">
<thead className="text-xs uppercase ">
<tr>
<div className='block max-h-[78dvh] overflow-y-auto'>
<table className="w-full text-sm text-left rtl:text-right text-gray-500">
<thead className="text-xs uppercase ">
<tr>

<th scope="col" className="px-1 py-3">
Book title
</th>
<th scope="col" className="px-1 py-3">
Pages
</th>
<th scope="col" className="px-1 py-3">
Authors
</th>
</tr>
</thead>
<tbody>{books?.length > 0 && books.map(({ id, title, pages, authorsNames }: Book) => (
shouldFilterInWith(title, pages, id, authorsNames)
&& (
<tr key={id} className="border-b hover:bg-gray-50">
<th scope="row" className="px-1 py-4 font-medium text-gray-900 whitespace-nowrap">
{title}
<th scope="col" className="px-1 py-3">
Book title
</th>
<th scope="col" className="px-1 py-3">
Pages
</th>
<th scope="col" className="px-1 py-3">
Authors
</th>
<td className="px-1 py-4">
{Number.isInteger(pages) ? `${pages} pages` : "Not informed"}
</td>
<td className="px-1 py-4">
{
<span className='block max-w-52 truncate'>{authorsNames}</span>
}
</td>
</tr>
)
))}</tbody>
</table>
</div>
</thead>
<tbody>
{books?.length > 0 && books.map(({ id, title, pages, authorsNames }: Book) => (
shouldFilterInWith(title, pages, id, authorsNames) && (
<tr key={id} className="border-b hover:bg-gray-50">
<th scope="row" className="px-1 py-4 font-medium text-gray-900 whitespace-nowrap">
{title}
</th>
<td className="px-1 py-4">
{Number.isInteger(pages) ? `${pages} pages` : "Not informed"}
</td>
<td className="px-1 py-4">
{
<span className='block max-w-52 truncate'>{authorsNames}</span>
}
</td>
</tr>
)
))}
</tbody>
</table >
</div>
</div >
);
};

Expand Down

0 comments on commit ea8cd21

Please sign in to comment.