Skip to content

Commit ab68740

Browse files
authored
feat(Table): add zebraCrossing
close #159
1 parent 320ddee commit ab68740

File tree

6 files changed

+388
-76
lines changed

6 files changed

+388
-76
lines changed

src/components/LocaleProvider/__tests__/__snapshots__/demo.test.js.snap

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2143,11 +2143,18 @@ exports[`LocaleProvider demo -- list 1`] = `
21432143
display: none;
21442144
}
21452145
2146-
.c53 .uc-fe-table table > tbody > .uc-fe-table-row-hover,
2147-
.c53 .uc-fe-table table > tbody > .uc-fe-table-row:hover {
2146+
.c53 .uc-fe-table table > tbody > .uc-fe-table-row-hover > td,
2147+
.c53 .uc-fe-table table > tbody > .uc-fe-table-row:hover > td {
21482148
background-color: #eaf3fd;
21492149
}
21502150
2151+
.c53 .uc-fe-table table > tbody > .uc-fe-table-row-hover > td.uc-fe-table-row-expand-icon-cell,
2152+
.c53 .uc-fe-table table > tbody > .uc-fe-table-row:hover > td.uc-fe-table-row-expand-icon-cell,
2153+
.c53 .uc-fe-table table > tbody > .uc-fe-table-row-hover > td.uc-fe-table-row-select-icon-cell,
2154+
.c53 .uc-fe-table table > tbody > .uc-fe-table-row:hover > td.uc-fe-table-row-select-icon-cell {
2155+
background-color: unset;
2156+
}
2157+
21512158
.c53 .uc-fe-table-scroll-position-left .uc-fe-table-fixed-left {
21522159
box-shadow: none;
21532160
}

src/components/LocaleProvider/__tests__/__snapshots__/index.test.js.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1996,7 +1996,7 @@ exports[`LocaleProvider switch locale 1`] = `
19961996
class="demo-wrap"
19971997
>
19981998
<div
1999-
class="test-table style__TableWrap-djz4q7-0 dNdLKG"
1999+
class="test-table style__TableWrap-djz4q7-0 bTrSkG"
20002000
>
20012001
<div
20022002
class="style__PopupContainer-djz4q7-1 ftgDqG"
@@ -3977,7 +3977,7 @@ exports[`LocaleProvider switch locale 2`] = `
39773977
class="demo-wrap"
39783978
>
39793979
<div
3980-
class="test-table style__TableWrap-djz4q7-0 dNdLKG"
3980+
class="test-table style__TableWrap-djz4q7-0 bTrSkG"
39813981
>
39823982
<div
39833983
class="style__PopupContainer-djz4q7-1 ftgDqG"

src/components/Table/Table.jsx

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,9 @@ class Table extends Component {
176176
}),
177177
/** 定义如何获取每行的键值 */
178178
rowKey: PropTypes.oneOfType([PropTypes.func, PropTypes.string]),
179-
// 自定义表格组件
179+
/** 是否有斑马线,存在子表格时,斑马线样式可能会错乱 */
180+
zebraCrossing: PropTypes.bool,
181+
/** 自定义表格组件,慎用 */
180182
components: PropTypes.shape({
181183
header: PropTypes.shape({
182184
cell: PropTypes.any
@@ -733,6 +735,7 @@ class Table extends Component {
733735
onRow = () => {},
734736
components,
735737
onExpand,
738+
zebraCrossing,
736739
...rest
737740
} = this.props;
738741
if (emptyContent === undefined) {
@@ -765,7 +768,12 @@ class Table extends Component {
765768
locale
766769
}}
767770
>
768-
<TableWrap className={className} style={style} hideExpandIcon={hideExpandIcon}>
771+
<TableWrap
772+
className={className}
773+
style={style}
774+
hideExpandIcon={hideExpandIcon}
775+
zebraCrossing={zebraCrossing}
776+
>
769777
<PopupContainer innerRef={_ref => (this.popupContainer = _ref)} />
770778
<RcTable
771779
{...defaultExpandAllRowsProps}

src/components/Table/__demo__/table.jsx

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ class Demo extends React.Component {
1919
removeLastButOneColumnWidth: false,
2020
showHeader: true,
2121
showPagination: true,
22+
zebraCrossing: false,
2223
scroll: {
2324
x: false,
2425
y: false
@@ -38,7 +39,8 @@ class Demo extends React.Component {
3839
removeLastButOneColumnWidth,
3940
showHeader,
4041
showPagination,
41-
scroll
42+
scroll,
43+
zebraCrossing
4244
} = this.state;
4345
let dataSource = [];
4446
dataSource.length = dataLength;
@@ -80,7 +82,7 @@ class Demo extends React.Component {
8082
delete columns[columnLength - 2].width;
8183
}
8284

83-
const tableProps = { columns, dataSource, showHeader, scroll };
85+
const tableProps = { columns, dataSource, showHeader, scroll, zebraCrossing };
8486
if (rowSelection) {
8587
tableProps.rowSelection = {
8688
fixed: fixedFirstColumn
@@ -207,6 +209,16 @@ class Demo extends React.Component {
207209
}
208210
/>
209211
</Form.Item>
212+
<Form.Item label="zebraCrossing" {...itemLayout}>
213+
<Switch
214+
checked={zebraCrossing}
215+
onChange={zebraCrossing =>
216+
this.setState({
217+
zebraCrossing
218+
})
219+
}
220+
/>
221+
</Form.Item>
210222
</Form>
211223

212224
<div className="demo-wrap">

0 commit comments

Comments
 (0)