diff --git a/.storybook/webpack.config.js b/.storybook/webpack.config.js index c6e5cb72a168..b4db11d7a1b3 100644 --- a/.storybook/webpack.config.js +++ b/.storybook/webpack.config.js @@ -2,6 +2,7 @@ /* eslint-disable no-param-reassign */ const path = require('path'); const dotenv = require('dotenv'); +const custom = require('../config/webpack/webpack.common'); const env = dotenv.config({path: path.resolve(__dirname, '../.env.staging')}).parsed; @@ -9,11 +10,26 @@ module.exports = ({config}) => { config.resolve.alias = { 'react-native-config': 'react-web-config', 'react-native$': 'react-native-web', + '@react-native-community/netinfo': './mock', }; // Necessary to overwrite the values in the existing DefinePlugin hardcoded to the Config staging values const definePluginIndex = config.plugins.findIndex(plugin => plugin.constructor.name === 'DefinePlugin'); config.plugins[definePluginIndex].definitions.__REACT_WEB_CONFIG__ = JSON.stringify(env); config.resolve.extensions.push('.web.js', '.website.js'); + + const babelRulesIndex = custom.module.rules.findIndex(rule => rule.loader === 'babel-loader'); + const babelRule = custom.module.rules[babelRulesIndex]; + config.module.rules.push(babelRule); + + // Allows loading SVG - more context here https://github.com/storybookjs/storybook/issues/6188 + const fileLoaderRule = config.module.rules.find(rule => rule.test && rule.test.test('.svg')); + fileLoaderRule.exclude = /\.svg$/; + config.module.rules.push({ + test: /\.svg$/, + enforce: 'pre', + loader: require.resolve('@svgr/webpack'), + }); + return config; }; diff --git a/src/components/AttachmentModal.js b/src/components/AttachmentModal.js index f7a83a1146f9..ca854a9ab500 100755 --- a/src/components/AttachmentModal.js +++ b/src/components/AttachmentModal.js @@ -113,6 +113,7 @@ class AttachmentModal extends PureComponent { fileDownload(sourceURL)} onCloseButtonPress={() => this.setState({isModalOpen: false})} /> diff --git a/src/components/HeaderWithCloseButton.js b/src/components/HeaderWithCloseButton.js index 7fe0a2e787fd..45930710da7b 100755 --- a/src/components/HeaderWithCloseButton.js +++ b/src/components/HeaderWithCloseButton.js @@ -7,7 +7,6 @@ import styles from '../styles/styles'; import Header from './Header'; import Icon from './Icon'; import {Close, Download, BackArrow} from './Icon/Expensicons'; -import withLocalize, {withLocalizePropTypes} from './withLocalize'; const propTypes = { /** Title of the Header */ @@ -28,7 +27,8 @@ const propTypes = { /** Whether we should show a border on the bottom of the Header */ shouldShowBorderBottom: PropTypes.bool, - ...withLocalizePropTypes, + /** Whether we should show a download button */ + shouldShowDownloadButton: PropTypes.bool, }; const defaultProps = { @@ -38,6 +38,7 @@ const defaultProps = { onBackButtonPress: () => {}, shouldShowBackButton: false, shouldShowBorderBottom: false, + shouldShowDownloadButton: false, }; const HeaderWithCloseButton = props => ( @@ -62,7 +63,7 @@ const HeaderWithCloseButton = props => (
{ - props.title === props.translate('common.attachment') && ( + props.shouldShowDownloadButton && ( {}, +}; diff --git a/src/stories/Header.stories.js b/src/stories/Header.stories.js index ec18da134fe6..50c832264c0b 100644 --- a/src/stories/Header.stories.js +++ b/src/stories/Header.stories.js @@ -1,3 +1,4 @@ +import React from 'react'; import Header from '../components/Header'; /** @@ -17,7 +18,6 @@ const Template = args =>
; // See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args export const Default = Template.bind({}); Default.args = { - textSize: 'large', title: 'Chats', shouldShowEnvironmentBadge: true, }; diff --git a/src/stories/HeaderWithCloseButton.stories.js b/src/stories/HeaderWithCloseButton.stories.js new file mode 100644 index 000000000000..db9f86f52371 --- /dev/null +++ b/src/stories/HeaderWithCloseButton.stories.js @@ -0,0 +1,23 @@ +import React from 'react'; +import HeaderWithCloseButton from '../components/HeaderWithCloseButton'; + +/** + * We use the Component Story Format for writing stories. Follow the docs here: + * + * https://storybook.js.org/docs/react/writing-stories/introduction#component-story-format + */ +export default { + title: 'Components/HeaderWithCloseButton', + component: HeaderWithCloseButton, +}; + +// eslint-disable-next-line react/jsx-props-no-spreading +const Template = args => ; + +// Arguments can be passed to the component by binding +// See: https://storybook.js.org/docs/react/writing-stories/introduction#using-args +export const Default = Template.bind({}); +Default.args = { + title: 'Attachment', + shouldShowDownloadButton: true, +};