Skip to content
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

Introduce a ResizableBox component #10347

Merged

Conversation

chrisvanpatten
Copy link
Member

@chrisvanpatten chrisvanpatten commented Oct 4, 2018

This is a follow-up to #10331 and fixes #10343.

This PR…

  • introduces a ResizableBox component which wraps the re-resizable package to remove some code duplication
  • introduces global/shared classes for resize handles
  • removes the mixins introduced in Try: Larger drag handles #10331, and thus the code duplication (which had existed for a while before that)
  • updates core/image and core/spacer to use this new component

I plan to flesh out the docs, but want to make sure I'm on the right track with this first! Still want to know if I'm on track, but I added additional docs anyway :)

Testing

  • Insert image and spacer blocks
  • Verify there are no visual or functional regressions at various alignments and configurations

@chrisvanpatten chrisvanpatten requested review from tofumatt and a team October 4, 2018 19:43
@chrisvanpatten chrisvanpatten added [Type] Enhancement A suggestion for improvement. General Interface Parts of the UI which don't fall neatly under other labels. [Package] Components /packages/components labels Oct 4, 2018
@tofumatt tofumatt added this to the 4.1 milestone Oct 4, 2018
@tofumatt
Copy link
Member

tofumatt commented Oct 4, 2018

Thanks for jumping on the patch for this! 😄

I'l try to take a look this week, but I might have to wait a bit until after we clear out the 4.0 milestone. 😅

@chrisvanpatten
Copy link
Member Author

@tofumatt Also should note that if you want to take this off your plate, feel free to unassign yourself from the review! I requested you because you had reviewed #10331 but definitely don't feel obligated to review this too :) I know you have a lot going on!

Copy link
Member

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

I dig it! I think we need to add to the components changelog to mention the new component we've introduced. 🤔

After that I think this is good! Thanks for doing this! ❤️


## Usage

Most options are passed directly through to [re-resizable](https://github.com/bokuweb/re-resizable) so you may wish to refer to their documentation. Note that we set the `handleClasses` and `handleStyles` to enable the Gutenberg-specific styles.
Copy link
Member

Choose a reason for hiding this comment

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

I'd argue that we don't so much set them as unset them; it might be worth clarifying exactly what we do here for clarity.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair enough, I can see how it would be slightly confusing… we're setting the prop but unsetting the values. I'll update this :)

@chrisvanpatten
Copy link
Member Author

@tofumatt Clarified the docs and added to the changelog. Might need a check from @gziolo to be sure I updated the changelog correctly (although I do believe it's right; I checked the file history to see how it had been handled previously).

@@ -1,3 +1,9 @@
## 5.0.0 (Unreleased)
Copy link
Member

Choose a reason for hiding this comment

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

Not sure I'd count this as a 5.0.0 feature; it's more like 4.1.0. It isn't a breaking change and it's just an addition.

Copy link
Member Author

Choose a reason for hiding this comment

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

Fair point :)

@tofumatt
Copy link
Member

tofumatt commented Oct 5, 2018

I think the test failures are unrelated, see: #10364.

Once that's merged you should probably rebase and then flag me for another review... but I think this is all good 👍

@chrisvanpatten
Copy link
Member Author

@tofumatt looks like Travis is still failing for the Undo and Split/Merge tests, which is likely unrelated.

@tofumatt
Copy link
Member

tofumatt commented Oct 5, 2018

Yup, that one is an "expected" intermittent failure 😅 (restarted)

@tofumatt
Copy link
Member

tofumatt commented Oct 5, 2018

It keeps failing, maybe something else is up? 😢

@chrisvanpatten
Copy link
Member Author

@tofumatt I’ll try the tests locally. It’s strange it only happens in the one environment in Travis…

@chrisvanpatten
Copy link
Member Author

I got the local test environment set up and I can't get the undo test working there (split/merge seems good now)… but I also can't get the undo test working in master so it seems like just a sporadic/unpredictable/unrelated failure.

@tofumatt
Copy link
Member

tofumatt commented Oct 6, 2018

