Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add tdCellClassName in table columns #1909

Merged
merged 1 commit into from
Dec 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 3 additions & 8 deletions src/components/creditNote/CreditNotesTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,11 +326,12 @@ const CreditNotesTable = ({
key: 'invoice.customer.displayName',
title: translate('text_63ac86d797f728a87b2f9fb3'),
content: (creditNote: CreditNoteTableItemFragment) => (
<CustomerColumn variant="body" color="grey600" noWrap>
<Typography variant="body" color="grey600" noWrap>
{creditNote.invoice?.customer.displayName}
</CustomerColumn>
</Typography>
),
maxSpace: true,
tdCellClassName: 'hidden md:table-cell',
} as TableColumn<CreditNoteTableItemFragment>,
]
: []),
Expand Down Expand Up @@ -383,9 +384,3 @@ const Grid = () => css`
const SkeletonLine = styled(BaseListItem)`
${Grid()}
`

const CustomerColumn = styled(Typography)`
${theme.breakpoints.down('md')} {
display: none;
}
`
13 changes: 11 additions & 2 deletions src/components/designSystem/Table/Table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ export type TableColumn<T> = {
maxSpace?: boolean
minWidth?: number
truncateOverflow?: boolean
tdCellClassName?: string
}

type DataItem = {
Expand Down Expand Up @@ -139,17 +140,19 @@ const TableCell = ({
hasPlaceholderDisplayed,
isBlurred,
maxSpace,
tdCellClassName,
...props
}: PropsWithChildren &
TableCellProps & {
className?: string
isBlurred?: boolean
hasPlaceholderDisplayed?: boolean
maxSpace?: number
tdCellClassName?: string
}) => {
return (
<MUITableCell
className={tw('lago-table-cell', 'w-auto whitespace-nowrap p-0', className)}
className={tw('lago-table-cell', 'w-auto whitespace-nowrap p-0', className, tdCellClassName)}
style={{
width: !!maxSpace ? `${maxSpace}%` : 'auto',
borderBottom: !!hasPlaceholderDisplayed ? 'none' : `1px solid ${theme.palette.grey[300]}`,
Expand Down Expand Up @@ -248,7 +251,11 @@ const LoadingRows = <T,>({
return Array.from({ length: LOADING_ROW_COUNT }).map((_, i) => (
<TableRow key={`${id}-loading-row-${i}`}>
{columns.map((col, j) => (
<TableCell hasPlaceholderDisplayed={false} key={`${id}-loading-cell-${i}-${j}`}>
<TableCell
tdCellClassName={col.tdCellClassName}
hasPlaceholderDisplayed={false}
key={`${id}-loading-cell-${i}-${j}`}
>
<TableInnerCell minWidth={col.minWidth} align={col.textAlign}>
<div
style={{
Expand Down Expand Up @@ -465,6 +472,7 @@ export const Table = <T extends DataItem>({
key={`${TABLE_ID}-head-${i}`}
align={column.textAlign || 'left'}
maxSpace={column.maxSpace ? 100 / maxSpaceColumns : undefined}
tdCellClassName={column.tdCellClassName}
>
<TableInnerCell
className="min-h-10 text-grey-600"
Expand Down Expand Up @@ -502,6 +510,7 @@ export const Table = <T extends DataItem>({
key={`${TABLE_ID}-cell-${i}-${j}`}
align={column.textAlign || 'left'}
maxSpace={column.maxSpace ? 100 / maxSpaceColumns : undefined}
tdCellClassName={column.tdCellClassName}
>
<TableInnerCell
minWidth={column.minWidth}
Expand Down
Loading