Skip to content

Commit

Permalink
Add header styling
Browse files Browse the repository at this point in the history
  • Loading branch information
kattylucy committed Jan 22, 2025
1 parent 2e38cd1 commit 2bc7833
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 25 deletions.
21 changes: 17 additions & 4 deletions centrifuge-app/src/components/DataTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import Decimal from 'decimal.js-light'
import { getIn } from 'formik'
import * as React from 'react'
import { Link, LinkProps } from 'react-router-dom'
import styled from 'styled-components'
import styled, { useTheme } from 'styled-components'
import { FiltersState } from '../utils/useFilters'
import { FilterButton } from './FilterButton'
import { QuickAction } from './QuickAction'
Expand Down Expand Up @@ -50,7 +50,7 @@ export type DataTableProps<T = any> = {
footer?: React.ReactNode
pageSize?: number
page?: number
headerStyles?: React.CSSProperties
hideHeader?: boolean
hideBorder?: boolean
} & GroupedProps

Expand Down Expand Up @@ -100,10 +100,11 @@ export const DataTable = <T extends Record<string, any>>({
defaultSortOrder = 'desc',
pageSize = Infinity,
page = 1,
headerStyles,
hideHeader,
scrollable = false,
hideBorder,
}: DataTableProps<T>) => {
const theme = useTheme()
const tableRef = React.useRef<HTMLDivElement>(null)
const [offsetTop, setOffsetTop] = React.useState(0)
const [orderBy, setOrderBy] = React.useState<Record<string, OrderBy>>(
Expand Down Expand Up @@ -147,7 +148,19 @@ export const DataTable = <T extends Record<string, any>>({
offsetTop={offsetTop}
>
{showHeader && (
<HeaderRow styles={headerStyles} scrollable={scrollable} hideBorder={hideBorder}>
<HeaderRow
styles={
hideHeader
? {
backgroundColor: 'transparent',
border: 'transparent',
borderBottom: `1px solid ${theme.colors.backgroundInverted}`,
}
: {}
}
scrollable={scrollable}
hideBorder={hideBorder}
>
{columns.map((col, i) => (
<HeaderCol key={i} align={col?.align} isLabel={col.isLabel}>
<Text variant="body3">
Expand Down
11 changes: 1 addition & 10 deletions centrifuge-app/src/components/PoolOverview/TrancheTokenCards.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -155,16 +155,7 @@ export const TrancheTokenCards = ({
overflow="auto"
borderBottom={`1px solid ${theme.colors.borderPrimary}`}
>
<DataTable
headerStyles={{
backgroundColor: 'white',
border: 'transparent',
borderBottom: `1px solid ${theme.colors.backgroundInverted}`,
}}
columns={columns}
data={dataTable}
hideBorder
/>
<DataTable columns={columns} data={dataTable} hideBorder hideHeader />
</Box>
</Shelf>
)
Expand Down
12 changes: 1 addition & 11 deletions centrifuge-app/src/components/Portfolio/Holdings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -295,17 +295,7 @@ export function Holdings({
isOpen={!!(openSendDrawer || openReceiveDrawer)}
onClose={() => navigate(pathname, { replace: true })}
/>
<DataTable
headerStyles={{
backgroundColor: 'white',
border: 'transparent',
borderBottom: `1px solid ${theme.colors.backgroundInverted}`,
}}
columns={columns}
data={tokens}
defaultSortKey="position"
hideBorder
/>
<DataTable hideHeader columns={columns} data={tokens} defaultSortKey="position" hideBorder />
<Box borderBottom={`1px solid ${theme.colors.backgroundTertiary}`} />
</Box>
) : (
Expand Down

0 comments on commit 2bc7833

Please sign in to comment.