Skip to content

Commit 21e3933

Browse files
committed
dynamic header width
1 parent b3da107 commit 21e3933

File tree

5 files changed

+18
-9
lines changed

5 files changed

+18
-9
lines changed

src/components/BrowserRow/BrowserRow.react.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export default class BrowserRow extends Component {
3333
row,
3434
rowValue,
3535
rowWidth,
36+
headerWidth,
3637
selection,
3738
selectRow,
3839
setCopyableValue,
@@ -70,8 +71,8 @@ export default class BrowserRow extends Component {
7071
requiredCols = ['authData'];
7172
}
7273
return (
73-
<div className={styles.tableRow} style={{ minWidth: rowWidth }} onMouseOver={() => onMouseOverRow(obj.id)}>
74-
<span className={styles.rowNumber}>{row + 1}</span>
74+
<div className={styles.tableRow} style={{ width: rowWidth }} onMouseOver={() => onMouseOverRow(obj.id)}>
75+
<span className={styles.rowNumber} style={{width: headerWidth}}>{row + 1}</span>
7576
<span
7677
className={styles.checkCell}
7778
onMouseUp={onMouseUpRowCheckBox}

src/components/DataBrowserHeaderBar/DataBrowserHeaderBar.react.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@ export default class DataBrowserHeaderBar extends React.Component {
2626
isDataLoaded,
2727
setSelectedObjectId,
2828
setCurrent,
29+
headerWidth
2930
} = this.props;
3031
const elements = [
31-
<div key="check" className={[styles.wrap, styles.check].join(' ')}>
32+
<div key="check" className={[styles.wrap, styles.check].join(' ')} style={{ paddingLeft: headerWidth, width: headerWidth + 30 }}>
3233
{readonly ? null : (
3334
<input type="checkbox" checked={selected} onChange={e => selectAll(e.target.checked)} />
3435
)}

src/components/DataBrowserHeaderBar/DataBrowserHeaderBar.scss

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
height: 30px;
5353
vertical-align: top;
5454
text-align: center;
55-
width: 60px;
55+
width: 30px;
5656
background: rgb(114, 111, 133);
5757
padding-left: 30px;
5858
}

src/dashboard/Data/Browser/Browser.scss

-4
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@ body:global(.expanded) {
112112

113113
.rowNumber {
114114
display: inline-block;
115-
width: 30px;
116115
height: 30px;
117116
line-height: 31px;
118117
vertical-align: top;
@@ -123,9 +122,6 @@ body:global(.expanded) {
123122
z-index: 1;
124123
border-bottom: 1px solid #e3e3ea;
125124
background: white;
126-
overflow: hidden;
127-
direction: rtl;
128-
text-overflow: ellipsis;
129125
}
130126

131127
.addRow {

src/dashboard/Data/Browser/BrowserTable.react.js

+12-1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ export default class BrowserTable extends React.Component {
3535
this.tableRef = React.createRef();
3636
this.handleResize = this.handleResize.bind(this);
3737
this.updateMaxWidth = this.updateMaxWidth.bind(this);
38+
this.headerWidth = 34;
3839
}
3940

4041
componentWillReceiveProps(props) {
@@ -121,10 +122,16 @@ export default class BrowserTable extends React.Component {
121122
let editor = null;
122123
let table = <div ref={this.tableRef} />;
123124
if (this.props.data) {
124-
const rowWidth = this.props.order.reduce(
125+
let rowWidth = this.props.order.reduce(
125126
(rowWidth, { visible, width }) => (visible ? rowWidth + width : rowWidth),
126127
this.props.onAddRow ? 210 : 0
127128
) + 30;
129+
130+
this.headerWidth = Math.max(
131+
30,
132+
Math.floor(Math.log10(this.props.data.length + this.props.skip)) * 10
133+
) + 4;
134+
128135
let editCloneRows;
129136
if (this.props.editCloneRows) {
130137
editCloneRows = (
@@ -159,6 +166,7 @@ export default class BrowserTable extends React.Component {
159166
row={index + this.props.skip}
160167
rowValue={this.props.data[index]}
161168
rowWidth={rowWidth}
169+
headerWidth={this.headerWidth}
162170
selection={this.props.selection}
163171
selectRow={this.props.selectRow}
164172
setCurrent={this.props.setCurrent}
@@ -240,6 +248,7 @@ export default class BrowserTable extends React.Component {
240248
readOnlyFields={READ_ONLY}
241249
row={-1}
242250
rowWidth={rowWidth}
251+
headerWidth={this.headerWidth}
243252
selection={this.props.selection}
244253
selectRow={this.props.selectRow}
245254
setCurrent={this.props.setCurrent}
@@ -332,6 +341,7 @@ export default class BrowserTable extends React.Component {
332341
row={i + this.props.skip}
333342
rowValue={this.props.data[i]}
334343
rowWidth={rowWidth}
344+
headerWidth={this.headerWidth}
335345
selection={this.props.selection}
336346
selectRow={this.props.selectRow}
337347
setCurrent={this.props.setCurrent}
@@ -563,6 +573,7 @@ export default class BrowserTable extends React.Component {
563573
isDataLoaded={!this.props.isLoading}
564574
setSelectedObjectId={this.props.setSelectedObjectId}
565575
setCurrent={this.props.setCurrent}
576+
headerWidth={this.headerWidth}
566577
/>
567578
{table}
568579
</div>

0 commit comments

Comments
 (0)