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

112 lines
3.6 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';
import { Button } from 'antd';
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-12-07 16:17:45 +08:00
};
2018-01-04 20:00:38 +08:00
static propTypes = {
className: PropTypes.string,
2018-12-07 16:17:45 +08:00
};
2018-01-04 20:00:38 +08:00
static defaultProps = {
className: 'banner',
2018-12-07 16:17:45 +08:00
};
2018-01-04 20:00:38 +08:00
render() {
2018-01-05 17:54:02 +08:00
const { className, isMobile } = this.props;
2018-12-07 16:17:45 +08:00
const {
intl: { locale },
} = this.context;
2018-01-08 12:16:59 +08:00
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 cx="100" cy="100" rx="6" ry="6" stroke="#2F54EB" strokeWidth="1.6" />
2018-01-04 20:00:38 +08:00
</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>
2018-12-07 16:17:45 +08:00
<ScrollParallax
location="banner"
className="banner-bg"
animation={{ playScale: [1, 1.5], rotate: 0 }}
/>
2018-01-04 20:00:38 +08:00
</div>
<QueueAnim className={`${className} page`} type="alpha" delay={150}>
2018-12-07 16:17:45 +08:00
{isMobile && (
<div className="img-wrapper" key="image">
<BannerImage />
</div>
)}
<QueueAnim className="text-wrapper" key="text" type="bottom">
<h1 key="h1">Ant Design</h1>
2018-01-04 20:00:38 +08:00
<p key="p">
<FormattedMessage id="app.home.introduce" />
</p>
2018-05-12 14:02:34 +08:00
<div className="banner-btns" key="buttons">
<Link to={utils.getLocalizedPathname('/docs/react/introduce', isZhCN)}>
<Button type="primary" className="banner-btn components">
<FormattedMessage id="app.home.getting-started" />
</Button>
2018-05-12 14:02:34 +08:00
</Link>
<Link
to={utils.getLocalizedPathname('/docs/spec/introduce', isZhCN)}
style={{ marginLeft: 16 }}
>
<Button className="banner-btn language">
<FormattedMessage id="app.home.design-language" />
</Button>
2018-05-12 14:02:34 +08:00
</Link>
{!isMobile && (
2018-01-09 14:27:56 +08:00
<GitHubButton
style={{ marginLeft: 16 }}
2018-01-09 14:27:56 +08:00
key="github-button"
size="large"
type="stargazers"
namespace="ant-design"
repo="ant-design"
/>
2018-05-12 14:02:34 +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">
2018-12-07 16:17:45 +08:00
<ScrollParallax
location="banner"
component={BannerImage}
animation={{ playScale: [1, 1.5], y: 80 }}
/>
2018-05-12 14:02:34 +08:00
</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;