Skip to content

Conversation

@mareklibra
Copy link
Contributor

@mareklibra mareklibra commented Sep 12, 2018

What: introduce ExpandCollapse component

Link to Storybook: https://rawgit.com/mareklibra/patternfly-react/ExpandCollapse-sb4/index.html

Additional issues:

Additional info:
Implementation for the Expand Collapse Section is provided.
Patternfly.org Design

The component can be farther used for the "More Information" use-case,
where additional text/components are hidden unless the user clicks
on a link.

Such a per-request rendered content is used for texts exceeding scope of a tooltip or
when the user is expected to copy and paste part of the information.

import { ExpandCollapse } from './index';
import { ALIGN_TYPES } from './constants';

const stories = storiesOf(`${storybookPackageName(name)}/${STORYBOOK_CATEGORY.WIDGETS}/Expand Collapse`, module);
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 Sep 12, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be under STORYBOOK_CATEGORY.FORMS_AND_CONTROLS

);

stories.add(
'ExpandCollapse',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would show the left/center better if we added a div around this with a set width and a border:

<div style={{ width: '400px', border: '1px solid lightgray' }}
  <ExpandCollapse  ...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

Copy link
Member

@serenamarie125 serenamarie125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mareklibra the pattern doc shows that the label changes from "Show Information" to "Hide Information". Is that possible with the component?

Also, is it possible to only show the underline on the text (not the spaces)? Here's a screenshot from the storybook which shows the underline below blank spaces

screen shot 2018-09-12 at 8 49 33 pm

@mareklibra
Copy link
Contributor Author

@serenamarie125 , sure, I will change the underline and add property for text of the expanded state.

Regarding default text values and moving under Forms and Controls:
The component is expected to have multiple use-cases, so far identified are

  • More Information
  • or Expand Collapse Section for forms.

I can imagine more coming in the future.

We can either keep the component under the WIDGETS and let the user just provide proper properties or we can implement specialized components for each of these use cases by providing expected texts or alignment. What do you think? @jeff-phillips-18 , @serenamarie125

@mareklibra mareklibra force-pushed the ExpandCollapse branch 2 times, most recently from 0415ecc to 092e5c9 Compare September 13, 2018 11:06
@coveralls
Copy link

coveralls commented Sep 13, 2018

Pull Request Test Coverage Report for Build 2592

  • 13 of 13 (100.0%) changed or added relevant lines in 2 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage increased (+0.08%) to 80.948%

Totals Coverage Status
Change from base Build 2584: 0.08%
Covered Lines: 3386
Relevant Lines: 3937

💛 - Coveralls

@mareklibra
Copy link
Contributor Author

Changes: the link consists of text only (not the space or icon). Consuming code can provide props for both expanded and collapsed state.

Storybook is updated (but requires cleaning of browser cache).

@jeff-phillips-18
Copy link
Member

jeff-phillips-18 commented Sep 13, 2018

I think that since the text can be set by the application there is no need for multiple components. I still feel this belongs under Forms and Controls to be consistent with ExpandCollapse pattern found on Patternfly.org. More Information is really just expand/collapse isn't it?

Also, can we set the button's focus state to use outline: 0. The focus treatment is really over done. This should be changed generically but in this case it seems really bad to me. The underline is enough to indicate focus in my opinion.

@serenamarie125
Copy link
Member

@mareklibra the storybook link doesn't work for me now. Can you update that so I can approve? As long as we can modify the text & there is the ability to have 2 different labels based on if it's expanded or collapsed we should be fine.

Agree that it likely needs to be in Forms & Controls

@mareklibra mareklibra force-pushed the ExpandCollapse branch 2 times, most recently from 08112c3 to b8cbf55 Compare September 14, 2018 07:08
@mareklibra
Copy link
Contributor Author

mareklibra commented Sep 14, 2018

The storybook worked for me once browser's cache is cleared. Anyway, redeployed to a new branch, can you please have a look?

Changes:

  • moved under Forms & Controls
  • so default texts changed to Hide/Show Advanced Options
  • the button has outline:none on focus

Regarding More Information: the difference is just in text and alignment of the link.

@mareklibra mareklibra force-pushed the ExpandCollapse branch 2 times, most recently from 898fa57 to 019bb66 Compare September 14, 2018 07:23
@serenamarie125
Copy link
Member

@mareklibra I have a couple of more asks ...
1 - the caret should be "selectable" as well as the text
2 - right now the text jumps when the component is selected, I think @jeff-phillips-18 may have some thoughts on why
3 - we should have a line to the right of the link, IMO this should be optional, but shown by default

@mareklibra
Copy link
Contributor Author

@jeff-phillips-18 , thanks, good idea with the use of flex.

Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you update the storybook please?

@mareklibra
Copy link
Contributor Author

Storybook updated

@jeff-phillips-18
Copy link
Member

@mareklibra I'm still not seeing the updates in the storybook

@mareklibra
Copy link
Contributor Author

@jeff-phillips-18 , please excuse late answer.
The link in the PR description has been updated, storybook should work now.
The PR is rebased.

@patternfly-build
Copy link
Collaborator

PatternFly-React preview: https://613-pr-patternfly-react-patternfly.surge.sh

serenamarie125
serenamarie125 previously approved these changes Oct 6, 2018
Copy link
Member

@serenamarie125 serenamarie125 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great @mareklibra thanks for the contribution!

@priley86
Copy link
Member

priley86 commented Oct 8, 2018

hey @mareklibra - this looks excellent to me... I have one suggestion for allowing the consumer to explicitly override the expand/collapse if desired. I think the "controlled" pattern for simple UI state is a nice addition to a component like this. You can see the behavior in my storybook w/ new knob here

Do you mind cherry-picking?

priley86@5bab582

Other than this...PR looks good to go to me!

mareklibra and others added 3 commits October 9, 2018 15:32
affects: patternfly-react

Implementation for the Expand Collapse Section is provided.

The component can be farther used for the "More Information" use-case,
where additional text/components are hidden unless the user clicks
on a link.

Such a per-request rendered content is used for texts exceeding scope of a tooltip or
when the user is expected to copy and paste part of the information.
@mareklibra
Copy link
Contributor Author

mareklibra commented Oct 9, 2018

@priley86 , thanks, cherry-picked.

Last changes:

  • rebased
  • cherry-picked priley86@5bab582
  • added expanded to propTypes and defaultProps
  • storybook updated

@priley86
Copy link
Member

priley86 commented Oct 9, 2018

great! looks good @mareklibra - one last favor... can you update the snapshots? just run yarn test -u and check them in to pass the build...

@lizsurette
Copy link
Contributor

@mareklibra I know I'm late to the party but just wanted to say this looks great! Thanks so much for the contribution and looking forward to making use of it :)

The propType and defaultProps added for the "expanded" property.
@mareklibra
Copy link
Contributor Author

Thanks for the nice feedback :-) I have updated the test snapshot for the expanded prop.

@jeff-phillips-18 jeff-phillips-18 merged commit 31eac90 into patternfly:master Oct 15, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants