#73 Allowing to specify width of columns in Table component
This commit is contained in:
parent
22a5da1722
commit
e460c152eb
|
@ -14,6 +14,17 @@ export type Column = {
|
||||||
disablePadding: boolean,
|
disablePadding: boolean,
|
||||||
label: string,
|
label: string,
|
||||||
custom: boolean, // If content will be rendered by user manually
|
custom: boolean, // If content will be rendered by user manually
|
||||||
|
width?: number,
|
||||||
|
}
|
||||||
|
|
||||||
|
export const cellWidth = (width: number | typeof undefined) => {
|
||||||
|
if (!width) {
|
||||||
|
return undefined
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
width: `${width}px`,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
|
|
@ -55,6 +55,7 @@ export const generateColumns = () => {
|
||||||
disablePadding: false,
|
disablePadding: false,
|
||||||
label: 'Asset',
|
label: 'Asset',
|
||||||
custom: false,
|
custom: false,
|
||||||
|
width: 250,
|
||||||
}
|
}
|
||||||
|
|
||||||
const balanceRow: Column = {
|
const balanceRow: Column = {
|
||||||
|
|
|
@ -12,7 +12,7 @@ import Col from '~/components/layout/Col'
|
||||||
import Row from '~/components/layout/Row'
|
import Row from '~/components/layout/Row'
|
||||||
import Paragraph from '~/components/layout/Paragraph'
|
import Paragraph from '~/components/layout/Paragraph'
|
||||||
import Modal from '~/components/Modal'
|
import Modal from '~/components/Modal'
|
||||||
import { type Column } from '~/components/Table/TableHead'
|
import { type Column, cellWidth } from '~/components/Table/TableHead'
|
||||||
import Table from '~/components/Table'
|
import Table from '~/components/Table'
|
||||||
import { sm, xs } from '~/theme/variables'
|
import { sm, xs } from '~/theme/variables'
|
||||||
import { getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero } from './dataFetcher'
|
import { getBalanceData, generateColumns, BALANCE_TABLE_ASSET_ID, type BalanceRow, filterByZero } from './dataFetcher'
|
||||||
|
@ -155,11 +155,11 @@ class Balances extends React.Component<Props, State> {
|
||||||
{(sortedData: Array<BalanceRow>) => sortedData.map((row: any, index: number) => (
|
{(sortedData: Array<BalanceRow>) => sortedData.map((row: any, index: number) => (
|
||||||
<TableRow tabIndex={-1} key={index} className={classes.hide}>
|
<TableRow tabIndex={-1} key={index} className={classes.hide}>
|
||||||
{ autoColumns.map((column: Column) => (
|
{ autoColumns.map((column: Column) => (
|
||||||
<TableCell key={column.id} numeric={column.numeric} component="th" scope="row">
|
<TableCell key={column.id} style={cellWidth(column.width)} numeric={column.numeric} component="td">
|
||||||
{row[column.id]}
|
{row[column.id]}
|
||||||
</TableCell>
|
</TableCell>
|
||||||
)) }
|
)) }
|
||||||
<TableCell component="th" scope="row">
|
<TableCell component="td">
|
||||||
<Row align="end" className={classes.actions}>
|
<Row align="end" className={classes.actions}>
|
||||||
{ granted &&
|
{ granted &&
|
||||||
<Button variant="contained" size="small" color="secondary" className={classes.send} onClick={this.onShow('Send')}>
|
<Button variant="contained" size="small" color="secondary" className={classes.send} onClick={this.onShow('Send')}>
|
||||||
|
|
Loading…
Reference in New Issue