WordPress / gutenberg

The Block Editor project for WordPress and beyond. Plugin is available from the official repository.
https://wordpress.org/gutenberg/
Other
10.39k stars 4.15k forks source link

Navigation block: Add support for separators between menu items. #23293

Open alaczek opened 4 years ago

alaczek commented 4 years ago

A popular design pattern is to have some sort of separator between top-level menu items.

These could take many forms, but two very popular are dots and dashes:

image

image

How could we introduce those? My first thought was via block styles but maybe there's a better way to offer more flexibility with choosing the separator?

talldan commented 4 years ago

Great point @alaczek. It could also be a separate block.

There's already a core Separator block that would work in vertical navigation menus.

Generally in horizontal navigations the separator is more for styling, whereas in vertical menus it's often used to divide links up into logical sections, but a block could serve both purposes.

Thinking technically, if the nav menu orientation were exposed as part of the new Block Context API, a separator block could be smart enough to use that to determine how it should appear.

ntsekouras commented 4 years ago

Maybe this could be handled with an object containing information about the separator and apply the effects with css in before / after content property? This will have of course the limitations of supporting content for the content property, but would work for most cases since the separator is something simple and usually a single character or small image.

I am talking about an object since it probably must have more configuration, ex nested menus. Do we apply it to all menu items?

In a simple one level horizontal menu case it could work with just setting the separator character.

This would be simpler than inserting a new block between each menu item and could be targeted only to horizontal menus.

draganescu commented 4 years ago

This issue has been discussed on Slack in the weekly Navigation Sync meeting.

There are at least two options here to explore in the issue before we begin implementing:

draganescu commented 4 years ago

Howdy @shaunandrews 👋 I will remove this issue from the project as it is not a requirement for the navigation editor to support.

shaunandrews commented 4 years ago

Here's a quick look at how the Navigation block could add support for decorative separators:

navigation separator

mtias commented 4 years ago

This seems like it should be a simple to execute styling option, not a block or anything like that.

cpapazoglou commented 4 years ago

Initial commit on addressing the separators in the navigation block https://github.com/WordPress/gutenberg/pull/25339

ZebulanStanphill commented 4 years ago

Quoting my comment on #25339:

I think adding this option is a bad idea. Can't this sort of thing be handled entirely by theme styles? And shouldn't it? It seems like a recipe for inconsistent design to allow the user to choose different separators for different Navigation blocks. That's the job of the theme (and possibly the upcoming Global Styles feature). I already think the option to show/hide the submenu indicator was a mistake. I really, really don't think we should be adding even more options like it.

mtias commented 4 years ago

I think we can leave this one on pause for a bit and see what feedback we get from theme and pattern creators. The balance between complexity and usefulness seems to lean a bit on the wrong side.

jasmussen commented 3 years ago

Coming in fresh to this one, my first instinct was the same as Niks in https://github.com/WordPress/gutenberg/issues/23293#issuecomment-655418526.

This is something pseudo before/after CSS can accomplish this, making it more of a theme issue than anything else. I did a little testing. This CSS adds a slash separator between menu items:

.wp-block-navigation-link::after {
    content: "/"
}

It works in the editor and frontend, though not beautifully:

Screenshot 2021-01-26 at 09 35 24

That could be improved with a little more CSS rules. And general improvements to the the markup for the navigation block front and editor views will also benefit this.

draganescu commented 3 years ago

@jasmussen that's yet another argument to close this issue, right?

jasmussen commented 3 years ago

I would say so yes, with the option to reopen or revisit if / when it becomes relevant again.

mtias commented 3 years ago

I think it's still worth exploring solutions that allow the user to edit these, but should not be high priority.

annezazu commented 2 years ago

As part of the twelfth call for testing for the FSE Outreach Program, feedback came in around how it's not currently possible to create button like menu items using the navigation block:

I ran into two primary issues with this experiment. One of the problems I had a year ago with FSE Outreach 4 was creating a menu that had button-like links. This basic design is still impossible with the Navigation block, at least with the core design tools. Users can add a background to the entire Navigation block but not to the individual menu items. How did I do it? I used a Buttons block instead. The more I think about it now, the more I like the Buttons block alternative. However, there is no way to wrap this in a <nav> tag to define it as a navigation element.

Here's the design in question:

pizza-button-links

Felt relevant to share here when considering how to add separators between menu items, even if that separator is just simply space between.

jasmussen commented 2 years ago

Nice one Anne, it seems like if individual Page Links received the ability to employ background & text colors, as well as padding control and perhaps even border and border radius, combined with setting a gap of 1px, you'd be able to accomplish that design. The gap (block spacing) is already possible, the other items should be possible by editing theme.json manually, but might be worth ticketing separately. One half of it would be surfacing those properties no the Page Link inspector so you could apply the style piecemeal or using multi-select. The other half would be surfacing the Page Link block in global styles, so you could apply it across all instances at once.

mohanrangasamy commented 2 years ago

Here's a quick look at how the Navigation block could add support for decorative separators:

navigation separator

Hi Shaun please share some references for the same block

mrfoxtalbot commented 1 year ago

This would be a lovely feature to have, +1.

UltimateByte commented 10 months ago

Hi Shaun please share some references for the same block

That would be awesome. I feel like it's really missing when customizing WordPress websites via full site editing and that's how I ended up on this issue.

I would also add that to me, given how Gutenberg has evolved into full site editing, it has become a much higher priority feature.

draganescu commented 10 months ago

I wonder if this should be style variations of the block provided by the theme or a plugin?

UltimateByte commented 10 months ago

I wonder if this should be style variations of the block provided by the theme or a plugin?

Some menu blocks provided by third parties have this feature. But it's so simple and essential that for me it should be added to the core.

Dont hesitate to upvote or downvote this comment to show your thoughts. 👍 👎

margaretschneider commented 10 months ago

Giving this one a +1; it would help me a lot while working on a client site with an FSE theme.

draganescu commented 9 months ago

There are two problems with this in core (none of which are blocking - for anyone who would like to explore with code):