yapi/client/components/Intro/Intro.js

97 lines
2.4 KiB
JavaScript
Raw Normal View History

2017-07-17 21:11:58 +08:00
import React from 'react'
import PropTypes from 'prop-types'
2017-07-28 20:35:44 +08:00
import { Icon } from 'antd'
2017-07-17 21:11:58 +08:00
import "./Intro.scss"
import { OverPack } from 'rc-scroll-anim'
import TweenOne from 'rc-tween-one'
import QueueAnim from 'rc-queue-anim';
2017-07-17 21:11:58 +08:00
const IntroPart = (props) =>(
2017-07-28 20:35:44 +08:00
<li className="switch-content">
2017-07-17 21:11:58 +08:00
<div className="icon-switch">
2017-07-25 17:56:04 +08:00
<Icon type={props.iconType} />
2017-07-17 21:11:58 +08:00
</div>
2017-07-28 20:35:44 +08:00
<div className="text-switch">
2017-07-17 21:11:58 +08:00
<p><b>{props.title}</b></p>
<p>{props.des}</p>
</div>
2017-07-28 20:35:44 +08:00
</li>
2017-07-17 21:11:58 +08:00
)
IntroPart.propTypes = {
title : PropTypes.string,
2017-07-25 17:56:04 +08:00
des : PropTypes.string,
iconType : PropTypes.string
2017-07-17 21:11:58 +08:00
}
class Intro extends React.Component{
constructor(props){
super(props);
}
static propTypes={
intro : PropTypes.shape({
title:PropTypes.string,
des:PropTypes.string,
img:PropTypes.string,
detail:PropTypes.arrayOf(PropTypes.shape({
title:PropTypes.string,
des:PropTypes.string
}))
}),
className : PropTypes.string
2017-07-17 21:11:58 +08:00
}
render(){
const { intro } = this.props;
const id = "motion";
const animType = {
queue: 'right',
one: { x: '-=30', opacity: 0, type: 'from' }
};
2017-07-17 21:11:58 +08:00
return(
<div className="intro-container">
<OverPack
playScale="0.3"
>
<TweenOne
animation={animType.one}
key={`${id}-img`}
resetStyleBool
id={`${id}-imgWrapper`}
className="imgWrapper"
>
<div className="img-container" id={`${id}-img-container`}>
<img src={intro.img}/>
2017-07-17 21:11:58 +08:00
</div>
</TweenOne>
<QueueAnim
type={animType.queue}
key={`${id}-text`}
leaveReverse
ease={['easeOutCubic', 'easeInCubic']}
id={`${id}-textWrapper`}
className={`${id}-text des-container textWrapper`}
>
<div key={`${id}-des-content`}>
2017-07-17 21:11:58 +08:00
<div className="des-title">
{intro.title}
</div>
<div className="des-detail">
{intro.des}
</div>
</div>
2017-07-28 20:35:44 +08:00
<ul className="des-switch" key={`${id}-des-switch`}>
2017-07-17 21:11:58 +08:00
{intro.detail.map(function(item,i){
2017-07-25 17:56:04 +08:00
return(<IntroPart key={i} title={item.title} des={item.des} iconType={item.iconType}/>)
2017-07-17 21:11:58 +08:00
})}
2017-07-28 20:35:44 +08:00
</ul>
</QueueAnim>
</OverPack>
2017-07-17 21:11:58 +08:00
</div>
)
}
}
export default Intro;