Ten four, I've kicked the test server again and hopefully it'll work done 🤷‍♂️

@chrisvanpatten
Copy link
Member Author

Strangely I can't "pass" the undo test in master (or this branch) even when I manually follow the instructions (typing in three lines and hitting undo six times). It actually takes me 7 or 8 undos before I'm back to a disabled undo state.

I'm wondering if this might actually be a bug in master right now? I can't reproduce it in 3.9.

@chrisvanpatten
Copy link
Member Author

chrisvanpatten commented Oct 6, 2018

lol okay just as I type that the test finally passes ¯_(ツ)_/¯

@tofumatt I think we're finally clear on this… phew…

(Also should it still be held until 4.1? Will there still be a 4.1 at this point…?)

@tofumatt
Copy link
Member

tofumatt commented Oct 6, 2018 via email

@tofumatt
Copy link
Member

tofumatt commented Oct 6, 2018

In general I’m for merging as much stuff as possible and this is pretty minimal. I’ll have a look tomorrow, been a bit distracted by travel today.

There will be a 4.1 by the way! In general Gutenberg development (including releases) will continue on GitHub, so while I’m not exactly sure how things will work after WordPress 5.0, I think the general idea will be that certain releases of WordPress will pull in a certain release of Gutenberg, if that makes sense.

@chrisvanpatten
Copy link
Member Author

chrisvanpatten commented Oct 7, 2018

@tofumatt totally fair! Travel can’t can knock the wind out of you.

I’m going to try a git blame bisect to see if I can figure out when the undo behaviour changed and if I can figure it out I’ll open a new issue.

@chrisvanpatten
Copy link
Member Author

@tofumatt just opened #10380 which tracks the undo issue. It looks related to the rich text state structure changes, which makes sense.

@tofumatt
Copy link
Member

tofumatt commented Oct 7, 2018 via email

Copy link
Member

@tofumatt tofumatt left a comment

Choose a reason for hiding this comment

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

I dig it 👍

@chrisvanpatten chrisvanpatten merged commit eafd620 into WordPress:master Oct 7, 2018
@chrisvanpatten chrisvanpatten modified the milestones: 4.1, 4.0 Oct 7, 2018
@aduth
Copy link
Member

aduth commented Oct 10, 2018

This introduced changes when running npm install on master because the package-lock.json file wasn't updated.

@aduth
Copy link
Member

aduth commented Oct 10, 2018

#10234

@chrisvanpatten
Copy link
Member Author

Ughhh I'm really sorry @aduth 😭 I should have caught that…

display: none;

// Show the resize handle when selected.
.components-resizable-box__container.is-selected & {
Copy link
Member

@aduth aduth May 2, 2019

Choose a reason for hiding this comment

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

Where do we document how a resizable box becomes "selected" to unhide itself? The current documentation for ResizableBox has no indication of this default hidden state. It was quite the journey to find my way here, as I've found it quite difficult to use the component with the documentation as written.

Copy link
Member Author

Choose a reason for hiding this comment

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

The behavior here was inherited from the original, non-componentized usages of ResizableBox; you can see it in previous PRs as well such as here.

There are probably other use-cases that would provide more valuable context, and could certainly be referenced and improved in the documentation.

Copy link
Member

@aduth aduth May 3, 2019

Choose a reason for hiding this comment

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

While I'd agree it often needs contextualized styling, the main problem for me was that in using the example from the documentation, there is nothing visual which appears. It took me quite a while to realize that the handles are hidden by default.

I understand this is largely a result of how it was used prior to this pull request, but it seems to me that as a generic component, there's no reason to hide those controls by default. I could imagine we might want to keep this behavior for blocks in a block list, but rather than styling in ResizableBox and in individual block stylesheets, it seems like something which should be managed in one of the stylesheets for the block list (apply consistently and exclusively to ResizableBox within blocks).

I could create an issue if it seems reasonable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
General Interface Parts of the UI which don't fall neatly under other labels. [Package] Components /packages/components [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create wrapper component around ResizableBox
3 participants