From 94e956aa15fc02d26a2bd905df029b4558d5c5d0 Mon Sep 17 00:00:00 2001 From: Jeff Phillips Date: Wed, 24 Oct 2018 14:35:25 -0400 Subject: [PATCH] fix(ExpandCollapse): Fix to export ALIGN_LEFT and ALIGN_CENTER constants (#826) Added the constants to ExpandCollapse rather than requiring applications to expressly import the constants file. Fixes the storybook display of the align type values to show the values rather than the constant. --- .../src/components/ExpandCollapse/ExpandCollapse.js | 11 +++++++++-- .../ExpandCollapse/ExpandCollapse.stories.js | 3 +-- .../components/ExpandCollapse/ExpandCollapse.test.js | 9 ++++----- .../src/components/ExpandCollapse/constants.js | 9 +++++++++ 4 files changed, 23 insertions(+), 9 deletions(-) diff --git a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js index 6167e3c8a1d..b81617cdc36 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js +++ b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.js @@ -5,7 +5,10 @@ import classNames from 'classnames'; import { Button } from '../Button'; import { Icon } from '../Icon'; -import { ALIGN_LEFT, ALIGN_CENTER, ALIGN_TYPES } from './constants'; +const ALIGN_LEFT = 'left'; +const ALIGN_CENTER = 'center'; + +const ALIGN_TYPES = [ALIGN_LEFT, ALIGN_CENTER]; class ExpandCollapse extends React.Component { state = { expanded: false, mirroredExpanded: false }; @@ -54,7 +57,7 @@ ExpandCollapse.propTypes = { textCollapsed: PropTypes.string, /** Text for the link in expanded state */ textExpanded: PropTypes.string, - /** Align the link to the left or center. Default: left. */ + /** Align the link to the left or center. */ align: PropTypes.oneOf(ALIGN_TYPES), /** Flag to show a separation border line */ bordered: PropTypes.bool, @@ -71,4 +74,8 @@ ExpandCollapse.defaultProps = { expanded: false }; +ExpandCollapse.ALIGN_LEFT = ALIGN_LEFT; +ExpandCollapse.ALIGN_CENTER = ALIGN_CENTER; +ExpandCollapse.ALIGN_TYPES = ALIGN_TYPES; + export default ExpandCollapse; diff --git a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.stories.js b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.stories.js index c08fae30365..c85b03c8a52 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.stories.js +++ b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/ExpandCollapse.stories.js @@ -7,7 +7,6 @@ import { name } from '../../../package.json'; import { boolean, select, text, withKnobs } from '@storybook/addon-knobs'; import { ExpandCollapse } from './index'; -import { ALIGN_TYPES } from './constants'; const stories = storiesOf( `${storybookPackageName(name)}/${STORYBOOK_CATEGORY.FORMS_AND_CONTROLS}/Expand Collapse`, @@ -26,7 +25,7 @@ stories.add( withInfo(`This is the ExpandCollapse component.`)(() => (
{ const view = mount( @@ -50,14 +49,14 @@ test('aligned ExpandCollapse', () => { expect(def.find('.expand-collapse-pf-separator')).toHaveLength(1); const left = render( - +
My text
); expect(left.find('.expand-collapse-pf-separator')).toHaveLength(1); const center = render( - +
My text
); @@ -81,14 +80,14 @@ test('ExpandCollapse with separator', () => { expect(noSep.find('.expand-collapse-pf-separator.bordered')).toHaveLength(0); const center = render( - +
My text
); expect(center.find('.expand-collapse-pf-separator.bordered')).toHaveLength(2); const centerNoSep = render( - +
My text
); diff --git a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/constants.js b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/constants.js index 69912e817a9..c14e0390149 100644 --- a/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/constants.js +++ b/packages/patternfly-3/patternfly-react/src/components/ExpandCollapse/constants.js @@ -1,3 +1,12 @@ +/** + * UNUSED/DEPRECATED + * + * These constants have been moved directly into the ExpandCollapse component. + * The separate file constants do not display correctly in storybook and were not exported outside of this file + * so they weren't accessible unless this file was expressly imported. + * + * Leaving this file for the case that an application did expressly import this file. + */ export const ALIGN_LEFT = 'left'; export const ALIGN_CENTER = 'center';