From 89c3e330f221479b7eb43b6003d2c1902940126a Mon Sep 17 00:00:00 2001 From: Filip Barl Date: Mon, 12 Feb 2018 13:33:40 +0100 Subject: [PATCH] Use relative positioning of Table view tables. --- client/app/scripts/charts/nodes-grid.js | 22 +++++++++++++--------- client/app/scripts/constants/styles.js | 5 +---- client/app/scripts/selectors/canvas.js | 11 +++++++++++ client/app/styles/_base.scss | 6 +----- 4 files changed, 26 insertions(+), 18 deletions(-) diff --git a/client/app/scripts/charts/nodes-grid.js b/client/app/scripts/charts/nodes-grid.js index a54e8745cf..2ba14e61cb 100644 --- a/client/app/scripts/charts/nodes-grid.js +++ b/client/app/scripts/charts/nodes-grid.js @@ -9,7 +9,7 @@ import { shownNodesSelector } from '../selectors/node-filters'; import { trackAnalyticsEvent } from '../utils/tracking-utils'; import { TABLE_VIEW_MODE } from '../constants/naming'; -import { canvasMarginsSelector, canvasHeightSelector } from '../selectors/canvas'; +import { windowHeightSelector } from '../selectors/canvas'; import { searchNodeMatchesSelector } from '../selectors/search'; import { getNodeColor } from '../utils/color-utils'; @@ -86,6 +86,7 @@ class NodesGrid extends React.Component { this.onClickRow = this.onClickRow.bind(this); this.onSortChange = this.onSortChange.bind(this); + this.saveTableRef = this.saveTableRef.bind(this); } onClickRow(ev, node) { @@ -101,16 +102,20 @@ class NodesGrid extends React.Component { this.props.sortOrderChanged(sortedBy, sortedDesc); } + saveTableRef(ref) { + this.tableRef = ref; + } + render() { const { - nodes, height, gridSortedBy, gridSortedDesc, canvasMargins, - searchNodeMatches, searchQuery + nodes, gridSortedBy, gridSortedDesc, searchNodeMatches, searchQuery, windowHeight } = this.props; + const height = + this.tableRef ? windowHeight - this.tableRef.getBoundingClientRect().top - 30 : 0; const cmpStyle = { height, - marginTop: canvasMargins.top, - paddingLeft: canvasMargins.left, - paddingRight: canvasMargins.right, + paddingLeft: 40, + paddingRight: 40, }; // TODO: What are 24 and 18? Use a comment or extract into constants. const tbodyHeight = height - 24 - 18; @@ -130,7 +135,7 @@ class NodesGrid extends React.Component { }; return ( -
+
{nodes.size > 0 && state.getIn(['viewport', 'height']), + ], + () => window.innerHeight, +); + export const canvasMarginsSelector = createSelector( [ state => state.get('topologyViewMode'), diff --git a/client/app/styles/_base.scss b/client/app/styles/_base.scss index 94e083cdd0..6352e295e4 100644 --- a/client/app/styles/_base.scss +++ b/client/app/styles/_base.scss @@ -103,7 +103,7 @@ a { font-size: 0.7rem; justify-content: center; padding: 5px; - position: absolute; + position: fixed; bottom: 11px; button { @@ -2001,10 +2001,6 @@ a { // .nodes-grid { - // TODO: Would be good to have relative positioning here. - position: absolute; - top: 0; - tr { border-radius: 6px; }