Problem/Motivation

Currently the Top Bar renders the the local tasks. But there is no logic, order or even an standardized way to add elements to it.

Proposed resolution

  • Provide 3 delimited regions where UI elements will be hooked and rendered.
  • Refactor how the existing local tasks are rendered so they used the standardized system created in this issue.

The three delimited regions are inspired by current designs for the top bar:

Top Bar Regions

  1. Tools: Editorial tools, for instance pictured is a device switcher to aid in previewing content
  2. Context: Contextual information including the title and publish status of the content
  3. Actions: Actions to take on the content. Local tasks present in the Navigation top bar should be initially placed here, to be further refined in follow up issues.

Remaining tasks

User interface changes

None

Introduced terminology

API changes

Data model changes

Release notes snippet

CommentFileSizeAuthor
#27 top-bar.png6.05 KBm4olivei

Issue fork drupal-3484564

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

ckrina created an issue. See original summary.

plopesc’s picture

Assigned: Unassigned » plopesc

Working on the definition of the 3 new areas.

plopesc’s picture

Version: 11.0.x-dev » 11.x-dev

plopesc changed the visibility of the branch 3484564-define-top-bar-regions to hidden.

plopesc changed the visibility of the branch 3484564-define-top-bar-regions to active.

plopesc’s picture

Status: Active » Needs review

Initial round to define the new TopBar render element and the plugin system to define top bar items.

We can iterate from here if the approach is considered valid.

nod_’s picture

Conceptually I don't see an issue. The fact that it's not editable makes sense.

on the PHP implementation i'm not the best person to comment, just pointing out that the region names feels a bit magic, if we're really tryin to enforce the 3 areas i'd use an enum or something a bit more restrictive (and maybe easier to document).

As it is contrib can add anything fairly easily, and i'm not sure it's a feature or not. maybe it's missing wrappers and minimum styling too?

plopesc’s picture

Good point about the enum!

Created and used it as part of TopBar::preRenderTopBar() . Tried to use the enum in the twig template as well, but it was not possible, given that enum support in Twig has been added recently and will not be available until 3.15. Core is now using Twig 3.14.

See https://twig.symfony.com/doc/3.x/functions/enum.html & https://github.com/twigphp/Twig/pull/4352

Regarding the styles, some basic styling is needed. Hopefully a more experienced FE dev could help here.

nod_’s picture

Status: Needs review » Needs work

Let's get some minimal styling going on. just some barebone flexbox layout to replicate the positioning we can see #3484600: Show entity information on the Top Bar

finnsky’s picture

This issue has POC with styles required
https://www.drupal.org/project/drupal/issues/3401826

catch’s picture

Left a (slightly drive-by) review on the MR.

kunalkursija’s picture

I tried applying the patch today to see what functionality is being added. Unfortunately, The patch is failing to apply.
Navigation.module seems to be having conflicts.

kunalkursija’s picture

Tried out the MR, This seems to be a solid way of defining the top bar elements. Thanks @plopesc!

finnsky’s picture

I'm not really sure how to apply styles to nothing :)

Could you please add some test cases?

plopesc’s picture

@finnsky We only need the very basic styles to define the 3 regions:

  • Tools: Aligned to the left
  • Context: Centered
  • Actions: Aligned to the right

Currently, only Actions has any content, the "More Actions" dropdown in entity pages.

nod_’s picture

we can add markup for this

m4olivei’s picture

Assigned: plopesc » m4olivei

I'm not really sure how to apply styles to nothing :)

Could you please add some test cases?

I also see that the local tasks are not rendering with the latest changes. Looks like we need to update the top_bar theme hook to be a render element type and probably do some preprocess.

I'll can work on that, as well as adding some basic styles.

m4olivei’s picture

I've addressed the issue that was preventing local tasks from showing up where appropriate. I've also addressed adding some markup to get local tasks over to the right-hand side. There were already some grid styles in place for that. That can probably be further improved in follow-ups.

I'm looking at the failing test ATM.

m4olivei’s picture

Assigned: m4olivei » Unassigned
Status: Needs work » Needs review

Test is green. Ready for review.

m4olivei’s picture

finnsky’s picture

Applied styles.

plopesc’s picture

Status: Needs review » Reviewed & tested by the community

All the comments by core committers were addressed and the basic styles implemented, I think this one can be marked as RTBC.

catch’s picture

It would be useful if the issue summary could say:

1. What the three top bar items are

2. However they're being defined (quick look at the MR looks like plugins, but then I checked the issue summary and didn't see a mention).

If we're expecting contrib modules to interact with these (I think we are?) then a change record would good too.

m4olivei’s picture

Issue summary: View changes
StatusFileSize
new6.05 KB

I've updated the issue summary per #26.

Will work on a CR as well.

m4olivei’s picture

CR written: https://www.drupal.org/node/3489732

Removing the relevant tags.

Thanks for the suggestions @catch.

  • nod_ committed 3ef3cfe2 on 11.1.x
    Issue #3484564 by plopesc, finnsky, m4olivei, ckrina, catch, larowlan:...

  • nod_ committed dc129a55 on 11.x
    Issue #3484564 by plopesc, finnsky, m4olivei, ckrina, catch, larowlan:...

nod_ credited larowlan.

nod_’s picture

Version: 11.x-dev » 10.5.x-dev
Status: Reviewed & tested by the community » Patch (to be ported)

Committed 3ef3cfe and pushed to 11.1.x. Thanks!

Cherry pick is not clean on 10.5.x, need a MR for it

wim leers’s picture

How will the https://www.drupal.org/project/experience_builder React-powered UI be able to reuse this "Top Bar"? 🤔

finnsky’s picture

Probably some Microfrontends with common context. Just brainstorming. I don't have lot info about ExB.

https://dev.to/nik-bogachenkov/building-micro-frontends-with-vite-react-...

lauriii’s picture

XB won't use this directly (inside XB). This is simply partially driven by needs from Drupal CMS and XB to bring continuity between the Drupal UI and XB (by making changes to the Drupal UI).

finnsky’s picture

Then yeah. We have tiicket to backport all to sdc

catch’s picture

nod_’s picture

Status: Patch (to be ported) » Fixed

per thread on slack we're not backporting the top bar work to 10.x, closing this one

nod_’s picture

Version: 10.5.x-dev » 11.x-dev

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.