diff --git a/site/theme/en-US.js b/site/theme/en-US.js index ff95742569..2f65b65f6a 100644 --- a/site/theme/en-US.js +++ b/site/theme/en-US.js @@ -54,6 +54,7 @@ module.exports = { 'app.footer.awesome': 'Awesome Ant Design', 'app.footer.course': 'Ant Design Practical Tutorial', 'app.footer.chinamirror': 'China Mirror 🇨🇳', + 'app.footer.primary-color-changing': 'Changing primary color...', 'app.footer.primary-color-changed': 'Change primary color successfully!', 'app.footer.scaffold': 'Scaffold', 'app.footer.kitchen': 'Sketch Toolkit', diff --git a/site/theme/template/Layout/Footer.jsx b/site/theme/template/Layout/Footer.jsx index f9361e78a2..297e7d86e6 100644 --- a/site/theme/template/Layout/Footer.jsx +++ b/site/theme/template/Layout/Footer.jsx @@ -1,8 +1,9 @@ import React from 'react'; import { FormattedMessage, injectIntl } from 'react-intl'; -import { Modal, message, Row, Col, Icon } from 'antd'; +import { Modal, message, Icon } from 'antd'; import { Link } from 'bisheng/router'; import RcFooter from 'rc-footer'; +import { presetPalettes } from '@ant-design/colors'; import { isLocalStorageNameSupported, loadScript, getLocalizedPathname } from '../utils'; import ColorPicker from '../Color/ColorPicker'; @@ -10,7 +11,7 @@ class Footer extends React.Component { lessLoaded = false; state = { - color: '#1890ff', + color: presetPalettes.blue.primary, }; componentDidMount() { @@ -32,7 +33,6 @@ class Footer extends React.Component { getColumns() { const { intl = {} } = this.props; - const { color } = this.state; const isZhCN = intl.locale === 'zh-CN'; return [ { @@ -171,7 +171,19 @@ class Footer extends React.Component { url: getLocalizedPathname('/docs/react/faq', isZhCN), }, { - icon: , + icon: , + title: , + url: 'https://new-issue.ant.design/', + openExternal: true, + }, + { + icon: , + title: , + url: 'https://github.com/ant-design/ant-design/issues', + openExternal: true, + }, + { + icon: , title: , url: 'https://www.yuque.com/ant-design/course', openExternal: true, @@ -188,18 +200,6 @@ class Footer extends React.Component { url: 'https://gitter.im/ant-design/ant-design-english', openExternal: true, }, - { - icon: , - title: , - url: 'https://new-issue.ant.design/', - openExternal: true, - }, - { - icon: , - title: , - url: 'https://github.com/ant-design/ant-design/issues', - openExternal: true, - }, { icon: , title: , @@ -294,6 +294,9 @@ class Footer extends React.Component { url: 'https://xtech.antfin.com/', openExternal: true, }, + { + title: this.renderThemeChanger(), + }, ], }, ]; @@ -304,11 +307,13 @@ class Footer extends React.Component { const { intl: { messages }, } = this.props; + const hide = message.loading(messages['app.footer.primary-color-changing']); window.less .modifyVars({ '@primary-color': color, }) .then(() => { + hide(); Icon.setTwoToneColor({ primaryColor: color }); message.success(messages['app.footer.primary-color-changed']); this.setState({ color }); @@ -364,6 +369,27 @@ class Footer extends React.Component { }); } + renderThemeChanger() { + const { color } = this.state; + const colors = Object.keys(presetPalettes).filter(item => item !== 'grey'); + return ( +
+ presetPalettes[c][5]), + ...colors.map(c => presetPalettes[c][4]), + ...colors.map(c => presetPalettes[c][6]), + ]} + onChangeComplete={this.handleColorChange} + /> +
+ ); + } + render() { return (