Make Excerpt more predictable to work with #71
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Part of hypothesis/h#9808
This PR is an alternative to #69, with the same motivation, making it more intuitive to work with the
Excerptcomponent, but taking a more pragmatic approach, as suggested in #69 (review)This PR applies the next changes:
For example, previous to these changes, if
inlineControlswastrue,collapsedandonToggleCollapsedwould be ignored.inlineControl: trueandinlineControl: false). That allows to define other props which are only relevant for one of the two cases, like inline control customizations (texts, styles and classes).If one tries to accidentally provide these props for the other "branch", the static type checks will warn you.
As the point above, this also helps preventing some props from being accidentally ignored.
inlineControlstoinlineControl, since it handles the rendering of one control only.collapsetocollapsed, since it sounds more natural.shadowprop that handles the rendering of the shadow that indicate there's hidden content, so there's less magic or surprising implicit behavior.It does keep showing by default only when
inlineControlisfalse, to keep the behavior closer to how it currently is, but any explicitly provided value will take precedence.collapsedprop now defaults to true, which was the behavior wheninlineControlswastrue. This makes it more consistent for both excerpts with and without inline controls.inlineControlprop is now mandatory, to make the intention more explicit. But we were already explicitly providing it in every use of the Excerpt anyway.Todo