1
1
import PropTypes from 'prop-types' ;
2
2
import React , { Component } from 'react' ;
3
- import styled , { css } from 'styled-components' ;
3
+ import styled from 'styled-components' ;
4
4
import isEqual from 'lodash/isEqual' ;
5
5
import TableContext from './context' ;
6
6
import Loader from './Loader' ;
@@ -129,7 +129,6 @@ class Table extends Component {
129
129
return (
130
130
< TableContext . Provider value = { context } >
131
131
< WrapperStyle
132
- minimalist = { minimalist }
133
132
width = { tableWidth }
134
133
height = { tableHeight }
135
134
{ ...props }
@@ -144,13 +143,22 @@ class Table extends Component {
144
143
} )
145
144
: children
146
145
}
146
+ { ! minimalist && (
147
+ < React . Fragment >
148
+ < BorderTop />
149
+ < BorderRight />
150
+ < BorderBottom />
151
+ < BorderLeft />
152
+ </ React . Fragment >
153
+ ) }
147
154
</ WrapperStyle >
148
155
</ TableContext . Provider >
149
156
) ;
150
157
}
151
158
}
152
159
153
160
const WrapperStyle = styled . div `
161
+ position: relative;
154
162
display: flex;
155
163
flex-direction: column;
156
164
line-height: 20px;
@@ -160,26 +168,45 @@ const WrapperStyle = styled.div`
160
168
*, *:before, *:after {
161
169
box-sizing: inherit;
162
170
}
163
-
164
- ${ props => ! props . minimalist && css `
165
- border-top: 1px solid #ddd;
166
- border-bottom: 1px solid #ddd;
167
- ` }
168
-
169
- ${ props => props . minimalist && css `
170
- border: 0;
171
- ` }
172
171
` ;
173
172
174
173
const EmptyBodyStyle = styled . div `
175
174
text-align: center;
176
175
padding: 44px 12px;
177
176
color: #999;
177
+ ` ;
178
+
179
+ const VerticalLine = styled . div `
180
+ border: none;
181
+ border-left: 1px solid #ddd;
182
+ height: 100%;
183
+ width: 1px;
184
+ ` ;
178
185
179
- ${ props => ! props . minimalist && css `
180
- border-left: 1px solid #ddd;
181
- border-right: 1px solid #ddd;
182
- ` }
186
+ const HorizontalLine = styled . div `
187
+ border: none;
188
+ border-top: 1px solid #ddd;
189
+ height: 1px;
190
+ width: 100%;
191
+ ` ;
192
+
193
+ const BorderTop = styled ( HorizontalLine ) `
194
+ position: absolute;
195
+ top: 0;
196
+ ` ;
197
+ const BorderRight = styled ( VerticalLine ) `
198
+ position: absolute;
199
+ top: 0;
200
+ right: 0;
201
+ ` ;
202
+ const BorderBottom = styled ( HorizontalLine ) `
203
+ position: absolute;
204
+ bottom: 0;
205
+ ` ;
206
+ const BorderLeft = styled ( VerticalLine ) `
207
+ position: absolute;
208
+ top: 0;
209
+ left: 0;
183
210
` ;
184
211
185
212
export default Table ;
0 commit comments