From c471e6c39a2de8f2d238f1290aa95245b522316e Mon Sep 17 00:00:00 2001 From: afc163 Date: Sat, 1 Sep 2018 22:59:01 +0800 Subject: [PATCH] Add Tootlip fop options --- .../PageHeaderWrapper/GridContent.js | 6 +- src/components/PageHeaderWrapper/index.js | 6 +- src/components/SettingDrawer/BlockChecbox.js | 30 ++++------ src/components/SettingDrawer/ThemeColor.js | 60 +++++++++++++------ src/components/SettingDrawer/index.js | 18 +++--- src/components/TopNavHeader/index.js | 8 +-- src/locales/en-US.js | 12 ++++ src/locales/zh-CN.js | 14 ++++- 8 files changed, 102 insertions(+), 52 deletions(-) diff --git a/src/components/PageHeaderWrapper/GridContent.js b/src/components/PageHeaderWrapper/GridContent.js index 5f16c5d0..931ea20c 100644 --- a/src/components/PageHeaderWrapper/GridContent.js +++ b/src/components/PageHeaderWrapper/GridContent.js @@ -4,9 +4,9 @@ import styles from './GridContent.less'; class GridContent extends PureComponent { render() { - const { grid, children } = this.props; + const { contentWidth, children } = this.props; let className = `${styles.main}`; - if (grid === 'Fixed') { + if (contentWidth === 'Fixed') { className = `${styles.main} ${styles.wide}`; } return
{children}
; @@ -14,5 +14,5 @@ class GridContent extends PureComponent { } export default connect(({ setting }) => ({ - grid: setting.grid, + contentWidth: setting.contentWidth, }))(GridContent); diff --git a/src/components/PageHeaderWrapper/index.js b/src/components/PageHeaderWrapper/index.js index 63082df7..66096404 100644 --- a/src/components/PageHeaderWrapper/index.js +++ b/src/components/PageHeaderWrapper/index.js @@ -7,13 +7,13 @@ import GridContent from './GridContent'; import styles from './index.less'; import MenuContext from '@/layouts/MenuContext'; -const PageHeaderWrapper = ({ children, grid, wrapperClassName, top, ...restProps }) => ( +const PageHeaderWrapper = ({ children, contentWidth, wrapperClassName, top, ...restProps }) => (
{top} {value => ( } {...value} key="pageheader" @@ -37,5 +37,5 @@ const PageHeaderWrapper = ({ children, grid, wrapperClassName, top, ...restProps ); export default connect(({ setting }) => ({ - grid: setting.grid, + contentWidth: setting.contentWidth, }))(PageHeaderWrapper); diff --git a/src/components/SettingDrawer/BlockChecbox.js b/src/components/SettingDrawer/BlockChecbox.js index be7e3ff1..49af42c7 100644 --- a/src/components/SettingDrawer/BlockChecbox.js +++ b/src/components/SettingDrawer/BlockChecbox.js @@ -1,27 +1,23 @@ -import { Icon } from 'antd'; import React from 'react'; +import { Tooltip, Icon } from 'antd'; import style from './index.less'; const BlockChecbox = ({ value, onChange, list }) => (
{list.map(item => ( -
{ - onChange(item.key); - }} - > - {item.key} -
- + +
onChange(item.key)}> + {item.key} +
+ +
-
+ ))}
); diff --git a/src/components/SettingDrawer/ThemeColor.js b/src/components/SettingDrawer/ThemeColor.js index 6246dc61..e5d66d4b 100644 --- a/src/components/SettingDrawer/ThemeColor.js +++ b/src/components/SettingDrawer/ThemeColor.js @@ -1,5 +1,6 @@ -import { Icon } from 'antd'; import React from 'react'; +import { Tooltip, Icon } from 'antd'; +import { formatMessage } from 'umi/locale'; import styles from './ThemeColor.less'; const Tag = ({ color, check, ...rest }) => ( @@ -17,28 +18,53 @@ const ThemeColor = ({ colors, title, value, onChange }) => { let colorList = colors; if (!colors) { colorList = [ - '#F5222D', - '#FA541C', - '#FAAD14', - '#13C2C2', - '#52C41A', - '#1890FF', - '#2F54EB', - '#722ED1', + { + key: 'dust', + color: '#F5222D', + }, + { + key: 'volcano', + color: '#FA541C', + }, + { + key: 'sunset', + color: '#FAAD14', + }, + { + key: 'cyan', + color: '#13C2C2', + }, + { + key: 'green', + color: '#52C41A', + }, + { + key: 'daybreak', + color: '#1890FF', + }, + { + key: 'geekblue', + color: '#2F54EB', + }, + { + key: 'purple', + color: '#722ED1', + }, ]; } return (

{title}

- {colorList.map(color => ( - onChange && onChange(color)} - /> + {colorList.map(({ key, color }) => ( + + onChange && onChange(color)} + /> + ))}
diff --git a/src/components/SettingDrawer/index.js b/src/components/SettingDrawer/index.js index cb359254..8950bb7a 100644 --- a/src/components/SettingDrawer/index.js +++ b/src/components/SettingDrawer/index.js @@ -28,23 +28,23 @@ class SettingDrawer extends PureComponent { getLayOutSetting = () => { const { - setting: { grid, fixedHeader, layout, autoHideHeader, fixSiderbar }, + setting: { contentWidth, fixedHeader, layout, autoHideHeader, fixSiderbar }, } = this.props; return [ { - title: formatMessage({ id: 'app.setting.gridmode' }), + title: formatMessage({ id: 'app.setting.content-width' }), action: [ , ], @@ -89,7 +89,7 @@ class SettingDrawer extends PureComponent { const nextState = { ...setting }; nextState[key] = value; if (key === 'layout') { - nextState.grid = value === 'topmenu' ? 'Fixed' : 'Fluid'; + nextState.contentWidth = value === 'topmenu' ? 'Fixed' : 'Fluid'; } else if (key === 'fixedHeader' && !value) { nextState.autoHideHeader = false; } @@ -140,10 +140,12 @@ class SettingDrawer extends PureComponent { { key: 'dark', url: 'https://gw.alipayobjects.com/zos/rmsportal/LCkqqYNmvBEbokSDscrm.svg', + title: formatMessage({ id: 'app.setting.pagestyle.dark' }), }, { key: 'light', url: 'https://gw.alipayobjects.com/zos/rmsportal/jpRkZQMyYRryryPNtyIC.svg', + title: formatMessage({ id: 'app.setting.pagestyle.light' }), }, ]} value={navTheme} @@ -165,10 +167,12 @@ class SettingDrawer extends PureComponent { { key: 'sidemenu', url: 'https://gw.alipayobjects.com/zos/rmsportal/JopDzEhOqwOjeNTXkoje.svg', + title: formatMessage({ id: 'app.setting.sidemenu' }), }, { key: 'topmenu', url: 'https://gw.alipayobjects.com/zos/rmsportal/KDNDBbriJhLwuqMoxcAr.svg', + title: formatMessage({ id: 'app.setting.topmenu' }), }, ]} value={layout} diff --git a/src/components/TopNavHeader/index.js b/src/components/TopNavHeader/index.js index 347208c9..9c8575ce 100644 --- a/src/components/TopNavHeader/index.js +++ b/src/components/TopNavHeader/index.js @@ -9,18 +9,18 @@ export default class TopNavHeader extends PureComponent { super(props); this.state = { - maxWidth: (props.grid === 'Fixed' ? 1200 : window.innerWidth) - 324 - 165 - 4, + maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 324 - 165 - 4, }; } static getDerivedStateFromProps(props) { return { - maxWidth: (props.grid === 'Fixed' ? 1200 : window.innerWidth) - 324 - 165 - 4, + maxWidth: (props.contentWidth === 'Fixed' ? 1200 : window.innerWidth) - 324 - 165 - 4, }; } render() { - const { theme, grid, logo } = this.props; + const { theme, contentWidth, logo } = this.props; const { maxWidth } = this.state; return (
@@ -28,7 +28,7 @@ export default class TopNavHeader extends PureComponent { ref={ref => { this.maim = ref; }} - className={`${styles.main} ${grid === 'Fixed' ? styles.wide : ''}`} + className={`${styles.main} ${contentWidth === 'Fixed' ? styles.wide : ''}`} >