Make it compatible with D10.3 experimental core Navigation ad Navigation Top Bar modules

Created on 11 July 2024, 9 months ago
Updated 18 July 2024, 9 months ago

Problem/Motivation

I'm switching my projects from toolbar and gin_toolbar etc to using the new core 'navigation' and 'navigation_top_bar' modules.
It would be nice that this module also adds a 'Geysir' action to activate/deactivate geysir insde the 'More actions' in the Top bar that is created by the 'navigation_top_bar' module.

Feature request
Status

Active

Version

2.1

Component

Code

Created by

🇧🇪Belgium flyke

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

Comments & Activities

  • Issue created by @flyke
  • 🇧🇪Belgium flyke

    BTW I fixed this in a custom module where I make other improvements and changes to the Navigation and Navigation Top Bar.

    /**
     * Implements hook_preprocess_HOOK().
     *
     * Make general changes to the Navigation Top Bar.
     */
    function mymodule_preprocess_top_bar(array &$variables): void {
    
      // Add geysir to the top bar from core's navigation_top_bar module.
      if (\Drupal::service('module_handler')->moduleExists('geysir')) {
        $variables['local_tasks']['#local_tasks']['geysir'] = [
          '#theme' => 'top_bar_local_task',
          '#link' => [
            '#type' => 'html_tag',
            '#tag' => 'button',
            'child' => [
              'icon' => [
                '#type' => 'html_tag',
                '#tag' => 'span',
                '#attributes' => [
                  'class' => ['geysir-icon'],
                ],
              ],
              'text' => ['#plain_text' => t('Geysir')]
            ],
            '#attributes' => [
              'class' => ['toolbar-icon-geysir'],
              'aria-pressed' => 'false',
              'type' => 'button',
            ],
            '#attached' => [
              'library' => [
                'geysir/geysir-toolbar',
              ],
            ],
          ],
        ];
      }
    }

    And in CSS:

    .toolbar-icon-geysir{
        border: none;
        background: inherit;
        width: 100%;
        text-align: left;
    }
    
    .geysir-icon:before {
        content: '☐';
    }
    .geysir-icon {
        display: inline-block;
    }
Production build 0.71.5 2024