From 5665732939541fe5cf536cb1ddd3deda6b01d8f8 Mon Sep 17 00:00:00 2001 From: zouxuoz Date: Fri, 2 Nov 2018 13:28:36 +0300 Subject: [PATCH] feat(Modal): export modal context instead of consumer --- src/atoms/Modal/Modal.stories.js | 6 +++--- src/atoms/Modal/ModalContext.js | 4 ++-- src/atoms/Modal/ModalProvider.js | 6 +++--- src/atoms/Modal/withModal.js | 4 ++-- src/atoms/Modal/withModalState.js | 4 ++-- src/index.js | 2 +- 6 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/atoms/Modal/Modal.stories.js b/src/atoms/Modal/Modal.stories.js index 0fe1a3f3..da500d55 100644 --- a/src/atoms/Modal/Modal.stories.js +++ b/src/atoms/Modal/Modal.stories.js @@ -1,7 +1,7 @@ import React from 'react'; export default (asStory) => { - asStory('ATOMS/Modal (skip shot)', module, (story, { Modal, ModalConsumer, Button }) => { + asStory('ATOMS/Modal (skip shot)', module, (story, { Modal, ModalContext, Button }) => { story .add('multiple modals', () => ( @@ -46,11 +46,11 @@ export default (asStory) => { ) } - + { ({ openModal }) => } - + )); }); diff --git a/src/atoms/Modal/ModalContext.js b/src/atoms/Modal/ModalContext.js index 3bb8b1bd..aa640137 100644 --- a/src/atoms/Modal/ModalContext.js +++ b/src/atoms/Modal/ModalContext.js @@ -1,5 +1,5 @@ import React from 'react'; -const { Provider, Consumer } = React.createContext('modal'); +const ModalContext = React.createContext('modal'); -export { Provider, Consumer }; +export { ModalContext }; diff --git a/src/atoms/Modal/ModalProvider.js b/src/atoms/Modal/ModalProvider.js index f7d1113d..59fb8a23 100644 --- a/src/atoms/Modal/ModalProvider.js +++ b/src/atoms/Modal/ModalProvider.js @@ -1,6 +1,6 @@ import React, { Component } from 'react'; -import { Provider } from './ModalContext'; +import { ModalContext } from './ModalContext'; class ModalProvider extends Component { constructor(props) { @@ -36,9 +36,9 @@ class ModalProvider extends Component { const contextValue = this.collectContextValue(); return ( - + { this.props.children } - + ); } } diff --git a/src/atoms/Modal/withModal.js b/src/atoms/Modal/withModal.js index fedc91ca..8cba1044 100644 --- a/src/atoms/Modal/withModal.js +++ b/src/atoms/Modal/withModal.js @@ -1,6 +1,6 @@ import React from 'react'; -import { Consumer } from './ModalContext'; +import { ModalContext } from './ModalContext'; const withModal = (BaseComponent) => { class ModalStateConsumer extends React.Component { @@ -15,7 +15,7 @@ const withModal = (BaseComponent) => { } render() { - return { this.renderBaseComponent }; + return { this.renderBaseComponent }; } } diff --git a/src/atoms/Modal/withModalState.js b/src/atoms/Modal/withModalState.js index 4158d189..6728f18a 100644 --- a/src/atoms/Modal/withModalState.js +++ b/src/atoms/Modal/withModalState.js @@ -1,6 +1,6 @@ import React from 'react'; -import { Consumer } from './ModalContext'; +import { ModalContext } from './ModalContext'; const withModalState = (BaseComponent) => { class ModalStateConsumer extends React.Component { @@ -21,7 +21,7 @@ const withModalState = (BaseComponent) => { const { id, ...rest } = this.props; if (id) { - return { this.renderBaseComponentWithModalProps }; + return { this.renderBaseComponentWithModalProps }; } return ; diff --git a/src/index.js b/src/index.js index 71e910a1..d14fd9bc 100644 --- a/src/index.js +++ b/src/index.js @@ -4,7 +4,7 @@ export { ThemeProvider } from 'emotion-theming'; export { defaultTheme, resetGlobal, Z_INDEX } from './theme'; export * from './atoms'; export * from './molecules'; -export { Consumer as ModalConsumer } from './atoms/Modal/ModalContext'; +export { ModalContext } from './atoms/Modal/ModalContext'; export { withModal } from './atoms/Modal/withModal'; export { EightBaseBoostProvider } from './EightBaseBoostProvider';