|
13 | 13 | * limitations under the License.
|
14 | 14 | */
|
15 | 15 |
|
16 |
| -import React, { Component } from 'react'; |
| 16 | +/** @jsx jsx */ |
| 17 | + |
| 18 | +import { Component } from 'react'; |
17 | 19 | import PropTypes from 'prop-types';
|
18 | 20 | import styled from '@emotion/styled';
|
19 |
| -import { css } from '@emotion/core'; |
| 21 | +import { jsx, css } from '@emotion/core'; |
20 | 22 |
|
21 | 23 | import TableHead from './components/TableHead';
|
22 | 24 | import TableBody from './components/TableBody';
|
@@ -91,7 +93,7 @@ const noShadowStyles = ({ noShadow }) =>
|
91 | 93 | `;
|
92 | 94 |
|
93 | 95 | const ScrollContainer = styled.div(containerStyles);
|
94 |
| -const Container = styled.div` |
| 96 | +const ShadowContainer = styled.div` |
95 | 97 | ${shadowSingle};
|
96 | 98 | ${noShadowStyles};
|
97 | 99 | `;
|
@@ -158,31 +160,41 @@ class Table extends Component {
|
158 | 160 | } = this.props;
|
159 | 161 | const { sortDirection, sortHover, sortedRow } = this.state;
|
160 | 162 |
|
| 163 | + /** |
| 164 | + * The position: relative; container is necessary because ShadowContainer |
| 165 | + * is a position: absolute; element |
| 166 | + */ |
161 | 167 | return (
|
162 |
| - <Container noShadow={noShadow}> |
163 |
| - <ScrollContainer rowHeaders={rowHeaders}> |
164 |
| - <StyledTable |
165 |
| - rowHeaders={rowHeaders} |
166 |
| - borderCollapsed={borderCollapsed} |
167 |
| - > |
168 |
| - <TableHead |
169 |
| - sortDirection={sortDirection} |
170 |
| - sortedRow={sortedRow} |
171 |
| - onSortBy={this.onSortBy} |
172 |
| - onSortEnter={this.onSortEnter} |
173 |
| - onSortLeave={this.onSortLeave} |
174 |
| - headers={headers} |
175 |
| - rowHeaders={rowHeaders} |
176 |
| - /> |
177 |
| - <TableBody |
178 |
| - rows={this.getSortedRows()} |
| 168 | + <div |
| 169 | + css={css` |
| 170 | + position: relative; |
| 171 | + `} |
| 172 | + > |
| 173 | + <ShadowContainer noShadow={noShadow}> |
| 174 | + <ScrollContainer rowHeaders={rowHeaders}> |
| 175 | + <StyledTable |
179 | 176 | rowHeaders={rowHeaders}
|
180 |
| - sortHover={sortHover} |
181 |
| - onRowClick={onRowClick} |
182 |
| - /> |
183 |
| - </StyledTable> |
184 |
| - </ScrollContainer> |
185 |
| - </Container> |
| 177 | + borderCollapsed={borderCollapsed} |
| 178 | + > |
| 179 | + <TableHead |
| 180 | + sortDirection={sortDirection} |
| 181 | + sortedRow={sortedRow} |
| 182 | + onSortBy={this.onSortBy} |
| 183 | + onSortEnter={this.onSortEnter} |
| 184 | + onSortLeave={this.onSortLeave} |
| 185 | + headers={headers} |
| 186 | + rowHeaders={rowHeaders} |
| 187 | + /> |
| 188 | + <TableBody |
| 189 | + rows={this.getSortedRows()} |
| 190 | + rowHeaders={rowHeaders} |
| 191 | + sortHover={sortHover} |
| 192 | + onRowClick={onRowClick} |
| 193 | + /> |
| 194 | + </StyledTable> |
| 195 | + </ScrollContainer> |
| 196 | + </ShadowContainer> |
| 197 | + </div> |
186 | 198 | );
|
187 | 199 | }
|
188 | 200 | }
|
|
0 commit comments