We need to insert two search blocks (one for narrow, one for wide) into the theme's header. The markup needs to be close to what's at the PoC (https://olivero-poc.netlify.com/).

The search blocks should not work if the search module is disabled, or if the user doesn't have the appropriate permission to perform a search.

One other random note: We may need to create a new region to provide separate place for things like page title, tabs. etc. if we go ahead with using the header region for the site branding block.

Comments

mherchel created an issue. See original summary.

hawkeye.twolf’s picture

StatusFileSize
new5.67 KB

Here's a suggestion of how we could lay out the regions (header, primary_menu, and secondary_menu) in page.html.twig. The crux is that the search block form needs different markup based on which region it gets placed into. I think we can use template suggestions to make that work. As a fallback, we could make a separate region just called "Search" and then print it twice, once in each place where it's needed with different wrappers.

hawkeye.twolf’s picture

FYI, here's some sample code for adding region-specific block suggestions, if we decide to go that route (adapted from Twig Suggest):

/**
 * Implements hook_theme_suggestions_HOOK_alter() for block().
 */
function olivero_theme_suggestions_block_alter(&$suggestions, array $variables) {

  // Add region-specific block theme suggestions.
  // Prevent PHP notices if contrib modules create blocks without this ID.
  if (isset($variables['elements']['#id']) || !empty($variables['elements']['#id'])) {

    // @todo Use entity storage instead of Block class.
    $block = \Drupal\block\Entity\Block\Block::load($variables['elements']['#id']);

    $suggestions[] = 'block__' . $block->getRegion();
    $suggestions[] = 'block__' . $block->getRegion() . '__' . $variables['elements']['#id'];
  }
}
hawkeye.twolf’s picture

Issue summary: View changes
StatusFileSize
new4.14 KB

Here's a PoC for adding search markup according to theme settings, represented by the olivero template variable that doesn't currently exist, rather than the search block(s).

hawkeye.twolf’s picture

StatusFileSize
new4.29 KB

Updating if statements to consider search setting.

hawkeye.twolf’s picture

Next up: I'll tackle preprocessing the search form markup by the end of the week.

mrconnerton’s picture

StatusFileSize
new4.32 KB

Last patch had twig error. this one fixes that and uses the page.header_search variable from #3115429: Create theme settings for mobile menu

hawkeye.twolf’s picture

StatusFileSize
new4.94 KB

Thanks for adding that header_search theme setting, @mrconnorton :) I've added a page preprocess that uses the setting here in this patch, so I'll submit a change to the other issue to take it out of the html preprocess.

hawkeye.twolf’s picture

StatusFileSize
new7.27 KB

Re-roll against latest HEAD.

@mherchel, I noticed that the <div class="secondary-nav__wrapper"> wrapper was removed from page.html.twig. I've added it back here in this patch, but if the deletion was intentional, lemme know and I'll take it out.

hawkeye.twolf’s picture

StatusFileSize
new0 bytes

(bad patch)

hawkeye.twolf’s picture

StatusFileSize
new6.02 KB

Here's a patch to demonstrate a block-based approach as opposed to using theme-settings and loading the search form in hook_preprocess_page().

mherchel’s picture

Thanks! We'll look at this shortly.

Hey, I've been running into an issue with Firefox in Windows high contrast mode. The only solution I can find is to replace the <input type="submit"> with a <button> element (within the search forms).

Can this be folded into this patch? The code would need to look something like this (this is currently in https://github.com/Lullabot/olivero-poc/pull/33)

<button class="header-nav__search-button" aria-label="Toggle Search Form">
    <svg width="24px" height="25px" viewBox="0 0 24 25" version="1.1"
      xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink">
      <title>Search Icon</title>
      <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
        <g id="Group">
          <rect id="Rectangle" fill="#FFFFFF" x="0" y="0" width="24" height="25">
          </rect>
          <g id="search" transform="translate(1.000000, 1.000000)" fill="#0D1214">
            <path
              d="M18,10 C18,14.4183 14.4183,18 10,18 C5.58172,18 2,14.4183 2,10 C2,5.58172 5.58172,2 10,2 C14.4183,2 18,5.58172 18,10 Z M15.7608,18.175 C14.1323,19.3246 12.145,20 10,20 C4.47715,20 0,15.5228 0,10 C0,4.47715 4.47715,0 10,0 C15.5228,0 20,4.47715 20,10 C20,12.6561 18.9645,15.0703 17.2752,16.8609 L21.7071,21.2929 C22.0976,21.6834 22.0976,22.3166 21.7071,22.7071 C21.3166,23.0976 20.6834,23.0976 20.2929,22.7071 L15.7608,18.175 Z"
              id="Shape"></path>
          </g>
        </g>
      </g>
    </svg>
    <div class="header-nav__search-button__close"></div>
  </button>
  <div class="search-wide__wrapper">
    <div class="search-wide__container">
      <div class="search-wide__grid">
        <form role="search" action="">
          <label class="visually-hidden" for="search-wide-input">Search</label>
          <input id="search-wide-input" type="search"
            placeholder="Search by keyword or phrase.">
          <button type="submit">
              <span class="icon--search"></span>
              <span class="visually-hidden">Search</span>
          </button>
        </form>
      </div>
    </div>
  </div>
hawkeye.twolf’s picture

Sure! I'll make new versions of each patch with this added in via hook_form_alter().

hawkeye.twolf’s picture

Assigned: Unassigned » hawkeye.twolf
hawkeye.twolf’s picture

StatusFileSize
new12.95 KB

I forgot to include a few files in the last patch. Here it is again, and with @mherchel's requested changes to the search form submit button markup.

This version of the patch is for the block-based (and IMO preferred) approach.

hawkeye.twolf’s picture

StatusFileSize
new0 bytes

Here's an updated version of the theme settings-based approach, with @mherchel's requested changes added in to change inputs to buttons.

hawkeye.twolf’s picture

StatusFileSize
new10.47 KB

Updating patch from #16 as I forgot to include a file.

hawkeye.twolf’s picture

StatusFileSize
new12.95 KB

Updated block-based approach patch from #15 (improved twig file comment).

hawkeye.twolf’s picture

StatusFileSize
new12.95 KB

Hides block labels.

proeung’s picture

Issue tags: +olivero-sprint-d
proeung’s picture

Status: Active » Fixed

@hawkeye.twolf Thanks for submitting this patch! I just tested your patch and made some minor adjustments, but the two search blocks (narrow and wide) are looking great! https://git.drupalcode.org/project/olivero/-/commit/10e9c47595f07aacc97e...

See the latest tugboat preview here - https://8-x-1-x-dev-2t4d1epwkj8tgwxduizmixhzevqwzi8w.tugboat.qa/

Also, we'll need to render the search form placeholder text and move the search icon to be inline SVG, but we'll take of that in another ticket. Thanks for all of your help in this again!

Status: Fixed » Closed (fixed)

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