Browse Source

docs: add techui promotion (#27465)

* feat: add techui promotion

* feat: change button to menu

* feat: change TechUI menu position
pull/27473/head
大猫 4 years ago
committed by GitHub
parent
commit
5c0799d5ac
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      components/overview/index.zh-CN.md
  2. 9
      site/theme/template/Layout/Header/Navigation.tsx
  3. 17
      site/theme/template/Layout/Header/index.tsx

2
components/overview/index.zh-CN.md

@ -4,4 +4,4 @@ title: 组件总览
type: 组件总览
---
`antd` 为 Web 应用提供了丰富的基础 UI 组件,我们还将持续探索企业级应用的最佳 UI 实践。除了官方组件,我们也提供了[社区精选组件](/docs/react/recommendation)作为必要的补充。
`antd` 为 Web 应用提供了丰富的基础 UI 组件,我们还将持续探索企业级应用的最佳 UI 实践。除了官方组件,我们也提供了[社区精选组件](/docs/react/recommendation)作为必要的补充,另外如果您是内网用户,欢迎尝试使用 [TechUI](https://techui.alipay.com)

9
site/theme/template/Layout/Header/Navigation.tsx

@ -17,6 +17,7 @@ export interface NavigationProps extends SharedProps {
responsive: null | 'narrow' | 'crowded';
location: { pathname: string; query: any };
directionText: string;
showTechUIButton: boolean;
onLangChange: () => void;
onDirectionChange: () => void;
}
@ -29,6 +30,7 @@ export default ({
responsive,
location,
directionText,
showTechUIButton,
onLangChange,
onDirectionChange,
}: NavigationProps) => {
@ -100,6 +102,13 @@ export default ({
<FormattedMessage id="app.header.menu.resource" />
</Link>
</Menu.Item>
{showTechUIButton && (
<Menu.Item key="tech-ui">
<a href="https://techui.alipay.com" target="__blank" rel="noopener noreferrer">
TechUI
</a>
</Menu.Item>
)}
{isZhCN && !isGitee && (
<Menu.Item key="mirror">
<a href="https://ant-design.gitee.io"></a>

17
site/theme/template/Layout/Header/index.tsx

@ -12,6 +12,7 @@ import More from './More';
import Navigation from './Navigation';
import Github from './Github';
import SiteContext from '../SiteContext';
import { ping } from '../../utils';
import './index.less';
@ -61,15 +62,19 @@ interface HeaderState {
menuVisible: boolean;
windowWidth: number;
searching: boolean;
showTechUIButton: boolean;
}
class Header extends React.Component<HeaderProps, HeaderState> {
static contextType = SiteContext;
pingTimer: NodeJS.Timeout;
state = {
menuVisible: false,
windowWidth: 1400,
searching: false,
showTechUIButton: false,
};
componentDidMount() {
@ -79,10 +84,19 @@ class Header extends React.Component<HeaderProps, HeaderState> {
window.addEventListener('resize', this.onWindowResize);
this.onWindowResize();
this.pingTimer = ping(status => {
if (status !== 'timeout' && status !== 'error') {
this.setState({
showTechUIButton: true,
});
}
});
}
componentWillUnmount() {
window.removeEventListener('resize', this.onWindowResize);
clearTimeout(this.pingTimer);
}
onWindowResize = () => {
@ -179,7 +193,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
return (
<SiteContext.Consumer>
{({ isMobile }) => {
const { menuVisible, windowWidth, searching } = this.state;
const { menuVisible, windowWidth, searching, showTechUIButton } = this.state;
const { direction } = this.context;
const {
location,
@ -232,6 +246,7 @@ class Header extends React.Component<HeaderProps, HeaderState> {
location={location}
responsive={responsive}
isMobile={isMobile}
showTechUIButton={showTechUIButton}
pathname={pathname}
directionText={this.getNextDirectionText()}
onLangChange={this.onLangChange}

Loading…
Cancel
Save