ant-design/site/theme/template/Layout/Header.jsx

344 lines
9.5 KiB
React
Raw Normal View History

import React from 'react';
import PropTypes from 'prop-types';
2019-12-26 15:27:52 +08:00
import GitHubButton from 'react-github-button';
2017-01-17 15:24:13 +08:00
import { Link } from 'bisheng/router';
2019-08-08 12:35:48 +08:00
import { FormattedMessage, injectIntl } from 'react-intl';
2016-04-28 15:42:02 +08:00
import classNames from 'classnames';
2019-12-26 15:27:52 +08:00
import { SearchOutlined, MenuOutlined } from '@ant-design/icons';
2019-12-31 14:52:53 +08:00
import { Select, Menu, Row, Col, Popover, Input, Button } from 'antd';
use ant design icons 4.0 (#18217) * feat: use @ant-design/icons@4.0 * feat: use createFromIconfontCN to make site works * feat: update doc for Icon * feat: use icon in component Alert * feat: use icon in component Avatar * feat: use icon in component Breadcrumb * feat: use icon in component Button * feat: use icon in component Cascader * feat: use icon in component Collapse * feat: use icon in component Datepicker * feat: use icon in component Dropdown * feat: use icon in component Form * feat: use icon in component Input * feat: use icon in component InputNumber * feat: use icon in component Layout * feat: use icon in component Mention * feat: use icon in component Message * feat: use icon in component Modal * feat: use icon in component Notification * feat: use icon in component PageHeader * feat: use icon in component Pagination * feat: use icon in component Popconfirm * feat: use icon in component Progress * feat: use icon in component Rate * feat: use icon in component Result * feat: use icon in component Select * feat: use icon in component Step * feat: use icon in component Switch * feat: use icon in component Table * feat: use icon in component Tab * feat: use icon in component Tag * feat: handle rest component which using Icon * fix: remove unused vars * feat: use latest alpha ant design icons * fix: failed test in uploadlist.test.js * test: update snapshot for icons * doc: add Icon for site * doc: use @ant-design/icons in site * chore: use latest icons * fix: tslint issue * fix: test cases * fix: types for react * fix: lint rules for import orders * fix: use @ant-design/icons@4.0.0-alpha.5 to avoid insert css in server render * fix: eslint error in demo/**.md * inject antd icons * update snapshot * fix site * doc: update docs * fix: code snippets icon in site * feat: use latest @ant-design/icons * fix: icon props in message
2019-08-13 14:07:17 +08:00
import * as utils from '../utils';
import { version as antdVersion } from '../../../../package.json';
2016-08-23 21:00:35 +08:00
2017-12-29 12:02:22 +08:00
const { Option } = Select;
let docsearch;
if (typeof window !== 'undefined') {
docsearch = require('docsearch.js'); // eslint-disable-line
}
function initDocSearch(locale) {
if (!docsearch) {
return;
}
const lang = locale === 'zh-CN' ? 'cn' : 'en';
docsearch({
apiKey: '60ac2c1a7d26ab713757e4a081e133d0',
indexName: 'ant_design',
inputSelector: '#search-box input',
algoliaOptions: { facetFilters: [`tags:${lang}`] },
2018-01-09 19:38:27 +08:00
transformData(hits) {
2018-12-07 16:17:45 +08:00
hits.forEach(hit => {
2018-11-28 15:00:03 +08:00
hit.url = hit.url.replace('ant.design', window.location.host); // eslint-disable-line
hit.url = hit.url.replace('https:', window.location.protocol); // eslint-disable-line
2018-01-09 19:38:27 +08:00
});
return hits;
},
2017-12-29 12:02:22 +08:00
debug: false, // Set debug to true if you want to inspect the dropdown
});
}
2016-02-29 14:08:40 +08:00
2019-08-08 12:35:48 +08:00
class Header extends React.Component {
static contextTypes = {
router: PropTypes.object.isRequired,
2018-01-05 17:23:59 +08:00
isMobile: PropTypes.bool.isRequired,
2019-12-23 14:49:45 +08:00
theme: PropTypes.oneOf(['default', 'dark']),
feat: added rtl direction to all of ant-design components (#19380) * rtl demo change en-us description * change bundlesize css limit * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * fix select component arrow issue * RTL: form component * add pagination rtl test * fix test lint error * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * some fixes to RTL components * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * fix switch component text rtl issue * fix table grouped header text-align * add rtl support to whole demo with RTL button * Update rtl demo responsive * RTL: page-header component * RTL: typography component * RTL: Dropdown (Partial) * update config-provider doc * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * fix lost changes after rebase * fix lint errors * RTL: Transfer Component * RTL: upload component * RTL: update avatar demo * RTL: comment component * RTL: collapse component * RTL: carousel component * update snapshots * RTL: Card component * RTL: descriptions component * RTL: Empty component * RTL: list component * RTL: slider component * slider component import/order * add shared rtlTest * RTL: Statistic component * RTL: tooltip components * RTL: popover component * RTL: timeline component * RTL: tag component * RTL: alert component * RTL: drawer component * RTL: Tab component * change direction definition * RTL: progress component * input.tsx, remove duplicate after rebase * fix demo.less after rebase * fix ant-row-rtl after rebase * fix upload issues in rtl * badge rtl demo margin fix * fix: tabs with icon margin * fix: radio-wrapper margin * fix: table component after rebase * fix: centered modal text-align * update slider snapshot * RTL: popconfirm component * RTL: back-top component * RTL: spin component * RTL: result component * RTL: skeleton component * RTL: menu component * RTL: time-picker component * RTL: calendar component * RTL: date-picker component * RTL: home page * update snapshots * test: add auto-complete rtl test * test: add avatar component rtl tests * test: add badge component rtl tests * test: add breadcrumb component rtl tests * test: add button components rtl tests * test: add card component rtl tests * test: add carousel component rtl tests * test: add cascader component rtl tests * test: add checkbox component rtl tests * test: add collapse component rtl tests * test: add comment component rtl tests * test: add dropdown component rtl tests * test: add empty component rtl tests * test: add form component rtl tests * test: add grid component rtl tests * test: add input component rtl tests * test: add search component rtl tests * test: add input-number component rtl tests * test: add layout component rtl tests * test: add list component rtl tests * test: add mentions component rtl tests * test: add modal component rtl tests * test: add page-header component rtl tests * test: add pagination component rtl tests * test: add radio component rtl tests * test: add rate component rtl tests * test: add select component rtl tests * test: add slider component rtl tests * test: add steps component rtl tests * test: add switch component rtl tests * test: add table component rtl tests * test: add transfer component rtl tests * test: add tree component rtl tests * test: add tree-select component rtl tests * test: add typography component rtl tests * test: add upload component rtl tests * test: add affix component rtl tests * update calendar tests * increase css file maxSize * update snapshots * remove workflows to allow push * remove duplicate reverse prop from slider * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * Added direction property to ConfigProvider * cascader rtl tests added * update config-provider doc * RTL: grid system * RTL: input component * RTL: switch component * fix rtl demo lint * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * RTL: form component * add pagination rtl test * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * input.tsx, remove duplicate after rebase * fix ant-row-rtl after rebase * update snapshots * test: add cascader component rtl tests * test: add pagination component rtl tests * update calendar tests * update snapshots * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * update direction.md icons * dropdown and cascader default placement in rtl * update snapshots * fix lint errors * remove duplicate import * update snapshots * update snapshot * update calendar snapshot * update snapshots * integrate with new rc-picker * update snapshots * fix lint errors * update snapshot * update snapshots * update snapshots * update snapshots :| * update snapshots * fix compile error. * fix typo after rebase * update snapshots * remove workflows to allow push * update snapshots * update snapshots * fix dist error * front-page css fix * update snapshots * fix lint and test issues * restore cascader index.less * update snapshots * fix logo in rtl and demo controls * ci errors * resolve steps/index.tsx conflicts * tooltip family demo remove inline style * resolve table/Table.tsx conflicts * resolve modal/Modal.tsx conflicts * resolve cascader/index.tsx conflicts * add workflows from upstream * update snapshots * revert logo to default * fix codebox demo direction of placements * resolve tooltip overlayClassName conflicts * update snapshots * update popover test * fix: cascader miss popupClassName * fix: fix select missing dropdownClassName * chore: Update snapshot * chore: Adjust menu use rtl logic * docs: Update demo line color Co-authored-by: 二货机器人 <smith3816@gmail.com>
2020-01-02 19:10:16 +08:00
direction: PropTypes.string,
2018-12-07 16:17:45 +08:00
};
state = {
menuVisible: false,
};
2016-05-09 11:34:45 +08:00
componentDidMount() {
2019-08-08 12:35:48 +08:00
const { intl } = this.props;
const { router } = this.context;
2017-12-29 12:02:22 +08:00
router.listen(this.handleHideMenu);
2017-10-09 13:23:20 +08:00
const { searchInput } = this;
2018-12-07 16:17:45 +08:00
document.addEventListener('keyup', event => {
if (event.keyCode === 83 && event.target === document.body) {
searchInput.focus();
}
});
2017-12-29 12:02:22 +08:00
initDocSearch(intl.locale);
2016-03-24 17:13:19 +08:00
}
handleShowMenu = () => {
this.setState({
menuVisible: true,
});
2018-12-07 16:17:45 +08:00
};
handleHideMenu = () => {
this.setState({
menuVisible: false,
});
2018-12-07 16:17:45 +08:00
};
2016-02-29 14:08:40 +08:00
feat: added rtl direction to all of ant-design components (#19380) * rtl demo change en-us description * change bundlesize css limit * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * fix select component arrow issue * RTL: form component * add pagination rtl test * fix test lint error * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * some fixes to RTL components * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * fix switch component text rtl issue * fix table grouped header text-align * add rtl support to whole demo with RTL button * Update rtl demo responsive * RTL: page-header component * RTL: typography component * RTL: Dropdown (Partial) * update config-provider doc * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * fix lost changes after rebase * fix lint errors * RTL: Transfer Component * RTL: upload component * RTL: update avatar demo * RTL: comment component * RTL: collapse component * RTL: carousel component * update snapshots * RTL: Card component * RTL: descriptions component * RTL: Empty component * RTL: list component * RTL: slider component * slider component import/order * add shared rtlTest * RTL: Statistic component * RTL: tooltip components * RTL: popover component * RTL: timeline component * RTL: tag component * RTL: alert component * RTL: drawer component * RTL: Tab component * change direction definition * RTL: progress component * input.tsx, remove duplicate after rebase * fix demo.less after rebase * fix ant-row-rtl after rebase * fix upload issues in rtl * badge rtl demo margin fix * fix: tabs with icon margin * fix: radio-wrapper margin * fix: table component after rebase * fix: centered modal text-align * update slider snapshot * RTL: popconfirm component * RTL: back-top component * RTL: spin component * RTL: result component * RTL: skeleton component * RTL: menu component * RTL: time-picker component * RTL: calendar component * RTL: date-picker component * RTL: home page * update snapshots * test: add auto-complete rtl test * test: add avatar component rtl tests * test: add badge component rtl tests * test: add breadcrumb component rtl tests * test: add button components rtl tests * test: add card component rtl tests * test: add carousel component rtl tests * test: add cascader component rtl tests * test: add checkbox component rtl tests * test: add collapse component rtl tests * test: add comment component rtl tests * test: add dropdown component rtl tests * test: add empty component rtl tests * test: add form component rtl tests * test: add grid component rtl tests * test: add input component rtl tests * test: add search component rtl tests * test: add input-number component rtl tests * test: add layout component rtl tests * test: add list component rtl tests * test: add mentions component rtl tests * test: add modal component rtl tests * test: add page-header component rtl tests * test: add pagination component rtl tests * test: add radio component rtl tests * test: add rate component rtl tests * test: add select component rtl tests * test: add slider component rtl tests * test: add steps component rtl tests * test: add switch component rtl tests * test: add table component rtl tests * test: add transfer component rtl tests * test: add tree component rtl tests * test: add tree-select component rtl tests * test: add typography component rtl tests * test: add upload component rtl tests * test: add affix component rtl tests * update calendar tests * increase css file maxSize * update snapshots * remove workflows to allow push * remove duplicate reverse prop from slider * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * Added direction property to ConfigProvider * cascader rtl tests added * update config-provider doc * RTL: grid system * RTL: input component * RTL: switch component * fix rtl demo lint * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * RTL: form component * add pagination rtl test * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * input.tsx, remove duplicate after rebase * fix ant-row-rtl after rebase * update snapshots * test: add cascader component rtl tests * test: add pagination component rtl tests * update calendar tests * update snapshots * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * update direction.md icons * dropdown and cascader default placement in rtl * update snapshots * fix lint errors * remove duplicate import * update snapshots * update snapshot * update calendar snapshot * update snapshots * integrate with new rc-picker * update snapshots * fix lint errors * update snapshot * update snapshots * update snapshots * update snapshots :| * update snapshots * fix compile error. * fix typo after rebase * update snapshots * remove workflows to allow push * update snapshots * update snapshots * fix dist error * front-page css fix * update snapshots * fix lint and test issues * restore cascader index.less * update snapshots * fix logo in rtl and demo controls * ci errors * resolve steps/index.tsx conflicts * tooltip family demo remove inline style * resolve table/Table.tsx conflicts * resolve modal/Modal.tsx conflicts * resolve cascader/index.tsx conflicts * add workflows from upstream * update snapshots * revert logo to default * fix codebox demo direction of placements * resolve tooltip overlayClassName conflicts * update snapshots * update popover test * fix: cascader miss popupClassName * fix: fix select missing dropdownClassName * chore: Update snapshot * chore: Adjust menu use rtl logic * docs: Update demo line color Co-authored-by: 二货机器人 <smith3816@gmail.com>
2020-01-02 19:10:16 +08:00
handleDirectionChange = () => {
const { changeDirection } = this.props;
const { direction } = this.context;
if (direction !== 'rtl') {
changeDirection('rtl');
} else {
changeDirection('ltr');
}
};
getNextDirectionText = () => {
const { direction } = this.context;
if (direction !== 'rtl') {
return 'RTL';
}
return 'LTR';
};
2018-12-07 16:17:45 +08:00
onMenuVisibleChange = visible => {
2017-02-21 13:36:17 +08:00
this.setState({
menuVisible: visible,
});
2018-12-07 16:17:45 +08:00
};
2017-02-21 13:36:17 +08:00
2018-12-07 16:17:45 +08:00
handleVersionChange = url => {
const currentUrl = window.location.href;
const currentPathname = window.location.pathname;
2018-12-07 16:17:45 +08:00
window.location.href = currentUrl
.replace(window.location.origin, url)
.replace(currentPathname, utils.getLocalizedPathname(currentPathname));
2018-12-07 16:17:45 +08:00
};
2017-12-01 20:37:14 +08:00
handleLangChange = () => {
2018-12-07 16:17:45 +08:00
const {
location: { pathname },
} = this.props;
2017-12-01 20:37:14 +08:00
const currentProtocol = `${window.location.protocol}//`;
const currentHref = window.location.href.substr(currentProtocol.length);
if (utils.isLocalStorageNameSupported()) {
localStorage.setItem('locale', utils.isZhCN(pathname) ? 'en-US' : 'zh-CN');
}
2018-12-07 16:17:45 +08:00
window.location.href =
currentProtocol +
currentHref.replace(
window.location.pathname,
utils.getLocalizedPathname(pathname, !utils.isZhCN(pathname)),
);
};
2017-12-01 20:37:14 +08:00
2016-03-01 16:20:32 +08:00
render() {
2018-01-04 20:00:38 +08:00
const { menuVisible } = this.state;
2019-12-23 16:30:32 +08:00
const { isMobile } = this.context;
2018-01-05 17:23:59 +08:00
const menuMode = isMobile ? 'inline' : 'horizontal';
2019-08-12 13:34:23 +08:00
const {
location,
themeConfig,
intl: { locale },
} = this.props;
const docVersions = { ...themeConfig.docVersions, [antdVersion]: antdVersion };
2018-12-07 16:17:45 +08:00
const versionOptions = Object.keys(docVersions).map(version => (
<Option value={docVersions[version]} key={version}>
{version}
</Option>
));
2019-12-26 15:27:52 +08:00
const pathname = location.pathname.replace(/(^\/|\/$)/g, '');
const module = pathname
2018-12-07 16:17:45 +08:00
.split('/')
.slice(0, -1)
.join('/');
2016-07-26 15:24:48 +08:00
let activeMenuItem = module || 'home';
if (location.pathname === 'changelog' || location.pathname === 'changelog-cn') {
2016-06-15 15:55:39 +08:00
activeMenuItem = 'docs/react';
}
2019-12-26 15:27:52 +08:00
const isHome = ['', 'index', 'index-cn'].includes(pathname);
const isZhCN = locale === 'zh-CN';
2016-04-28 15:42:02 +08:00
const headerClassName = classNames({
clearfix: true,
2019-12-26 15:27:52 +08:00
'home-header': isHome,
2016-04-28 15:42:02 +08:00
});
2016-09-26 12:12:44 +08:00
const menu = [
2019-12-26 15:27:52 +08:00
isHome ? (
<GitHubButton key="github" type="stargazers" namespace="ant-design" repo="ant-design" />
) : null,
2018-12-07 16:17:45 +08:00
<Button
feat: added rtl direction to all of ant-design components (#19380) * rtl demo change en-us description * change bundlesize css limit * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * fix select component arrow issue * RTL: form component * add pagination rtl test * fix test lint error * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * some fixes to RTL components * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * fix switch component text rtl issue * fix table grouped header text-align * add rtl support to whole demo with RTL button * Update rtl demo responsive * RTL: page-header component * RTL: typography component * RTL: Dropdown (Partial) * update config-provider doc * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * fix lost changes after rebase * fix lint errors * RTL: Transfer Component * RTL: upload component * RTL: update avatar demo * RTL: comment component * RTL: collapse component * RTL: carousel component * update snapshots * RTL: Card component * RTL: descriptions component * RTL: Empty component * RTL: list component * RTL: slider component * slider component import/order * add shared rtlTest * RTL: Statistic component * RTL: tooltip components * RTL: popover component * RTL: timeline component * RTL: tag component * RTL: alert component * RTL: drawer component * RTL: Tab component * change direction definition * RTL: progress component * input.tsx, remove duplicate after rebase * fix demo.less after rebase * fix ant-row-rtl after rebase * fix upload issues in rtl * badge rtl demo margin fix * fix: tabs with icon margin * fix: radio-wrapper margin * fix: table component after rebase * fix: centered modal text-align * update slider snapshot * RTL: popconfirm component * RTL: back-top component * RTL: spin component * RTL: result component * RTL: skeleton component * RTL: menu component * RTL: time-picker component * RTL: calendar component * RTL: date-picker component * RTL: home page * update snapshots * test: add auto-complete rtl test * test: add avatar component rtl tests * test: add badge component rtl tests * test: add breadcrumb component rtl tests * test: add button components rtl tests * test: add card component rtl tests * test: add carousel component rtl tests * test: add cascader component rtl tests * test: add checkbox component rtl tests * test: add collapse component rtl tests * test: add comment component rtl tests * test: add dropdown component rtl tests * test: add empty component rtl tests * test: add form component rtl tests * test: add grid component rtl tests * test: add input component rtl tests * test: add search component rtl tests * test: add input-number component rtl tests * test: add layout component rtl tests * test: add list component rtl tests * test: add mentions component rtl tests * test: add modal component rtl tests * test: add page-header component rtl tests * test: add pagination component rtl tests * test: add radio component rtl tests * test: add rate component rtl tests * test: add select component rtl tests * test: add slider component rtl tests * test: add steps component rtl tests * test: add switch component rtl tests * test: add table component rtl tests * test: add transfer component rtl tests * test: add tree component rtl tests * test: add tree-select component rtl tests * test: add typography component rtl tests * test: add upload component rtl tests * test: add affix component rtl tests * update calendar tests * increase css file maxSize * update snapshots * remove workflows to allow push * remove duplicate reverse prop from slider * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * Added direction property to ConfigProvider * cascader rtl tests added * update config-provider doc * RTL: grid system * RTL: input component * RTL: switch component * fix rtl demo lint * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * fix pagination.tsx compile error * RTL: button and button-group * RTL: Steps component * fix rtl demo style * RTL: form component * add pagination rtl test * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * RTL: input component * RTL: select component * RTL: switch component * RTL: tree component * fix rtl demo lint * rtl demo change en-us description * RTL: modal component (exclude confirm) * RTL: table component * RTL: pagination component * cleanup rtl demo * RTL: button and button-group * RTL: Steps component * fix rtl demo style * fix input suffix icon alignment * RTL: form component * RTL: rate component * RTL: radio and radio group components * RTL: tree-select component * RTL: badge component * fix rtl issue in inline form * fix input component rtl padding issue * add rtl support to whole demo with RTL button * input.tsx, remove duplicate after rebase * fix ant-row-rtl after rebase * update snapshots * test: add cascader component rtl tests * test: add pagination component rtl tests * update calendar tests * update snapshots * fix: remove table demo from config-provider * fix: remove table demo from config-provider * fix lint error * update direction.md icons * dropdown and cascader default placement in rtl * update snapshots * fix lint errors * remove duplicate import * update snapshots * update snapshot * update calendar snapshot * update snapshots * integrate with new rc-picker * update snapshots * fix lint errors * update snapshot * update snapshots * update snapshots * update snapshots :| * update snapshots * fix compile error. * fix typo after rebase * update snapshots * remove workflows to allow push * update snapshots * update snapshots * fix dist error * front-page css fix * update snapshots * fix lint and test issues * restore cascader index.less * update snapshots * fix logo in rtl and demo controls * ci errors * resolve steps/index.tsx conflicts * tooltip family demo remove inline style * resolve table/Table.tsx conflicts * resolve modal/Modal.tsx conflicts * resolve cascader/index.tsx conflicts * add workflows from upstream * update snapshots * revert logo to default * fix codebox demo direction of placements * resolve tooltip overlayClassName conflicts * update snapshots * update popover test * fix: cascader miss popupClassName * fix: fix select missing dropdownClassName * chore: Update snapshot * chore: Adjust menu use rtl logic * docs: Update demo line color Co-authored-by: 二货机器人 <smith3816@gmail.com>
2020-01-02 19:10:16 +08:00
size="small"
onClick={this.handleDirectionChange}
className="header-direction-button"
key="direction-button"
>
{this.getNextDirectionText()}
</Button>,
<Button
2018-12-07 16:17:45 +08:00
size="small"
onClick={this.handleLangChange}
className="header-lang-button"
key="lang-button"
>
2017-12-01 20:27:44 +08:00
<FormattedMessage id="app.header.lang" />
</Button>,
<Select
key="version"
className="version"
size="small"
dropdownMatchSelectWidth={false}
defaultValue={antdVersion}
onChange={this.handleVersionChange}
getPopupContainer={trigger => trigger.parentNode}
>
{versionOptions}
</Select>,
2018-12-07 16:17:45 +08:00
<Menu
className="menu-site"
mode={menuMode}
selectedKeys={[activeMenuItem]}
id="nav"
key="nav"
>
2019-12-26 15:27:52 +08:00
{isHome ? null : (
<Menu.Item key="home" className="hide-in-home-page">
<Link to={utils.getLocalizedPathname('/', isZhCN)}>
<FormattedMessage id="app.header.menu.home" />
</Link>
</Menu.Item>
)}
2016-10-07 14:33:08 +08:00
<Menu.Item key="docs/spec">
<Link to={utils.getLocalizedPathname('/docs/spec/introduce', isZhCN)}>
2016-10-07 14:33:08 +08:00
<FormattedMessage id="app.header.menu.spec" />
2016-09-26 12:12:44 +08:00
</Link>
</Menu.Item>
<Menu.Item key="docs/react">
<Link to={utils.getLocalizedPathname('/docs/react/introduce', isZhCN)}>
<FormattedMessage id="app.header.menu.documentation" />
</Link>
</Menu.Item>
<Menu.Item key="components">
<Link to={utils.getLocalizedPathname('/components/button/', isZhCN)}>
2016-09-26 12:12:44 +08:00
<FormattedMessage id="app.header.menu.components" />
</Link>
</Menu.Item>
2019-03-11 11:19:43 +08:00
<Menu.SubMenu
key="ecosystem"
className="hide-in-home-page"
2019-12-31 14:52:53 +08:00
title={<FormattedMessage id="app.header.menu.ecosystem" />}
2019-03-11 11:19:43 +08:00
>
<Menu.Item key="pro">
<a
href="http://pro.ant.design"
className="header-link"
target="_blank"
rel="noopener noreferrer"
>
2019-12-31 14:52:53 +08:00
<FormattedMessage id="app.header.menu.pro.v4" />
2019-03-11 11:19:43 +08:00
</a>
</Menu.Item>
<Menu.Item key="ng">
<a
href="http://ng.ant.design"
className="header-link"
target="_blank"
rel="noopener noreferrer"
>
Ant Design of Angular
</a>
</Menu.Item>
<Menu.Item key="vue">
2018-09-12 11:46:40 +08:00
<a
2019-03-11 11:19:43 +08:00
href="http://vue.ant.design"
2018-09-12 11:46:40 +08:00
className="header-link"
target="_blank"
rel="noopener noreferrer"
>
2019-03-11 11:19:43 +08:00
Ant Design of Vue
2018-09-12 11:46:40 +08:00
</a>
2018-09-12 11:52:59 +08:00
</Menu.Item>
2019-03-11 11:19:43 +08:00
{isZhCN ? (
<Menu.Item key="course" className="hide-in-home-page">
<a
href="https://www.yuque.com/ant-design/course"
className="header-link"
target="_blank"
rel="noopener noreferrer"
>
2019-03-13 11:58:36 +08:00
Ant Design 实战教程
2019-03-11 11:19:43 +08:00
</a>
</Menu.Item>
) : null}
</Menu.SubMenu>
2016-09-26 12:12:44 +08:00
</Menu>,
];
const colProps = isHome
? [{ flex: 'none' }, { flex: 'auto' }]
: [
{
xxl: 4,
xl: 5,
lg: 5,
md: 5,
sm: 24,
xs: 24,
},
{
xxl: 20,
xl: 19,
lg: 19,
md: 19,
sm: 0,
xs: 0,
},
];
2018-01-12 15:00:03 +08:00
const searchPlaceholder = locale === 'zh-CN' ? '在 ant.design 中搜索' : 'Search in ant.design';
2016-03-01 16:20:32 +08:00
return (
2016-04-28 15:42:02 +08:00
<header id="header" className={headerClassName}>
2018-01-05 17:23:59 +08:00
{isMobile && (
2017-10-09 13:23:20 +08:00
<Popover
overlayClassName="popover-menu"
placement="bottomRight"
content={menu}
trigger="click"
visible={menuVisible}
arrowPointAtCenter
onVisibleChange={this.onMenuVisibleChange}
>
2019-12-26 15:27:52 +08:00
<MenuOutlined className="nav-phone-icon" onClick={this.handleShowMenu} />
2017-10-09 13:23:20 +08:00
</Popover>
2018-01-04 20:00:38 +08:00
)}
2016-03-01 16:33:19 +08:00
<Row>
<Col {...colProps[0]}>
2019-12-27 14:10:55 +08:00
<h1>
<Link to={utils.getLocalizedPathname('/', isZhCN)} id="logo">
<img
alt="logo"
src="https://gw.alipayobjects.com/zos/rmsportal/KDpgvguMpGfqaHPjicRK.svg"
/>
Ant Design
</Link>
</h1>
2016-03-01 16:33:19 +08:00
</Col>
<Col {...colProps[1]}>
2016-03-01 16:33:19 +08:00
<div id="search-box">
2019-12-26 15:27:52 +08:00
<SearchOutlined />
2018-12-07 16:17:45 +08:00
<Input
ref={ref => {
this.searchInput = ref;
}}
placeholder={searchPlaceholder}
/>
2016-03-01 16:33:19 +08:00
</div>
{!isMobile && menu}
2016-03-01 16:33:19 +08:00
</Col>
</Row>
2016-03-01 16:20:32 +08:00
</header>
);
}
2016-02-29 14:08:40 +08:00
}
2019-08-08 12:35:48 +08:00
export default injectIntl(Header);