Skip to content

Commit 46dbd9c

Browse files
Set table cells to have shorter default height (#2158)
* Set table cells to have shorter default * Remove unused 'auto' cell height * defaults all the way down * firewall rules table is tall for now --------- Co-authored-by: David Crespo <[email protected]>
1 parent e94929a commit 46dbd9c

File tree

6 files changed

+22
-17
lines changed

6 files changed

+22
-17
lines changed

app/pages/project/instances/InstancesPage.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export function InstancesPage() {
128128
New Instance
129129
</Link>
130130
</TableActions>
131-
<Table columns={columns} emptyState={<EmptyState />} />
131+
<Table columns={columns} emptyState={<EmptyState />} rowHeight="large" />
132132
</>
133133
)
134134
}

app/pages/project/vpcs/VpcPage/tabs/VpcFirewallRulesTab.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ export const VpcFirewallRulesTab = () => {
151151
/>
152152
)}
153153
</div>
154-
{rules.length > 0 ? <Table table={table} /> : emptyState}
154+
{rules.length > 0 ? <Table table={table} rowHeight="large" /> : emptyState}
155155
</>
156156
)
157157
}

app/pages/system/UtilizationPage.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -172,41 +172,43 @@ function UsageTab() {
172172
<Table.Body>
173173
{siloUtilizations.items.map((silo) => (
174174
<Table.Row key={silo.siloName}>
175-
<Table.Cell width="16%">{silo.siloName}</Table.Cell>
176-
<Table.Cell width="14%">
175+
<Table.Cell width="16%" height="large">
176+
{silo.siloName}
177+
</Table.Cell>
178+
<Table.Cell width="14%" height="large">
177179
<UsageCell
178180
provisioned={silo.provisioned.cpus}
179181
allocated={silo.allocated.cpus}
180182
/>
181183
</Table.Cell>
182-
<Table.Cell width="14%">
184+
<Table.Cell width="14%" height="large">
183185
<UsageCell
184186
provisioned={bytesToGiB(silo.provisioned.memory)}
185187
allocated={bytesToGiB(silo.allocated.memory)}
186188
unit="GiB"
187189
/>
188190
</Table.Cell>
189-
<Table.Cell width="14%">
191+
<Table.Cell width="14%" height="large">
190192
<UsageCell
191193
provisioned={bytesToTiB(silo.provisioned.storage)}
192194
allocated={bytesToTiB(silo.allocated.storage)}
193195
unit="TiB"
194196
/>
195197
</Table.Cell>
196-
<Table.Cell width="14%" className="relative">
198+
<Table.Cell width="14%" className="relative" height="large">
197199
<AvailableCell
198200
provisioned={silo.provisioned.cpus}
199201
allocated={silo.allocated.cpus}
200202
/>
201203
</Table.Cell>
202-
<Table.Cell width="14%" className="relative">
204+
<Table.Cell width="14%" className="relative" height="large">
203205
<AvailableCell
204206
provisioned={bytesToGiB(silo.provisioned.memory)}
205207
allocated={bytesToGiB(silo.allocated.memory)}
206208
unit="GiB"
207209
/>
208210
</Table.Cell>
209-
<Table.Cell width="14%" className="relative">
211+
<Table.Cell width="14%" className="relative" height="large">
210212
<AvailableCell
211213
provisioned={bytesToTiB(silo.provisioned.storage)}
212214
allocated={bytesToTiB(silo.allocated.storage)}

app/table/QueryTable.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ type QueryTableProps<Item> = {
5656
/** Function that produces a list of actions from a row item */
5757
pagination?: 'inline' | 'page'
5858
pageSize?: number
59+
rowHeight?: 'small' | 'large'
5960
emptyState: React.ReactElement
6061
columns: ColumnDef<Item, any>[]
6162
}
@@ -72,6 +73,7 @@ const makeQueryTable = <Item extends Record<string, unknown>>(
7273
debug,
7374
pagination = 'page',
7475
pageSize = PAGE_SIZE,
76+
rowHeight = 'small',
7577
emptyState,
7678
columns,
7779
}: QueryTableProps<Item>) {
@@ -111,7 +113,7 @@ const makeQueryTable = <Item extends Record<string, unknown>>(
111113

112114
return (
113115
<>
114-
<Table table={table} />
116+
<Table table={table} rowHeight={rowHeight} />
115117
<Pagination
116118
inline={pagination === 'inline'}
117119
pageSize={pageSize}

app/table/Table.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import { Table as UITable } from '~/ui/lib/Table'
1212

1313
export type TableProps<TData> = JSX.IntrinsicElements['table'] & {
1414
rowClassName?: string
15+
rowHeight?: 'small' | 'large'
1516
table: TableInstance<TData>
1617
singleSelect?: boolean
1718
multiSelect?: boolean
@@ -20,6 +21,7 @@ export type TableProps<TData> = JSX.IntrinsicElements['table'] & {
2021
/** Render a React Table table instance */
2122
export const Table = <TData,>({
2223
rowClassName,
24+
rowHeight = 'small',
2325
table,
2426
singleSelect,
2527
multiSelect,
@@ -70,6 +72,7 @@ export const Table = <TData,>({
7072
key={cell.column.id}
7173
{...(i === 0 ? firstCellProps : {})}
7274
className={cell.column.columnDef.meta?.tdClassName}
75+
height={rowHeight}
7376
>
7477
{flexRender(cell.column.columnDef.cell, cell.getContext())}
7578
</UITable.Cell>

app/ui/lib/Table.tsx

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -93,24 +93,22 @@ Table.Body = ({ className, children, ...props }: TableBodyProps) => {
9393
)
9494
}
9595

96-
export type TableCellProps = JSX.IntrinsicElements['td'] & {
97-
height?: 'large' | 'small' | 'auto'
98-
}
99-
Table.Cell = ({ height = 'large', className, children, ...props }: TableCellProps) => {
100-
const heightClass = height === 'large' ? 'h-16' : height === 'small' ? 'h-8' : ''
96+
export type TableCellProps = JSX.IntrinsicElements['td'] & { height?: 'small' | 'large' }
97+
Table.Cell = ({ height = 'small', className, children, ...props }: TableCellProps) => {
98+
const heightClasses = { 'h-12': height === 'small', 'h-16': height === 'large' }
10199
return (
102100
<td
103101
className={cn(
104102
className,
105103
'pl-0 text-default border-default children:first:border-l-0 children:last:-mr-[1px]',
106-
heightClass
104+
heightClasses
107105
)}
108106
{...props}
109107
>
110108
<div
111109
className={cn(
112110
'relative -my-[1px] -mr-[2px] flex items-center border-b border-l py-3 pl-3 pr-3 border-secondary',
113-
heightClass
111+
heightClasses
114112
)}
115113
>
116114
{children}

0 commit comments

Comments
 (0)