improve table component

This commit is contained in:
João Geonizeli
2021-09-11 12:14:54 -03:00
parent a61a36a5bf
commit 80bfdbe528
2 changed files with 24 additions and 41 deletions

View File

@@ -26,7 +26,11 @@ export const TableRow: FC<Props> = ({ items, id, onClick }) => {
> >
{items?.map((item, index) => ( {items?.map((item, index) => (
<td key={index} className="px-5 py-5 border-b border-gray-200 text-sm"> <td key={index} className="px-5 py-5 border-b border-gray-200 text-sm">
{typeof item === "string" ? (
<p className="text-gray-900 whitespace-nowrap">{item}</p> <p className="text-gray-900 whitespace-nowrap">{item}</p>
) : (
item
)}
</td> </td>
))} ))}
</tr> </tr>

View File

@@ -3,6 +3,7 @@ import type { FC } from "react";
import React from "react"; import React from "react";
import { useFragment } from "react-relay"; import { useFragment } from "react-relay";
import { Table, TableRow } from "../../components";
import { getCurrencyLogo } from "../../utils/getCurrencyLogo"; import { getCurrencyLogo } from "../../utils/getCurrencyLogo";
import type { Balance_balance$key } from "./__generated__/Balance_balance.graphql"; import type { Balance_balance$key } from "./__generated__/Balance_balance.graphql";
@@ -24,27 +25,10 @@ export const Balance: FC<Props> = ({ balancesRef }) => {
return ( return (
<div className="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto"> <div className="-mx-4 sm:-mx-8 px-4 sm:px-8 py-4 overflow-x-auto">
<div className="inline-block min-w-full shadow rounded-lg overflow-hidden"> <div className="inline-block min-w-full shadow rounded-lg overflow-hidden">
<table className="min-w-full leading-normal"> <Table columns={["Moeda", "Saldo"]}>
<thead> <TableRow
<tr> items={[
<th <div className="flex items-center" key="pancake coin">
scope="col"
className="px-5 py-3 bg-white border-b border-gray-200 text-gray-800 text-left text-sm uppercase font-normal"
>
Moeda
</th>
<th
scope="col"
className="px-5 py-3 bg-white border-b border-gray-200 text-gray-800 text-left text-sm uppercase font-normal"
>
Saldo
</th>
</tr>
</thead>
<tbody>
<tr>
<td className="px-5 py-5 border-b border-gray-200 bg-white text-sm">
<div className="flex items-center">
<div className="flex-shrink-0"> <div className="flex-shrink-0">
<img <img
alt="CAKE icon" alt="CAKE icon"
@@ -55,16 +39,11 @@ export const Balance: FC<Props> = ({ balancesRef }) => {
<div className="ml-3"> <div className="ml-3">
<p className="text-gray-900 whitespace-no-wrap">CAKE</p> <p className="text-gray-900 whitespace-no-wrap">CAKE</p>
</div> </div>
</div> </div>,
</td> node.amount,
<td className="px-5 py-5 border-b border-gray-200 bg-white text-sm"> ]}
<p className="text-gray-900 whitespace-no-wrap"> />
{node.amount} </Table>
</p>
</td>
</tr>
</tbody>
</table>
</div> </div>
</div> </div>
); );