From 430ced3e00494c924efa720cbfbf7a59c9e54f40 Mon Sep 17 00:00:00 2001 From: theborakompanioni Date: Thu, 8 Jan 2026 21:05:21 +0100 Subject: [PATCH] chore(orderbook): table column alignment --- src/components/orderbook/Orderbook.tsx | 56 ++++++++++++++++++++++---- 1 file changed, 49 insertions(+), 7 deletions(-) diff --git a/src/components/orderbook/Orderbook.tsx b/src/components/orderbook/Orderbook.tsx index d2d21248..08d530ce 100644 --- a/src/components/orderbook/Orderbook.tsx +++ b/src/components/orderbook/Orderbook.tsx @@ -152,6 +152,8 @@ const offerToTableEntry = ( const columnHelper = createColumnHelper() +type OrderTableColumnMeta = { align?: string } | undefined + interface SortIconProps { className?: string sortKey: SortKey @@ -221,9 +223,12 @@ const OrderbookTable = ({ tableEntries, selectedEntries: highlightedEntries, pin ), + meta: { + align: 'center', + } as OrderTableColumnMeta, }), columnHelper.accessor('fee', { - header: () =>
{t('orderbook.table.heading_fee')}
, + header: () =>
{t('orderbook.table.heading_fee')}
, // Custom sorting: absolute before relative, then by fee value sortingFn: (a, b) => { if (a.original.type.isAbsolute !== b.original.type.isAbsolute) return a.original.type.isAbsolute ? -1 : 1 @@ -237,22 +242,34 @@ const OrderbookTable = ({ tableEntries, selectedEntries: highlightedEntries, pin ) }, + meta: { + align: 'right', + } as OrderTableColumnMeta, }), columnHelper.accessor('minimumSize', { header: () =>
{t('orderbook.table.heading_minimum_size')}
, sortingFn: (a, b) => Number(a.original.minimumSize) - Number(b.original.minimumSize), cell: (info) => , + meta: { + align: 'right', + } as OrderTableColumnMeta, }), columnHelper.accessor('maximumSize', { header: () =>
{t('orderbook.table.heading_maximum_size')}
, sortingFn: (a, b) => Number(a.original.maximumSize) - Number(b.original.maximumSize), cell: (info) => , + meta: { + align: 'right', + } as OrderTableColumnMeta, }), columnHelper.accessor('minerFeeContribution', { header: () =>
{t('orderbook.table.heading_miner_fee_contribution')}
, sortingFn: (a, b) => Number(a.original.minerFeeContribution) - Number(b.original.minerFeeContribution), cell: (info) => , enableHiding: true, + meta: { + align: 'right', + } as OrderTableColumnMeta, }), columnHelper.accessor('bondValue', { header: () =>
{t('orderbook.table.heading_bond_value')}
, @@ -279,6 +296,9 @@ const OrderbookTable = ({ tableEntries, selectedEntries: highlightedEntries, pin <>{entry.bondValue.displayValue} ) }, + meta: { + align: 'right', + }, }), ], [t], @@ -360,17 +380,25 @@ const OrderbookTable = ({ tableEntries, selectedEntries: highlightedEntries, pin {headerGroup.headers.map((header) => { const canSort = header.column.getCanSort() const key = header.column.id as SortKey - const alignRight = (header.column.columnDef.meta as { align?: string } | undefined)?.align === 'right' + const alignCenter = (header.column.columnDef.meta as OrderTableColumnMeta)?.align === 'center' + const alignRight = (header.column.columnDef.meta as OrderTableColumnMeta)?.align === 'right' return ( handleSort(key) : undefined} > -
+
{flexRender(header.column.columnDef.header, header.getContext())} {canSort ? : undefined}
@@ -384,9 +412,16 @@ const OrderbookTable = ({ tableEntries, selectedEntries: highlightedEntries, pin {table.getTopRows().map((row) => ( {row.getVisibleCells().map((cell) => { - const alignRight = (cell.column.columnDef.meta as { align?: string } | undefined)?.align === 'right' + const alignCenter = (cell.column.columnDef.meta as OrderTableColumnMeta)?.align === 'center' + const alignRight = (cell.column.columnDef.meta as OrderTableColumnMeta)?.align === 'right' return ( - + {flexRender(cell.column.columnDef.cell, cell.getContext())} ) @@ -397,9 +432,16 @@ const OrderbookTable = ({ tableEntries, selectedEntries: highlightedEntries, pin return ( {row.getVisibleCells().map((cell) => { - const alignRight = (cell.column.columnDef.meta as { align?: string } | undefined)?.align === 'right' + const alignCenter = (cell.column.columnDef.meta as OrderTableColumnMeta)?.align === 'center' + const alignRight = (cell.column.columnDef.meta as OrderTableColumnMeta)?.align === 'right' return ( - + {flexRender(cell.column.columnDef.cell, cell.getContext())} )