Add highlightIndex.

This commit is contained in:
Haifeng Luo 2022-05-08 18:50:44 +08:00
parent 773c742a61
commit 8ca78492c1
2 changed files with 15 additions and 1 deletions

View File

@ -120,6 +120,17 @@ class LabelTable extends React.Component {
}, },
]; ];
let highlightIndex = -1;
table.forEach((label, i) => {
if (highlightIndex === -1) {
if (label.timestamp > this.props.currentTime) {
if (i > 0) {
highlightIndex = i - 1;
}
}
}
});
return ( return (
<Table rowKey="timestamp" columns={columns} dataSource={table} size="middle" bordered pagination={false} <Table rowKey="timestamp" columns={columns} dataSource={table} size="middle" bordered pagination={false}
title={() => ( title={() => (
@ -133,6 +144,9 @@ class LabelTable extends React.Component {
} }
</div> </div>
)} )}
rowClassName={(record, index) => {
return (highlightIndex === index) ? "alert-row" : "";
}}
/> />
); );
} }

View File

@ -35,7 +35,7 @@ code {
} }
.alert-row { .alert-row {
background: #ffccc7; background: rgba(92,48,125,0.55);
} }
/*http://react-china.org/t/topic/33846/3*/ /*http://react-china.org/t/topic/33846/3*/