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

Block Editor: Add controlled inner blocks focus styles. #19929

Closed
wants to merge 3 commits into from

Conversation

epiqueras
Copy link
Contributor

Closes #19886

Screenshots

gif

Types of Changes

New Feature: Controlled inner blocks like template parts and post content now have a distinct style when selected.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code follows the accessibility standards.
  • My code has proper inline documentation.
  • I've included developer documentation if appropriate.
  • I've updated all React Native files affected by any refactorings/renamings in this PR. .

...props
} = this.props;
const { templateInProcess } = this.state;

const classes = classnames( 'block-editor-inner-blocks', {
'has-overlay': enableClickThrough && hasOverlay,
'is-capturing-toolbar': captureToolbars,
'is-controlled': onInput,
'is-selected': isSelected,
Copy link
Member

Choose a reason for hiding this comment

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

Could we add these to BlockList? I'm trying to move the existing classes in #19849.

Copy link
Member

Choose a reason for hiding this comment

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

That's because this particular wrapper will eventually be opt-out: #19910.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, sure.

Copy link
Member

@noahtallen noahtallen Mar 18, 2020

Choose a reason for hiding this comment

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

I've moved this functionality to block-list-block now. Does that change make sense??

@epiqueras epiqueras added the Needs Design Feedback Needs general design feedback. label Jan 28, 2020
@shaunandrews
Copy link
Contributor

This feels incredible similar to the current Spotlight mode, but with different styling. Maybe we should try fading all the other elements away, rather than introducing the dark overlay.

Fade Out

@epiqueras
Copy link
Contributor Author

Feel free to tweak the shadow values.

@jasmussen
Copy link
Contributor

jasmussen commented Jan 30, 2020

You folks move so fast, it's wonderful to see!

This "focus mode"/isolation mode is in principle not a bad idea. Variations of it have been explored in a number of mockups, and the goal, nearly always is to:

  • focus attention on where it should be
  • in the case of template parts, make it clear changes are global

The 2nd one is probably the most important, and it affords the opportunity to add an "Are you sure" dialog when you exit editing the template part, and a spot to explain that — hey, this change affects every page! As such, the idea, the implementation, both feel like they are veering in the right direction. Kudos for the energy.

I wonder though, whether this is the right time to implement it or not. It’s not a bad idea, but it might be one that should be postponed until we know we need it.

The G2 interface (#18667) is likely going to simplify a number of things, we might even consider retiring "spotlight mode" entirely, opening up alternate treatments to this, as Shaun alludes to.

More importantly, we might all think it's going to be important to make it clear to users that they are editing a global part, the fact is we don't actually know for sure yet that this is a problem.

By distinguishing between a template part and any other block, we may in fact add confusion: why is this block highlighted but not that block? — and since we are already looking at batching multiple template part edits together in an on-publish prompt, we already have an opportunity to inform the users of what they are doing.

To summarize: this may be the right idea and the right solution, but because we don't know that for sure yet, maybe we should wait!

@epiqueras
Copy link
Contributor Author

we don't actually know for sure yet that this is a problem.

Try editing a template part, it's very hard to tell if you are editing it or the blocks right after it without opening the block navigator.

why is this block highlighted but not that block?

That can easily be explained somewhere like the breadcrumb or where the button to exit the code view appears.

@epiqueras
Copy link
Contributor Author

Any updates on this from design?

@shaunandrews
Copy link
Contributor

Here's a quick mockup in Figma:

Highlight Template Partial

@mapk
Copy link
Contributor

mapk commented Feb 21, 2020

That last one from @shaunandrews is spot on! I suggest that be the direction we go. All my efforts were leading in that direction as well.

Let's just maintain the same amount of padding above the text within the selected template-part that initially shows in the unselected view. Once the template-part is focused, the padding above the text gets a little tight. Adding the margin for the block toolbar with the "pull away" effect is totally worth keeping. The breadcrumb indicator is unobtrusively informative as well. Really good work! 😍

@epiqueras epiqueras force-pushed the add/controlled-inner-blocks-focus-styles branch from 7e270ff to 821c25c Compare February 25, 2020 12:58
@github-actions
Copy link

github-actions bot commented Feb 25, 2020

Size Change: +261 B (0%)

Total Size: 857 kB

Filename Size Change
build/block-editor/index.js 100 kB +57 B (0%)
build/block-editor/style-rtl.css 11 kB +102 B (0%)
build/block-editor/style.css 11 kB +102 B (0%)
ℹ️ View Unchanged
Filename Size Change
build/a11y/index.js 998 B 0 B
build/annotations/index.js 3.43 kB 0 B
build/api-fetch/index.js 3.39 kB 0 B
build/autop/index.js 2.58 kB 0 B
build/blob/index.js 620 B 0 B
build/block-directory/index.js 6.02 kB 0 B
build/block-directory/style-rtl.css 760 B 0 B
build/block-directory/style.css 760 B 0 B
build/block-library/editor-rtl.css 7.23 kB 0 B
build/block-library/editor.css 7.24 kB 0 B
build/block-library/index.js 111 kB 0 B
build/block-library/style-rtl.css 7.42 kB 0 B
build/block-library/style.css 7.43 kB 0 B
build/block-library/theme-rtl.css 669 B 0 B
build/block-library/theme.css 671 B 0 B
build/block-serialization-default-parser/index.js 1.65 kB 0 B
build/block-serialization-spec-parser/index.js 3.1 kB 0 B
build/blocks/index.js 57.6 kB 0 B
build/components/index.js 191 kB 0 B
build/components/style-rtl.css 15.7 kB 0 B
build/components/style.css 15.7 kB 0 B
build/compose/index.js 6.21 kB 0 B
build/core-data/index.js 10.6 kB 0 B
build/data-controls/index.js 1.04 kB 0 B
build/data/index.js 8.2 kB 0 B
build/date/index.js 5.37 kB 0 B
build/deprecated/index.js 772 B 0 B
build/dom-ready/index.js 568 B 0 B
build/dom/index.js 3.06 kB 0 B
build/edit-post/index.js 91.2 kB 0 B
build/edit-post/style-rtl.css 8.52 kB 0 B
build/edit-post/style.css 8.51 kB 0 B
build/edit-site/index.js 5.07 kB 0 B
build/edit-site/style-rtl.css 2.53 kB 0 B
build/edit-site/style.css 2.53 kB 0 B
build/edit-widgets/index.js 4.43 kB 0 B
build/edit-widgets/style-rtl.css 2.58 kB 0 B
build/edit-widgets/style.css 2.58 kB 0 B
build/editor/editor-styles-rtl.css 381 B 0 B
build/editor/editor-styles.css 382 B 0 B
build/editor/index.js 44 kB 0 B
build/editor/style-rtl.css 3.97 kB 0 B
build/editor/style.css 3.96 kB 0 B
build/element/index.js 4.45 kB 0 B
build/escape-html/index.js 733 B 0 B
build/format-library/index.js 7.09 kB 0 B
build/format-library/style-rtl.css 502 B 0 B
build/format-library/style.css 502 B 0 B
build/hooks/index.js 1.93 kB 0 B
build/html-entities/index.js 621 B 0 B
build/i18n/index.js 3.49 kB 0 B
build/is-shallow-equal/index.js 710 B 0 B
build/keyboard-shortcuts/index.js 2.3 kB 0 B
build/keycodes/index.js 1.69 kB 0 B
build/list-reusable-blocks/index.js 2.99 kB 0 B
build/list-reusable-blocks/style-rtl.css 226 B 0 B
build/list-reusable-blocks/style.css 226 B 0 B
build/media-utils/index.js 4.84 kB 0 B
build/notices/index.js 1.58 kB 0 B
build/nux/index.js 3.01 kB 0 B
build/nux/style-rtl.css 616 B 0 B
build/nux/style.css 613 B 0 B
build/plugins/index.js 2.54 kB 0 B
build/primitives/index.js 1.5 kB 0 B
build/priority-queue/index.js 780 B 0 B
build/redux-routine/index.js 2.84 kB 0 B
build/rich-text/index.js 14.3 kB 0 B
build/server-side-render/index.js 2.55 kB 0 B
build/shortcode/index.js 1.7 kB 0 B
build/token-list/index.js 1.27 kB 0 B
build/url/index.js 4.01 kB 0 B
build/viewport/index.js 1.61 kB 0 B
build/warning/index.js 1.14 kB 0 B
build/wordcount/index.js 1.18 kB 0 B

compressed-size-action

@epiqueras
Copy link
Contributor Author

gif

@epiqueras
Copy link
Contributor Author

G2 makes it look slick @youknowriad 👏

@noahtallen noahtallen force-pushed the add/controlled-inner-blocks-focus-styles branch from ff4f22c to b31e3db Compare March 18, 2020 00:44
@noahtallen
Copy link
Member

I was looking at picking this up again today. Should the "focus mode" styles be consistent with what we're doing here?

@@ -121,6 +121,7 @@ function BlockListBlock( {
'is-focus-mode': isFocusMode,
'has-child-selected': isAncestorOfSelectedBlock,
'is-block-collapsed': isAligned,
'is-focus-container': name === 'core/template-part',
Copy link
Member

Choose a reason for hiding this comment

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

We need to create this class in a more extensible way. Before, with InnerBlocks, we added our custom styles if InnerBlocks had the onInput prop and if it or one of its children was selected.

@noahtallen
Copy link
Member

This is what it looks like right now. It feels a little choppy because selecting blocks in the editor jerks everything around a bit (and because my gif software is low framerate!)

2020-03-17 18 49 42

@jasmussen
Copy link
Contributor

I was looking at picking this up again today. Should the "focus mode" styles be consistent with what we're doing here?

Yes this is an excellent point, and I think we should be changing the style of the effect in this PR to match that of what focus mode does.

@noahtallen
Copy link
Member

noahtallen commented Mar 18, 2020

Cool! That makes it easy to stay consistent if we did ever want to update focus mode to be similar to the mockup above.

@MichaelArestad
Copy link
Contributor

I'm thinking we should probably shelve this for now in favor of just using the usual block focus styles.

@noahtallen
Copy link
Member

Yeah, that sounds reasonable. I'll close this PR out since the styles basically just set a massive background shadow over the rest of the page. (And since it's quite stale at this point!) I investigated triggering the focus styles just for the template part block probably 4 weeks ago but didn't make any progress on it. (There was some oddity with detecting when just the template part block was selected that I didn't figure out.) A new PR could be opened once someone wants to pick this up again 👍

@noahtallen noahtallen closed this Apr 28, 2020
@aristath aristath deleted the add/controlled-inner-blocks-focus-styles branch November 10, 2020 14:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Needs Design Feedback Needs general design feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Edit site: Template part focus styling
7 participants