ant-design/site/theme/template/Home/Banner.jsx

95 lines
3.4 KiB
React
Raw Normal View History

2016-03-03 17:23:08 +08:00
import React from 'react';
2018-01-04 20:00:38 +08:00
import PropTypes from 'prop-types';
import TweenOne from 'rc-tween-one';
2016-03-30 19:14:09 +08:00
import QueueAnim from 'rc-queue-anim';
2018-01-04 20:00:38 +08:00
import ScrollParallax from 'rc-scroll-anim/lib/ScrollParallax';
2018-01-08 12:16:59 +08:00
import { Link } from 'bisheng/router';
2018-01-04 20:00:38 +08:00
import { FormattedMessage } from 'react-intl';
2018-01-05 16:14:59 +08:00
import GitHubButton from 'react-github-button';
2018-01-04 20:00:38 +08:00
import BannerImage from './BannerImage';
2018-01-08 12:16:59 +08:00
import * as utils from '../utils';
2016-03-03 17:23:08 +08:00
2018-01-04 20:00:38 +08:00
const loop = {
duration: 3000,
yoyo: true,
repeat: -1,
};
2016-03-03 17:23:08 +08:00
2018-01-04 20:00:38 +08:00
class Banner extends React.PureComponent {
2018-01-08 12:16:59 +08:00
static contextTypes = {
intl: PropTypes.object.isRequired,
}
2018-01-04 20:00:38 +08:00
static propTypes = {
className: PropTypes.string,
}
static defaultProps = {
className: 'banner',
}
render() {
2018-01-05 17:54:02 +08:00
const { className, isMobile } = this.props;
2018-01-08 12:16:59 +08:00
const { locale } = this.context.intl;
const isZhCN = locale === 'zh-CN';
2018-01-04 20:00:38 +08:00
return (
<div className="home-page-wrapper banner-wrapper" id="banner">
<div className="banner-bg-wrapper">
<svg width="400px" height="576px" viewBox="0 0 400 576" fill="none">
<TweenOne component="g" animation={[{ opacity: 0, type: 'from' }, { ...loop, y: 15 }]}>
<ellipse id="Oval-9-Copy-4" cx="100" cy="100" rx="6" ry="6" stroke="#2F54EB" strokeWidth="1.6" />
</TweenOne>
<TweenOne component="g" animation={[{ opacity: 0, type: 'from' }, { ...loop, y: -15 }]}>
2018-01-05 16:14:59 +08:00
<g transform="translate(200 450)">
2018-01-04 20:00:38 +08:00
<g style={{ transformOrigin: '50% 50%', transform: 'rotate(-340deg)' }}>
<rect stroke="#FADB14" strokeWidth="1.6" width="9" height="9" />
</g>
</g>
</TweenOne>
</svg>
<ScrollParallax location="banner" className="banner-bg" animation={{ playScale: [1, 1.5], rotate: 0 }} />
</div>
<QueueAnim className={`${className} page`} type="alpha" delay={150}>
2018-01-05 17:54:02 +08:00
{isMobile && (
2018-01-04 20:00:38 +08:00
<div className="img-wrapper" key="image">
<BannerImage />
</div>)}
<QueueAnim
className="text-wrapper"
key="text"
type="bottom"
>
<h1 key="h1">
Ant Design
</h1>
<p key="p">
<FormattedMessage id="app.home.introduce" />
</p>
2018-01-05 18:04:55 +08:00
{!isMobile && (
2018-01-08 12:16:59 +08:00
<div key="buttons" style={{ marginTop: 24 }}>
<Link className="banner-btn components" to={utils.getLocalizedPathname('/docs/react/introduce', isZhCN)}>
<FormattedMessage id="app.home.getting-started" />
</Link>
<Link className="banner-btn language" to={utils.getLocalizedPathname('/docs/spec/introduce', isZhCN)}>
<FormattedMessage id="app.home.design-language" />
</Link>
<div style={{ display: 'inline-block' }}>
<GitHubButton
key="github-button"
type="stargazers"
namespace="ant-design"
repo="ant-design"
/>
</div>
2018-01-05 18:04:55 +08:00
</div>
)}
2018-01-04 20:00:38 +08:00
</QueueAnim>
2018-01-05 17:54:02 +08:00
{!isMobile && (
2018-01-04 20:00:38 +08:00
<div className="img-wrapper" key="image">
<ScrollParallax location="banner" component={BannerImage} animation={{ playScale: [1, 1.5], y: 80 }} />
</div>)}
</QueueAnim>
2018-01-04 20:00:38 +08:00
</div>
);
}
2016-03-03 17:23:08 +08:00
}
2018-01-04 20:00:38 +08:00
export default Banner;