Skip to content

Commit 2ed6b39

Browse files
committed
Moved functional styles out of styles.css and into components (via inline styles
1 parent 863cd87 commit 2ed6b39

File tree

6 files changed

+27
-39
lines changed

6 files changed

+27
-39
lines changed

README.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,13 +91,14 @@ ES6, CommonJS, and UMD builds are available with each distribution.
9191
For example:
9292

9393
```js
94-
// Make sure to import default styles.
94+
// If you're using the Table component you'll need to include the default styles.
9595
// This only needs to be done once; probably during your application's bootstrapping process.
96+
// Grid and List base styles are purely functional and so they're all inline.
9697
import 'react-virtualized/styles.css';
9798

9899
// Then you can import any react-virtualized components you need.
99-
// Tree-shaking is supported with ES6 or CommonJS usage.
100-
import { Grid } from 'react-virtualized'
100+
// Tree-shaking is supported with ES6 modules (`jsnext:main` package target).
101+
import { Table } from 'react-virtualized'
101102
```
102103

103104
Alternately you can load a global-friendly UMD build:

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"description": "React components for efficiently rendering large, scrollable lists and tabular data",
44
"author": "Brian Vaughn <brian.david.vaughn@gmail.com>",
55
"user": "bvaughn",
6-
"version": "8.0.0-rc.1",
6+
"version": "8.0.0-rc.2",
77
"homepage": "https://github.com/bvaughn/react-virtualized",
88
"main": "dist/commonjs/index.js",
99
"jsnext:main": "dist/es/index.js",

source/Collection/CollectionView.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -351,8 +351,13 @@ export default class CollectionView extends Component {
351351
}) : []
352352

353353
const collectionStyle = {
354+
boxSizing: 'border-box',
354355
height: autoHeight ? 'auto' : height,
355-
width
356+
overflow: 'auto',
357+
position: 'relative',
358+
webkitOverflowScrolling: 'touch',
359+
width,
360+
willChange: 'transform'
356361
}
357362

358363
// Force browser to hide scrollbars when we know they aren't necessary.
@@ -389,6 +394,7 @@ export default class CollectionView extends Component {
389394
height: totalHeight,
390395
maxHeight: totalHeight,
391396
maxWidth: totalWidth,
397+
overflow: 'hidden',
392398
pointerEvents: isScrolling ? 'none' : '',
393399
width: totalWidth
394400
}}

source/Grid/Grid.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,12 @@ export default class Grid extends Component {
492492
const { isScrolling } = this.state
493493

494494
const gridStyle = {
495+
boxSizing: 'border-box',
495496
height: autoHeight ? 'auto' : height,
496-
width
497+
position: 'relative',
498+
width,
499+
webkitOverflowScrolling: 'touch',
500+
willChange: 'transform'
497501
}
498502

499503
const totalColumnsWidth = this._columnSizeAndPositionManager.getTotalSize()
@@ -548,6 +552,7 @@ export default class Grid extends Component {
548552
height: totalRowsHeight,
549553
maxWidth: totalColumnsWidth,
550554
maxHeight: totalRowsHeight,
555+
overflow: 'hidden',
551556
pointerEvents: isScrolling ? 'none' : ''
552557
}}
553558
>

source/Table/Table.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,12 @@ export default class Table extends Component {
266266
// Precompute and cache column styles before rendering rows and columns to speed things up
267267
this._cachedColumnStyles = []
268268
React.Children.toArray(children).forEach((column, index) => {
269-
this._cachedColumnStyles[index] = this._getFlexStyleForColumn(column, column.props.style)
269+
const flexStyles = this._getFlexStyleForColumn(column, column.props.style)
270+
271+
this._cachedColumnStyles[index] = {
272+
...flexStyles,
273+
overflow: 'hidden'
274+
}
270275
})
271276

272277
// Note that we specify :numChildren, :scrollbarWidth, :sortBy, and :sortDirection as properties on Grid even though these have nothing to do with Grid.
@@ -283,6 +288,7 @@ export default class Table extends Component {
283288
style={{
284289
...rowStyleObject,
285290
height: headerHeight,
291+
overflow: 'hidden',
286292
paddingRight: scrollbarWidth,
287293
width: width
288294
}}
@@ -458,6 +464,7 @@ export default class Table extends Component {
458464
...style,
459465
...rowStyleObject,
460466
height: this._getRowHeight(index),
467+
overflow: 'hidden',
461468
paddingRight: scrollbarWidth
462469
}
463470

source/styles.css

Lines changed: 1 addition & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,17 @@
11
/* Collection default theme */
22

33
.ReactVirtualized__Collection {
4-
position: relative;
5-
overflow: auto;
6-
-webkit-overflow-scrolling: touch;
7-
8-
/* Without this property, Chrome repaints the entire Collection any time a new row or column is added.
9-
Firefox only repaints the new row or column (regardless of this property).
10-
Safari and IE don't support the property at all. */
11-
will-change: transform;
124
}
135

146
.ReactVirtualized__Collection__innerScrollContainer {
15-
box-sizing: border-box;
16-
overflow: hidden;
177
}
188

199
/* Grid default theme */
2010

2111
.ReactVirtualized__Grid {
22-
position: relative;
23-
overflow: auto;
24-
-webkit-overflow-scrolling: touch;
25-
26-
/* Without this property, Chrome repaints the entire Grid any time a new row or column is added.
27-
Firefox only repaints the new row or column (regardless of this property).
28-
Safari and IE don't support the property at all. */
29-
will-change: transform;
3012
}
3113

3214
.ReactVirtualized__Grid__innerScrollContainer {
33-
box-sizing: border-box;
34-
overflow: hidden;
35-
position: relative;
3615
}
3716

3817
/* Table default theme */
@@ -41,8 +20,6 @@
4120
}
4221

4322
.ReactVirtualized__Table__Grid {
44-
overflow-x: hidden;
45-
box-sizing: border-box;
4623
}
4724

4825
.ReactVirtualized__Table__headerRow {
@@ -51,17 +28,14 @@
5128
display: flex;
5229
flex-direction: row;
5330
align-items: center;
54-
overflow: hidden;
55-
box-sizing: border-box;
5631
}
5732
.ReactVirtualized__Table__row {
5833
display: flex;
5934
flex-direction: row;
6035
align-items: center;
61-
overflow: hidden;
6236
}
6337

64-
.ReactVirtualized__Table__headerTruncatedText {
38+
.ReactVirtualized__Table__headerTruncatedText {
6539
display: inline-block;
6640
max-width: 100%;
6741
white-space: nowrap;
@@ -75,7 +49,6 @@
7549
min-width: 0px;
7650
}
7751
.ReactVirtualized__Table__rowColumn {
78-
overflow: hidden;
7952
text-overflow: ellipsis;
8053
white-space: nowrap;
8154
}
@@ -102,8 +75,4 @@
10275
/* List default theme */
10376

10477
.ReactVirtualized__List {
105-
position: relative;
106-
overflow-y: auto;
107-
overflow-x: hidden;
108-
-webkit-overflow-scrolling: touch;
10978
}

0 commit comments

Comments
 (0)