-
Notifications
You must be signed in to change notification settings - Fork 9
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new component TextCollapseByLength #460
Conversation
65e846f
to
49a7e2d
Compare
- Rename to CollapsableText, similar to ExpandableSection - Rename showMore/showLess to moreLabel/lessLabel to avoid sounding like an action - Rename shouldShowAll & collapsedByDefault to collapse so that we can use as controlled prop. - Update propTypes - Use ellipsis - Some minor eslint warnings
} else if (this.state.collapsed) { | ||
return ( | ||
<span> | ||
{children.substring(0, maxLength).trim()}… {this.renderButton(this.expandText, moreLabel)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.expandText
would be undefined
|
||
return ( | ||
<span> | ||
{children} {this.renderButton(this.collapseText, lessLabel)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.collapseText
would be undefined
this.setState({ collapsed: !this.state.collapsed }); | ||
}; | ||
|
||
renderButton(callback, buttonText) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the callback being used here? we're using toggle()
anyway.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems reasonable, can you create a PR to correct them?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This component will let us show more or less of a long piece of text