ant-design/site/theme/template/Home/RecommendPage.tsx

132 lines
4.1 KiB
TypeScript
Raw Normal View History

2019-12-26 15:27:52 +08:00
import * as React from 'react';
import classNames from 'classnames';
2020-03-04 18:28:20 +08:00
import { FormattedMessage, useIntl } from 'react-intl';
2019-12-26 15:27:52 +08:00
import { Row, Col, Typography } from 'antd';
import './RecommendPage.less';
const { Title, Paragraph } = Typography;
interface Recommend {
title: string;
img: string;
href: string;
popularize?: boolean;
description: string;
}
2020-03-04 18:28:20 +08:00
const LIST_CN: Recommend[] = [
2019-12-26 15:27:52 +08:00
{
title: '树形控件在生产力工具中的设计',
2019-12-26 15:27:52 +08:00
description:
'惊半年实践血泪史3000 字深度好文,一个爱树的设计师手把手教你如何设计「树 」!',
img: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*Z4eXS55fMigAAAAAAAAAAAAAARQnAQ',
href: 'https://zhuanlan.zhihu.com/p/260068653',
2019-12-26 15:27:52 +08:00
popularize: true,
},
{
title: '或许这就是下一代组件库',
2019-12-26 15:27:52 +08:00
description:
'随着 React hooks、Vue composition API 的推出,或许组件库有了新的突破点。',
img: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*SU6hQ5jHVEsAAAAAAAAAAAAAARQnAQ',
href: 'https://zhuanlan.zhihu.com/p/252824872',
2019-12-26 15:27:52 +08:00
},
{
title: 'Ant Design 4.0 的一些杂事儿 - VirtualList 篇',
description:
'在 React 中,我们常说不太需要关注性能问题。然而作为组件库,这些事你就不得不考虑一下。',
img: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*ULOBQroFRMQAAAAAAAAAAAAAARQnAQ',
href: 'https://zhuanlan.zhihu.com/p/237996796',
2019-12-26 15:27:52 +08:00
},
];
2020-03-04 18:28:20 +08:00
const LIST_EN: Recommend[] = [
{
title: "How to Design Tree Component",
description:
'🌲 Surprise! With half-a-year practice of blood and tears, here comes a designer who deeply loves trees to teach you how to design 「tree」component!',
img: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*Z4eXS55fMigAAAAAAAAAAAAAARQnAQ',
href: 'https://zhuanlan.zhihu.com/p/260068653',
2020-03-04 18:28:20 +08:00
popularize: true,
},
{
title: 'Next Generation of Component Library?',
2020-05-23 15:00:18 +08:00
description:
'😎 With the launch of React hooks and Vue composition API, perhaps we have met a new breakthrough point of component libraries.',
img: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*SU6hQ5jHVEsAAAAAAAAAAAAAARQnAQ',
href: 'https://zhuanlan.zhihu.com/p/252824872',
2020-03-04 18:28:20 +08:00
},
{
title: 'Stories about Ant Design 4.0: VirtualList',
description:
"🏃 In React, usually you don't need to focus on performance problems. However, as a component library, we have to think about it.",
img: 'https://gw.alipayobjects.com/mdn/rms_08e378/afts/img/A*ULOBQroFRMQAAAAAAAAAAAAAARQnAQ',
href: 'https://zhuanlan.zhihu.com/p/237996796',
2020-03-04 18:28:20 +08:00
},
];
2019-12-26 15:27:52 +08:00
interface RecommendBlockProps extends Recommend {
main?: boolean;
img: string;
href: string;
}
const RecommendBlock = ({
main,
title,
popularize,
description,
img,
href,
}: RecommendBlockProps) => {
return (
<a
className={classNames('recommend-block', main && 'recommend-block-main')}
href={href}
target="_blank"
rel="noopener noreferrer"
onClick={() => {
if (window.gtag) {
window.gtag('event', '点击', {
event_category: '首页推广',
event_label: href,
});
}
}}
2019-12-26 15:27:52 +08:00
>
<img src={img} alt={title} />
{popularize && (
<span className="recommend-popularize">
<FormattedMessage id="app.home.popularize" />
</span>
)}
<div className="recommend-content">
<Title level={4}>{title}</Title>
<Paragraph style={{ fontSize: 13 }}>{description}</Paragraph>
2019-12-26 15:27:52 +08:00
</div>
</a>
);
};
2020-03-04 18:28:20 +08:00
export default function RecommendPageo() {
const { locale } = useIntl();
const isZhCN = locale === 'zh-CN';
const LIST = isZhCN ? LIST_CN : LIST_EN;
2019-12-26 15:27:52 +08:00
return (
<Row gutter={[24, 24]} style={{ marginBottom: -36 }}>
<Col xs={24} sm={14}>
<RecommendBlock {...LIST[0]} main />
</Col>
<Col xs={24} sm={10}>
<Row gutter={[24, 24]}>
<Col span={24}>
<RecommendBlock {...LIST[1]} />
</Col>
<Col span={24}>
<RecommendBlock {...LIST[2]} />
</Col>
</Row>
</Col>
</Row>
);
}