Skip to content

Commit

Permalink
fallback styling
Browse files Browse the repository at this point in the history
  • Loading branch information
onnovisser committed Oct 25, 2023
1 parent bc1ad1b commit 0d06f28
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions centrifuge-app/src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ export const DataTable = <T extends Record<string, any>>({
minWidth={scrollWidth > 0 ? scrollWidth : 'auto'}
>
{showHeader && (
<HeaderRow>
<HeaderRow templateColumns={templateColumns}>
{columns.map((col, i) => (
<HeaderCol key={i} align={col?.align}>
<Text variant="body3">
Expand All @@ -117,6 +117,7 @@ export const DataTable = <T extends Record<string, any>>({
to={onRowClicked && (() => onRowClicked(row))}
key={keyField ? row[keyField] : i}
tabIndex={onRowClicked ? 0 : undefined}
templateColumns={templateColumns}
>
{columns.map((col, index) => (
<DataCol variant="body2" align={col?.align} key={index}>
Expand All @@ -127,7 +128,7 @@ export const DataTable = <T extends Record<string, any>>({
))}
{/* summary row is not included in sorting */}
{summary && (
<DataRow>
<DataRow templateColumns={templateColumns}>
{columns.map((col, i) => (
<DataCol variant="body2" key={`${col.sortKey}-${i}`} align={col?.align}>
{col.cell(summary, i)}
Expand All @@ -146,14 +147,18 @@ export const DataTable = <T extends Record<string, any>>({

const TableGrid = styled(Grid)``

const Row = styled('div')`
const Row = styled('div')<any>`
display: grid;
// Fallback for browsers that don't support subgrid
// Tables will look a bit wonky in those browsers
// TODO: Remove when browser support is sufficient
grid-template-columns: ${(props) => props.templateColumns};
grid-template-columns: subgrid;
grid-column: start / end;
box-shadow: ${({ theme }) => `-1px 0 0 0 ${theme.colors.borderSecondary}, 1px 0 0 0 ${theme.colors.borderSecondary}`};
`

const HeaderRow = styled(Row)(
const HeaderRow = styled(Row)<any>(
css({
backgroundColor: 'backgroundSecondary',
borderStyle: 'solid',
Expand Down

0 comments on commit 0d06f28

Please sign in to comment.