Content7.jsx
3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import React from 'react';
import TweenOne from 'rc-tween-one';
import OverPack from 'rc-scroll-anim/lib/ScrollOverPack';
import { Tabs, Icon, Row, Col } from 'antd';
const TabPane = Tabs.TabPane;
class Content7 extends React.Component {
constructor(props) {
super(props);
this.state = {
current: 1,
};
}
onChange = (key) => {
this.setState({ current: parseFloat(key) });
};
getBlockChildren = (item, i) => {
const { tag, content } = item;
const { text, img } = content;
const textChildren = text.children;
const { icon } = tag;
const iconChildren = icon.children;
const tagText = tag.text;
return (
<TabPane
key={i + 1}
tab={(
<div className={tag.className}>
<Icon type={iconChildren} className={icon.className} />
<div {...tagText}>{tagText.children}</div>
</div>
)}
className={item.className}
>
<TweenOne.TweenOneGroup
enter={{
y: 30,
delay: 300,
opacity: 0,
type: 'from',
ease: 'easeOutQuad',
}}
leave={null}
component=""
>
{this.state.current === i + 1 && (
<Row
key="content"
className={content.className}
gutter={content.gutter}
>
<Col className={text.className} xs={text.xs} md={text.md}>
{textChildren}
</Col>
<Col className={img.className} xs={img.xs} md={img.md}>
<img src={img.children} width="100%" alt="img" />
</Col>
</Row>
)}
</TweenOne.TweenOneGroup>
</TabPane>
);
};
render() {
const { ...props } = this.props;
const { dataSource } = props;
delete props.dataSource;
delete props.isMobile;
const tabsChildren = dataSource.block.children.map(this.getBlockChildren);
return (
<div {...props} {...dataSource.wrapper}>
<div {...dataSource.page}>
<div {...dataSource.titleWrapper}>
{dataSource.titleWrapper.children.map((item, i) => React.createElement(
item.name.indexOf('title') === 0 ? 'h1' : 'div',
{ key: i.toString(), ...item },
item.children.match(
/\.(svg|gif|jpg|jpeg|png|JPG|PNG|GIF|JPEG)$/
)
? React.createElement('img', {
src: item.children,
alt: 'img',
})
: item.children
)
)}
</div>
<OverPack {...dataSource.OverPack}>
<TweenOne.TweenOneGroup
key="tabs"
enter={{
y: 30,
opacity: 0,
delay: 200,
type: 'from',
}}
leave={{ y: 30, opacity: 0 }}
{...dataSource.tabsWrapper}
>
<Tabs
key="tabs"
onChange={this.onChange}
activeKey={`${this.state.current}`}
{...dataSource.block}
>
{tabsChildren}
</Tabs>
</TweenOne.TweenOneGroup>
</OverPack>
</div>
</div>
);
}
}
export default Content7;