Skip to content

Commit

Permalink
chore: padding in table rows (#1313)
Browse files Browse the repository at this point in the history
  • Loading branch information
siddhart1o1 authored Feb 4, 2025
1 parent 3fb50fd commit dbebd53
Show file tree
Hide file tree
Showing 7 changed files with 80 additions and 27 deletions.
9 changes: 7 additions & 2 deletions apps/admin-panel/app/credit-facilities/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,12 @@ const columns: Column<CreditFacility>[] = [
{
key: "status",
label: "Status",
render: (status) => <LoanAndCreditFacilityStatusBadge status={status} />,
render: (status) => (
<LoanAndCreditFacilityStatusBadge
className="flex items-center justify-center text-center min-h-full min-w-full"
status={status}
/>
),
filterValues: Object.values(CreditFacilityStatus),
},
{
Expand All @@ -133,7 +138,7 @@ const columns: Column<CreditFacility>[] = [
},
{
key: "collateralizationState",
label: "Collateralization State",
label: "State",
render: (state) => formatCollateralizationState(state),
filterValues: Object.values(CollateralizationState),
},
Expand Down
2 changes: 2 additions & 0 deletions apps/admin-panel/app/loans/status-badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ const getVariant = (status: CreditFacilityStatus) => {
return "success"
case CreditFacilityStatus.PendingApproval:
return "default"
case CreditFacilityStatus.PendingCollateralization:
return "warning"
default:
return "secondary"
}
Expand Down
34 changes: 18 additions & 16 deletions apps/admin-panel/components/data-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,11 +213,8 @@ const DataTable = <T,>({
))}
</div>
) : (
<div
className="w-full overflow-x-auto border rounded-md"
data-testid="loading-skeleton"
>
<Table className={className}>
<div className="overflow-x-auto border rounded-md" data-testid="loading-skeleton">
<Table className={cn("table-fixed w-full", className)}>
<TableHeader className="bg-secondary [&_tr:hover]:!bg-secondary">
<TableRow className={headerClassName}>
{columns.map((column, index) => (
Expand All @@ -229,23 +226,25 @@ const DataTable = <T,>({
)}
style={{ width: column.width }}
>
{column.header}
<div className="flex items-center space-x-2 justify-between">
<span>{column.header}</span>
</div>
</TableHead>
))}
{navigateTo && <TableHead className="w-24"></TableHead>}
{navigateTo && <TableHead className="w-24" />}
</TableRow>
</TableHeader>
<TableBody>
{Array.from({ length: 5 }).map((_, rowIndex) => (
<TableRow key={rowIndex}>
{columns.map((_, colIndex) => (
<TableCell key={colIndex}>
<Skeleton className="h-4 w-full" />
<TableCell key={colIndex} className="h-[3.8rem]">
<Skeleton className="h-9 w-full" />
</TableCell>
))}
{navigateTo && (
<TableCell>
<Skeleton className="h-4 w-full" />
<TableCell className="h-[3.8rem]">
<Skeleton className="h-9 w-full" />
</TableCell>
)}
</TableRow>
Expand Down Expand Up @@ -331,7 +330,7 @@ const DataTable = <T,>({
return (
<div
ref={tableRef}
className="w-full overflow-x-auto border rounded-md focus:outline-none"
className="overflow-x-auto border rounded-md focus:outline-none"
tabIndex={0}
role="grid"
onFocus={() => setIsTableFocused(true)}
Expand All @@ -342,7 +341,7 @@ const DataTable = <T,>({
}
}}
>
<Table className={className}>
<Table className={cn("table-fixed w-full", className)}>
<TableHeader className="bg-secondary [&_tr:hover]:!bg-secondary">
<TableRow className={headerClassName}>
{columns.map((column, index) => (
Expand All @@ -354,10 +353,12 @@ const DataTable = <T,>({
)}
style={{ width: column.width }}
>
{column.header}
<div className="flex items-center space-x-2 justify-between">
<span>{column.header}</span>
</div>
</TableHead>
))}
{navigateTo && <TableHead className="w-24"></TableHead>}
{navigateTo && <TableHead className="w-24" />}
</TableRow>
</TableHeader>
<TableBody>
Expand All @@ -383,6 +384,7 @@ const DataTable = <T,>({
<TableCell
key={colIndex}
className={cn(
"whitespace-normal break-words h-[3.8rem]",
column.align === "center" && "text-center",
column.align === "right" && "text-right",
typeof cellClassName === "function"
Expand All @@ -396,7 +398,7 @@ const DataTable = <T,>({
</TableCell>
))}
{shouldShowNavigation(item) && (
<TableCell>
<TableCell className="h-[3.8rem]">
<Link href={getNavigationUrl(item) || ""}>
<Button
variant="outline"
Expand Down
52 changes: 45 additions & 7 deletions apps/admin-panel/components/paginated-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -276,11 +276,37 @@ const PaginatedTable = <T,>({
</div>
) : (
<div className="overflow-x-auto border rounded-md">
<Table>
<Table className="table-fixed w-full">
<TableHeader className="bg-secondary [&_tr:hover]:!bg-secondary">
<TableRow>
{columns.map((col) => (
<TableHead key={col.key as string}>{col.label}</TableHead>
<TableHead key={col.key as string}>
<div className="flex items-center space-x-2 justify-between">
<span>{col.label}</span>
<div className="flex items-center">
{col.sortable && (
<Button
variant="ghost"
size="sm"
className="h-9 w-8 p-0"
disabled
>
<HiSelector className="h-4 w-4" />
</Button>
)}
{col.filterValues && (
<Button
variant="ghost"
size="sm"
className="h-9 w-8 p-0"
disabled
>
<HiFilter className="h-4 w-4" />
</Button>
)}
</div>
</div>
</TableHead>
))}
{navigateTo && <TableHead className="w-24" />}
</TableRow>
Expand All @@ -289,19 +315,31 @@ const PaginatedTable = <T,>({
{Array.from({ length: pageSize }).map((_, rowIndex) => (
<TableRow key={rowIndex}>
{columns.map((_, colIndex) => (
<TableCell key={colIndex}>
<Skeleton className="h-4 w-full" />
<TableCell key={colIndex} className="h-[3.8rem]">
<Skeleton className="h-9 w-full" />
</TableCell>
))}
{navigateTo && (
<TableCell>
<Skeleton className="h-4 w-full" />
<TableCell className="h-[3.8rem]">
<Skeleton className="h-9 w-full" />
</TableCell>
)}
</TableRow>
))}
</TableBody>
</Table>
<Separator />
<div className="flex items-center justify-end space-x-4 py-2 mr-2">
<Button variant="outline" size="sm" disabled>
<HiChevronLeft className="h-4 w-4" />
</Button>
<div className="flex items-center gap-1">
<span className="text-sm font-medium">1</span>
</div>
<Button variant="outline" size="sm" disabled>
<HiChevronRight className="h-4 w-4" />
</Button>
</div>
</div>
)
}
Expand Down Expand Up @@ -525,7 +563,7 @@ const PaginatedTable = <T,>({
{columns.map((col) => (
<TableCell
key={col.key as string}
className="whitespace-normal break-words"
className="whitespace-normal break-words h-[3.8rem]"
>
{col.render ? col.render(node[col.key], node) : String(node[col.key])}
</TableCell>
Expand Down
7 changes: 5 additions & 2 deletions lib/js/shared-web/global.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,11 @@
--sidebar-ring: 217.2 91.2% 59.8%;

/* CUSTOM */
--success: 142.1 70.6% 45.3%;
--success-foreground: 144.9 80.4% 10%;
--success: 173 58% 39%;
--success-foreground: 0 0% 98%;

--warning: 12 76% 61%;
--warning-foreground: 0 0% 98%;
}

.dark {
Expand Down
2 changes: 2 additions & 0 deletions lib/js/shared-web/src/ui/badge.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ const badgeVariants = cva(
success:
"border-transparent bg-success text-success-foreground shadow hover:bg-success/80",
outline: "border-[#343a40] text-[#343a40] bg-[#343a400d]",
warning:
"border-transparent bg-warning text-primary-foreground shadow hover:bg-warning/80",
},
},
defaultVariants: {
Expand Down
1 change: 1 addition & 0 deletions lib/js/shared-web/tailwind.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ const tailwindConfig = {
},
warning: {
DEFAULT: "hsl(var(--warning))",
foreground: "hsl(var(--warning-foreground))",
},
chart: {
"1": "hsl(var(--chart-1))",
Expand Down

0 comments on commit dbebd53

Please sign in to comment.