On collapsed sidebars, if no icon for a top-level item is provided, use the first two letters

Created on 29 February 2024, 3 months ago
Updated 12 May 2024, 6 days ago

Problem/Motivation

If we use a default icon, then all new menu items who don't supply a custom icon in code, will have the same icon, which is very confusing.

Steps to reproduce

Proposed resolution

Instead of a default icon, use the first two letters of the menu item name.

Remaining tasks

User interface changes

API changes

Data model changes

āœØ Feature request
Status

Needs work

Version

11.0 šŸ”„

Component
NavigationĀ  ā†’

Last updated 25 minutes ago

No maintainer
Created by

šŸ‡ŗšŸ‡øUnited States KeyboardCowboy

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

  • Issue created by @KeyboardCowboy
  • Assigned to bronzehedwick
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick
  • Issue was unassigned.
  • Status changed to Needs review 2 months ago
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick
  • Pipeline finished with Success
    2 months ago
    Total: 148s
    #120436
  • Status changed to Needs work 2 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    Looking nice! I noticed one thing between collapsed and not expanded. It looks like there is a differnce in line-height or something that is causing a slight shift in the items that are defaulting to two letters. Here are a couple of examples:

  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    Thanks @m4olivei! I can confirm the issue. Investigating now.

  • Status changed to Needs review 2 months ago
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    I found the issue with layout shift on menu collapse, and pushed a commit to fix. Ready for another review. Thanks!

  • Pipeline finished with Success
    2 months ago
    Total: 292s
    #122465
  • Status changed to RTBC 2 months ago
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    This is looking great to me! Thanks for the fix @bronzehedwick.

  • Status changed to Needs work about 2 months ago
  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    Discussed in Slack, so moving to NW again and assigning it to @bronzehedwick since he said he'll work on this.

    ckrina
    @Chris DeLuca @m4olivei wondering how would you envision, when this is in core, how contrib modules could add their icons with this change moving its definition to templates and away from CSS

    Chris DeLuca
    Ahh, good point. I hadnā€™t considered that. I think thereā€™d need to be some more development on it, but my first idea would be to look in a YAML file for a mapping of menu item ids to SVG paths on the file system?

    ckrina
    Yeah, I think moving the traditional strategy using CSS to define icons on a twig template complicates extensibility from what we had so far and itā€™d need some discussion & work.
    We have this Plan/Meta issue where all this could be discussed šŸŒ± [PLAN] Icons for the sidebar Active .

    Chris DeLuca
    We can also move back to icons defined in CSS. Thereā€™s some other disadvantages, but if it makes extensibility easier, maybe itā€™s worth it

    ckrina
    But the changes you are proposing are increasing the scope of the what weā€™ll need to have, so I wonder if there is any way to address the Initials issue without getting into the weeds for this longer conversation?
    I totally agree that the technical strategy is way better, itā€™s just that Iā€™m trying to think about a way to get to the Beta line without increasing the scope

    Chris DeLuca
    Thatā€™s fine, I can move the solution back to icons in CSS
    Iā€™ll work on that now, unless anyone objects

    I've also created šŸ“Œ Decide strategy to customize or provide 1st level menu items' icons Active as a follow-up. Thanks!

  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    I've reverted back to the CSS icons, as per above. The solution for overriding icons is no longer elegant.

    This method requires a little bit more work to extend the icons than the
    original, default icon implementation, as the override will also need to
    set ::before { content: '' } and hide the abbreviation, in addition to
    setting --icon.

    Open to other suggestions.

  • Status changed to Needs review about 2 months ago
  • Pipeline finished with Failed
    about 2 months ago
    Total: 235s
    #123542
  • šŸ‡·šŸ‡øSerbia finnsky

    this button can be without icon.

  • Pipeline finished with Failed
    about 2 months ago
    Total: 199s
    #123642
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    [class*='toolbar-button--icon'] { targets the same elements now as .toolbar-button, so I was consolidating the styles. The code would have the exact same effect split across those two selectors.

    We could use attr() in conjunction with a data-* to store the value, but it would still require the same ::before, so I don't see an advantage.

  • šŸ‡·šŸ‡øSerbia finnsky

    Could you take a look at https://gyazo.com/b860d449b39738c41e181ddb7c4601ae
    As i said this button used in other places aswell. I don't really want to have it always iconic.
    Imo should be special class or attribute attached into this button when no icon i sidebar only.

  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    That would be great, but I'm not seeing how that's possible. We can't detect if an icon is intended from Twig, just print a class usable for icon styling from CSS. This can be solved in the future if we decide to go back to an inline SVG approach, but not with CSS icons.

  • šŸ‡·šŸ‡øSerbia finnsky

    I gonna take a look at this in next couple of days. Thank you.

  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    Could you take a look at https://gyazo.com/b860d449b39738c41e181ddb7c4601ae
    As i said this button used in other places aswell. I don't really want to have it always iconic.
    Imo should be special class or attribute attached into this button when no icon in sidebar menu only. like `--icon-failback` or something.

    Gotcha, I see the problem. I'll see if I can narrow the selector, but I don't think it's possible to move away from the ::before approach or that attr() will make an impact on this problem. I also don't see a way for an icon fallback to work without detecting which items have icons from Twig, which would need the larger refactor.

  • Merge request !203SVG generation #3424744 ā†’ (Closed) created by finnsky
  • Status changed to Needs work about 2 months ago
  • šŸ‡·šŸ‡øSerbia finnsky

    I've added a bit crazy solution with inline svg generation.
    https://gyazo.com/98af20f551a6184be3df90b62bb33170

    it has some problems like we cannot use `inter` font. only safe webfonts. but works good in terms of global button

    Gonna think a bit more about it.

  • Pipeline finished with Success
    about 2 months ago
    Total: 204s
    #124563
  • šŸ‡·šŸ‡ŗRussia kostyashupenko Omsk

    I this this task is related to this https://www.drupal.org/project/navigation/issues/3432173 šŸ“Œ Decide strategy to customize or provide 1st level menu items' icons Active where we need to define one global strategy how we can deliver own / custom icons.

    1. background (mask)
    2. iconic font
    3. embed svg <- this is a winner by the way

    And i think the initial approach with ::before pseudoselector directly on button itself (.toolbar-button) was a bit wrong. Since such kind of things (which should work with own icons, external icons and even 2 letters if no icon defined) requires own wrapper, like .

  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    it has some problems like we cannot use `inter` font. only safe webfonts. but works good in terms of global button

    Sorry, but UI design wise this needs to use the Inter font.

    Also, be aware that the dropdown from the Top Bar and the 1st menu items on the navigation toolbar won't look the same and won't behave the same, so I wouldn't try to force them to use the same button component. Things like the states will need to be diffrerent also.

  • šŸ‡·šŸ‡ŗRussia kostyashupenko Omsk

    Can we get rid of ::before at all in toolbar buttons?
    And to have just

    ... optional 2 first letters...

    With the own tag and specific classname it would be much easier to deliver 2 letters. Also 100% it will be easier to integrate 3rd party icons.
    Please share your opinion

  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    Moving this to major.

  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona
  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona
  • Merge request !7869Resolve #3424744 "On collapsed sidebars" ā†’ (Closed) created by m4olivei
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    m4olivei ā†’ changed the visibility of the branch 3424744-svg-generate to hidden.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    m4olivei ā†’ changed the visibility of the branch 3424744-on-collapsed-sidebars to hidden.

  • Pipeline finished with Failed
    17 days ago
    Total: 171s
    #161661
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    I moved @bronzehedwick's MR over to Drupal core. There were quite a few conflicts, so I'm really not sure if everything is OK there. Take a look see.

  • Pipeline finished with Failed
    17 days ago
    Total: 151s
    #161667
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    bronzehedwick ā†’ changed the visibility of the branch 3424744-on-collapsed-sidebars to hidden.

  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    bronzehedwick ā†’ changed the visibility of the branch 3424744-on-collapsed-sidebars to hidden.

  • Merge request !7874Use abbreviation for default menu items ā†’ (Closed) created by bronzehedwick
  • Pipeline finished with Failed
    17 days ago
    Total: 172s
    #161773
  • Pipeline finished with Failed
    17 days ago
    Total: 190s
    #161776
  • Pipeline finished with Failed
    17 days ago
    Total: 169s
    #161795
  • Pipeline finished with Failed
    17 days ago
    #161829
  • Pipeline finished with Failed
    17 days ago
    Total: 1240s
    #161846
  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    m4olivei ā†’ changed the visibility of the branch 3424744-on-collapsed-sidebars-off-11.x to hidden.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    m4olivei ā†’ changed the visibility of the branch drupal-3424744-3424744-on-collapsed-sidebars-off-11.x to hidden.

  • šŸ‡ØšŸ‡¦Canada m4olivei Grimsby, ON

    To summarize the back channel in Slack. Now that we've got a clean branch agasint core to work with, we're seeing a failed test. That failed test is failing on account of changes to the Twig template that are including the abbreviation for the Top Bar button. The twig template changed gets used by the top bar (you need to drush en -y navigation_top_bar to see it on a node view/edit page). Probably don't want this in that case.

    Should clean that up. Then we might still need to adjust the test depending.

    @skaught correctly pointed out that we'll probably also want to move that failed test (NavigationTopBarTest) from where it is. That's the subject of šŸ› Navigation Test names are disjointed. Active .

  • Pipeline finished with Success
    17 days ago
    Total: 661s
    #161927
  • Status changed to Needs review 17 days ago
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick
  • Status changed to Needs work 17 days ago
  • šŸ‡ŗšŸ‡øUnited States smustgrave

    Reading the issue summary seems like something that could have test coverage added for.

  • Pipeline finished with Failed
    16 days ago
    Total: 52s
    #162506
  • Pipeline finished with Failed
    15 days ago
    #163145
  • Pipeline finished with Failed
    15 days ago
    Total: 54s
    #163146
  • Pipeline finished with Failed
    15 days ago
    Total: 56s
    #163148
  • Pipeline finished with Success
    15 days ago
    Total: 56s
    #163165
  • Pipeline finished with Success
    15 days ago
    Total: 566s
    #163157
  • Pipeline finished with Success
    15 days ago
    Total: 52s
    #163189
  • Pipeline finished with Success
    15 days ago
    Total: 56s
    #163193
  • Pipeline finished with Success
    15 days ago
    Total: 337s
    #163224
  • Pipeline finished with Success
    15 days ago
    #163287
  • Pipeline finished with Success
    15 days ago
    Total: 54s
    #163300
  • Status changed to Needs review 15 days ago
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    @smustgrave I added an abbreviation test. It's my first time writing a Drupal test, so open to any feedback. Thanks!

  • Pipeline finished with Success
    15 days ago
    Total: 544s
    #163842
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    @SKAUGHT aria-hidden="true" is applied to the .toolbar-button__abbreviation element. That should handle the use case you're mentioning.

  • Pipeline finished with Success
    12 days ago
    Total: 566s
    #165779
  • Status changed to Needs work 11 days ago
  • šŸ‡ŗšŸ‡øUnited States smustgrave

    Got around to reviewing the test and made a suggestion for a more open test name for future tests.

    Also can we add before/after screenshots to the issue summary to show the issue, can reuse any of the existing files but should be in the UI section of the summary for quick reviews

  • šŸ‡·šŸ‡øSerbia finnsky

    On my side i still believe we should postpone it until icons logic will not decided:

    https://www.drupal.org/project/drupal/issues/3432173 šŸ“Œ Decide strategy to customize or provide 1st level menu items' icons Active

  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    If this could happen independently it would be great since the existing icon for missing icons looks like "broken" or that an icon is missing. We can always refactor and integrate the logic in the SVG process that ends up being used.

    Also, it would be great if this MR didn't change any SVG file that doesn't really need to change to make it easier to isolate the changes.

  • Assigned to bronzehedwick
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick
  • šŸ‡ŗšŸ‡øUnited States bronzehedwick

    Also, it would be great if this MR didn't change any SVG file that doesn't really need to change to make it easier to isolate the changes.

    Sorry about that @ckrina, those changes snuck in due to IDE automatically inserted newlines at the end of the file. I've pushed a commit to revert that, so those changes should no longer be in the diff.

  • Pipeline finished with Failed
    11 days ago
    Total: 508s
    #166534
  • Pipeline finished with Success
    11 days ago
    Total: 601s
    #166543
  • šŸ‡ŖšŸ‡øSpain ckrina Barcelona

    ckrina ā†’ changed the visibility of the branch 3424744-on-collapsed-sidebars-off-11.x to hidden.

  • Pipeline finished with Success
    3 days ago
    Total: 221s
    #173243
  • Pipeline finished with Success
    3 days ago
    Total: 233s
    #173251
  • Pipeline finished with Success
    3 days ago
    #173273
  • Pipeline finished with Success
    3 days ago
    #173277
  • Pipeline finished with Success
    3 days ago
    Total: 82s
    #173344
  • Pipeline finished with Failed
    3 days ago
    Total: 145s
    #173342
  • Pipeline finished with Canceled
    3 days ago
    Total: 50s
    #173350
  • Pipeline finished with Success
    3 days ago
    #173351
  • Pipeline finished with Success
    3 days ago
    Total: 213s
    #173355
  • Pipeline finished with Success
    2 days ago
    Total: 52s
    #174263
  • Pipeline finished with Success
    2 days ago
    Total: 56s
    #174266
Production build 0.67.2 2024