From 02f2df3bcda0fe55b293dbcf4da3621c5a390314 Mon Sep 17 00:00:00 2001 From: wugaoliang Date: Fri, 7 Feb 2020 20:50:56 +0800 Subject: [PATCH 1/2] fix: #733 --- components/context/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/context/index.js b/components/context/index.js index 139c2f42d..e93b239cb 100644 --- a/components/context/index.js +++ b/components/context/index.js @@ -1,7 +1,8 @@ import React, { Component, forwardRef } from 'react' import locales from '../locales' -export const ThemeContext = React.createContext('hiui-blue') +// export const ThemeContext = React.createContext('hiui-blue') +export const ThemeContext = React.createContext('orange') export const LocaleContext = React.createContext('zh-CN') export default (WrappedComponent) => { From c08a65ffb68d0021d44c1a390867674445b391b8 Mon Sep 17 00:00:00 2001 From: wugaoliang Date: Sat, 8 Feb 2020 00:13:28 +0800 Subject: [PATCH 2/2] fix: #733 --- components/context/index.js | 39 +++++++++++-------- components/menu/Menu.js | 3 +- components/menu/SubMenu.js | 3 +- components/notice/Notice.js | 1 + components/notification/index.js | 4 +- components/select/Select.js | 5 ++- components/select/SelectDropdown.js | 3 +- components/select/SelectInput.js | 3 +- .../__snapshots__/index.test.js.snap | 6 +-- 9 files changed, 36 insertions(+), 31 deletions(-) diff --git a/components/context/index.js b/components/context/index.js index e93b239cb..a5a10a34b 100644 --- a/components/context/index.js +++ b/components/context/index.js @@ -1,10 +1,12 @@ import React, { Component, forwardRef } from 'react' import locales from '../locales' -// export const ThemeContext = React.createContext('hiui-blue') -export const ThemeContext = React.createContext('orange') +export const ThemeContext = React.createContext('hiui-blue') export const LocaleContext = React.createContext('zh-CN') - +/** + * 临时解决 notice组件获取不到theme的问题 + */ +let noticeTheme = '' export default (WrappedComponent) => { class WrapperComponent extends Component { static displayName = WrappedComponent.name @@ -12,20 +14,23 @@ export default (WrappedComponent) => { const { theme, locale, innerRef, ...restProps } = this.props let ConsumerComponent = ( - {(contextTheme) => ( - - {(contextLocale) => ( - - )} - - )} + {(contextTheme) => { + noticeTheme = noticeTheme || contextTheme + return ( + + {(contextLocale) => ( + + )} + + ) + }} ) return wrapProvider(theme, ThemeContext)(locale, LocaleContext)( diff --git a/components/menu/Menu.js b/components/menu/Menu.js index 14447794d..0973a9023 100644 --- a/components/menu/Menu.js +++ b/components/menu/Menu.js @@ -221,7 +221,7 @@ class Menu extends Component { } renderMenu (data, parentIndex = '') { - const {showAllSubMenus, placement} = this.props + const {showAllSubMenus, placement, theme} = this.props const { activeIndex, expandIndex, @@ -237,6 +237,7 @@ class Menu extends Component { items.push( { const NoticeContent = ( diff --git a/components/select/Select.js b/components/select/Select.js index 326a007b0..d77c694ce 100644 --- a/components/select/Select.js +++ b/components/select/Select.js @@ -547,7 +547,8 @@ class Select extends Component { onFocus, dataSource, filterOption, - onSearch + onSearch, + theme } = this.props const placeholder = this.localeDatasProps('placeholder') const { @@ -579,6 +580,7 @@ class Select extends Component { ref={node => { this.selectInput = node }} + theme={theme} mode={type} disabled={disabled} searchable={searchable} @@ -617,6 +619,7 @@ class Select extends Component {