From 080edb380d3b2b35fe9584b0d67783b8c2b4fe90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dandelion=20Man=C3=A9?= Date: Mon, 13 Aug 2018 19:11:19 -0700 Subject: [PATCH] TableRows can create vertical padding (#656) This commit adds the `showPadding` prop to `TableRow`s. If showPadding is true, then the row will have vertical padding above the row, and below the last child of the row. The padding will match the background color of the given row. The padding is implemented as extra `tr` elements that themselves contain empty tds. Test plan: The new behavior is pretty thoroughly covered by new unit tests. Additionally, if you want to see padding in the live UI, you can apply the following (slightly contrived) diff. ``` diff --git a/src/app/credExplorer/pagerankTable/Connection.js b/src/app/credExplorer/pagerankTable/Connection.js index 3a882cd..633525b 100644 --- a/src/app/credExplorer/pagerankTable/Connection.js +++ b/src/app/credExplorer/pagerankTable/Connection.js @@ -70,7 +70,7 @@ export class ConnectionRow extends React.PureComponent { depth={depth} description={connectionView} connectionProportion={connectionProportion} - showPadding={false} + showPadding={depth % 3 === 0} score={sourceScore} > { depth={depth} description={connectionView} connectionProportion={connectionProportion} + showPadding={false} score={sourceScore} > { description={description} connectionProportion={null} score={score} + showPadding={false} > diff --git a/src/app/credExplorer/pagerankTable/TableRow.js b/src/app/credExplorer/pagerankTable/TableRow.js index d7dc59f..764d348 100644 --- a/src/app/credExplorer/pagerankTable/TableRow.js +++ b/src/app/credExplorer/pagerankTable/TableRow.js @@ -15,6 +15,7 @@ type TableRowProps = {| +score: number, // Children to show when the row is expanded +children: ReactNode, + +showPadding: boolean, |}; type TableRowState = {| expanded: boolean, @@ -40,18 +41,18 @@ export class TableRow extends React.PureComponent< connectionProportion, score, children, + showPadding, } = this.props; const {expanded} = this.state; const percent = connectionProportion == null ? "" : (connectionProportion * 100).toFixed(2) + "%"; + const backgroundColor = `rgba(0,143.4375,0,${1 - 0.9 ** depth})`; return ( - + {showPadding && } +