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

Navigation: Implement new design for sub-menus #19681

Merged
merged 85 commits into from
Feb 3, 2020

Conversation

retrofox
Copy link
Contributor

@retrofox retrofox commented Jan 15, 2020

Description

This PR improves the sub-menus for the Navigation block. Significant changes:

  • Apply position absolute to sub-menus, removing the block movements when a sub-menu is opened/closed, making the UX less stressful for the user.
  • Propagate text and background colors to the sub-menus.
  • Apply Light/Dark styles only when it doesn't have a custom background color.
  • Apply the border-color getting its value from text color (to be defined/under discussion)

Fixes #18310

Design

The final design to implement on this PR was defined in #18310:

About technical implementation

We need to keep in mind that this PR propagates the color values from the Navigation block to each Navigation Item. It simplifies applying the styles via CSS, and get ready the code to apply custom colors to sub-menus/sub-items.

Tasks on this PR:

  • Propagate the color changes for background and text through to all submenus

How has this been tested?

Screenshots

image

Types of changes

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • My code has proper inline documentation.

@retrofox retrofox force-pushed the update/navigation-add-background-color branch 2 times, most recently from e7abf4a to 96bce70 Compare January 15, 2020 21:28
@retrofox retrofox force-pushed the update/navigation-submenu-new-design branch from aae0082 to 7b7db07 Compare January 15, 2020 22:28
@retrofox retrofox changed the base branch from update/navigation-add-background-color to master January 15, 2020 22:28
@retrofox retrofox added the [Type] Enhancement A suggestion for improvement. label Jan 15, 2020
background-color: $dark-style-sub-menu-background-color;
}
}

Copy link
Contributor

@apeatling apeatling Jan 16, 2020

Choose a reason for hiding this comment

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

Are these styles going to be portable to the front end and shared?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Are these styles going to be portable to the front end and shared?

Probably(?). I left the code there in case it doesn't set up background color. Guessing that transparent could be a problem. So it will apply the default background-color as long it doesn't already define a custom one.
Something to keep discussing, btw.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Something like this:

	// No background color - Default / Light styles
	&:not(.has-background-color) .wp-block-navigation-link > .block-editor-inner-blocks {
		background-color: $light-style-sub-menu-background-color;
	}

Copy link
Contributor

Choose a reason for hiding this comment

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

I was talking about all the styles, not just the lines above. I was hoping we'd have a single stylesheet that can apply navigation structure to both the editor and the front end. Colors could be separated so they apply even in situations where you've set a different block style in the future and the structural look is totally different.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

... was hoping we'd have a single stylesheet that can apply navigation structure to both the editor and the front end.

That makes totally sense to me. Let's find a way to isolate and consume these from both sides.

position: absolute;
right: 0;
top: 50%;
border-left: 4px solid transparent;
Copy link
Contributor Author

@retrofox retrofox Jan 17, 2020

Choose a reason for hiding this comment

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

Can we consider using an icon or char instead of a border technique? Keep in mind that, at least for now, we have only two ways to apply colors: color and background-color. Applying border-color will be a pain.
We can use dashicons or even SVG.

:this: is no true, we can propagate the text color from the Navigation block and apply the border color with the same value.

@retrofox retrofox added the [Feature] List View Menu item in the top toolbar to select blocks from a list of links. label Jan 20, 2020
@retrofox retrofox changed the title [wip] Navigation: Implement new design for sub-menus Navigation: Implement new design for sub-menus Jan 20, 2020
@retrofox retrofox force-pushed the update/navigation-submenu-new-design branch 2 times, most recently from c6a7c66 to aeeec37 Compare January 21, 2020 22:21
Comment on lines 83 to 101
min-height: $navigation-min-height;
align-items: center;

> .wp-block-navigation-link {
display: flex;
min-height: $navigation-min-height;
margin-top: 0;
margin-bottom: 0;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@frontdevde, not sure if it's the correct implementation. The idea behind this is to fit the .wp-block-navigation-link in height to its container.

@obenland
Copy link
Member

@shaunandrews Do you think you'll have a chance today to try out these changes?

@apeatling
Copy link
Contributor

This is starting to come together nicely! I think it could use a design lookover, especially around padding, borders, and spacing both in the editor and front end.

@apeatling apeatling added the Needs Design Feedback Needs general design feedback. label Jan 23, 2020
@@ -271,12 +267,18 @@ function register_block_core_navigation() {
'customTextColor' => array(
'type' => 'string',
),
'valueTextColor' => array(
Copy link
Member

Choose a reason for hiding this comment

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

Which "value" is that? Could we find a more descriptive name here?

Copy link
Contributor Author

@retrofox retrofox Jan 23, 2020

Choose a reason for hiding this comment

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

This value (already removed) came from the use-colors hook. I had modified introduced the ability to set up this attribute from there, too.
The reason was to be able to pick up the color value of the text, independently if it was defined using a custom color or a palette color, to apply to the border-color property.
I've removed all this stuff and replaced it using the CSS currentColor property.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I've restored these changes. Going to explain why in the use-colors hook change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Basically this attribute will store the color value beyond how it was defined, either picking up from the colors palette or using the custom color panel.

@retrofox retrofox marked this pull request as ready for review January 23, 2020 18:17
@retrofox retrofox force-pushed the update/navigation-submenu-new-design branch from 84d4d56 to a039f32 Compare February 3, 2020 17:38
@retrofox retrofox merged commit 83e26a8 into master Feb 3, 2020
@retrofox retrofox deleted the update/navigation-submenu-new-design branch February 3, 2020 22:21
@retrofox
Copy link
Contributor Author

retrofox commented Feb 3, 2020

Thanks, folks for reviewing and helping with the development. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Feature] List View Menu item in the top toolbar to select blocks from a list of links. Needs Design Feedback Needs general design feedback. [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Navigation Block: sub-menu items design
8 participants