Skip to content

Commit

Permalink
add highlight in table
Browse files Browse the repository at this point in the history
  • Loading branch information
lixun910 committed Jan 6, 2024
1 parent 2c2a1b5 commit f35cd60
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/components/src/common/data-table/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ export const Container = styled.div<ContainerProps>`
top: 0;
border-right: 2px solid ${props => props.theme.pinnedGridBorderColor};
}
.filtered-row {
background-color: ${props => props.theme.filteredRowBackground};
}
.even-row {
background-color: ${props => props.theme.evenRowBackground};
}
Expand Down Expand Up @@ -380,6 +383,7 @@ export interface DataTableProps {
fixedWidth?: number;
theme?: any;
dataContainer: DataContainerInterface;
filteredIndex?: {};
fixedHeight?: number;
colMeta: ColMeta;
sortColumn: SortColumn;
Expand All @@ -405,6 +409,7 @@ function DataTableFactory(HeaderCell: ReturnType<typeof HeaderCellFactory>) {
class DataTable extends Component<DataTableProps, DataTableState> {
static defaultProps = {
dataContainer: null,
filteredIndex: {},
pinnedColumns: [],
colMeta: {},
cellSizeCache: {},
Expand Down Expand Up @@ -491,7 +496,7 @@ function DataTableFactory(HeaderCell: ReturnType<typeof HeaderCellFactory>) {
const getRowCell = this.props.getRowCell ?? defaultGetRowCell;
return cellInfo => {
const {columnIndex, key, style, rowIndex} = cellInfo;
const {dataContainer, colMeta} = props;
const {dataContainer, colMeta, filteredIndex} = props;
const column = columns[columnIndex];
const isGhost = column.ghost;

Expand All @@ -500,6 +505,7 @@ function DataTableFactory(HeaderCell: ReturnType<typeof HeaderCellFactory>) {
const type = isGhost ? null : colMeta[column].type;

const lastRowIndex = dataContainer ? dataContainer.numRows() - 1 : 0;
const hasFilteredIndex = Object.keys(filteredIndex ?? {}).length < dataContainer.numRows();

const endCell = columnIndex === columns.length - 1;
const firstCell = columnIndex === 0;
Expand All @@ -509,7 +515,11 @@ function DataTableFactory(HeaderCell: ReturnType<typeof HeaderCellFactory>) {
const cell = (
<div
className={classnames('cell', {
[rowIndex % 2 === 0 ? 'even-row' : 'odd-row']: true,
[filteredIndex?.[rowIndex] && hasFilteredIndex
? 'filtered-row'
: rowIndex % 2 === 0
? 'even-row'
: 'odd-row']: true,
[`row-${rowIndex}`]: true,
'pinned-cell': isPinned,
'first-cell': firstCell,
Expand Down
2 changes: 2 additions & 0 deletions src/styles/src/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ const headerCellStatsBackground = '#F8FAFF';
const headerCellStatsControlBackground = '#EAF0FF';
const headerCellIconColor = '#666666';
const cellBorderColor = '#E0E0E0';
const filteredRowBackground = '#FFFF00';
const evenRowBackground = '#FFFFFF';
const oddRowBackground = '#F7F7F7';
const optionButtonColor = '#6A7485';
Expand Down Expand Up @@ -1510,6 +1511,7 @@ export const theme = {
headerCellStatsControlBackground,
headerCellIconColor,
cellBorderColor,
filteredRowBackground,
evenRowBackground,
oddRowBackground,
pinnedGridBorderColor,
Expand Down

0 comments on commit f35cd60

Please sign in to comment.