I am starting to demo updated, Olivero-based themes to clients and have had 2 request reductions in the initial empty space above the site header/branding elements.

That is, they'd like their logo and menu to be more flush with the top of the page.

I can see a min-height of 11.25 for these elements. I took an initial stab changing these values to "min-height: inherit;" and some other tweaks, but with the js-interplay the body seems to jump and I can't figure out everything I need to change to keep it a smooth transition depending on if viewing:

  • site normally at top (initial visit)
  • scrolling down menu not expanded
  • scrolling down menu expanded

Could this either:

  • be an option to have the header/branding flush with the page top, or
  • some documentation/explanation of the code that needs to be changed to reduce or remove the empty space
CommentFileSizeAuthor
#37 mobile_header.png88.01 KBoswa_cabrera
#36 tablet_header.png101.04 KBoswa_cabrera
#30 checkbox-after-patch.png3.43 KBgaurav-mathur
#30 after-patch-olivero-header.png17.04 KBgaurav-mathur
#30 before-patch-olivero-header.png27.35 KBgaurav-mathur
#29 3264319-after-uncheck-checkbox.png242.44 KBpradipmodh13
#29 3264319-after-patch.png214.16 KBpradipmodh13
#29 3264319-before-patch.png242.44 KBpradipmodh13
#28 3264319-22.patch7.27 KBsmartsystems160
#28 3264319-25.patch7.41 KBsmartsystems160
#25 3264319-25.patch7.41 KBsmartsystems160
#22 3264319-22.patch7.27 KBsmartsystems160
#21 3264319-21.patch7.42 KBsmartsystems160
#20 3264319-20.patch7.42 KBsmartsystems160
#19 3264319-19.patch6.94 KBsmartsystems160
#18 3264319-18.patch8 KBsmartsystems160
#17 after-patch-unchecked-remove-extra-space.png586.35 KBpradipmodh13
#17 after-patch-checked-remove-extra-space.png586.46 KBpradipmodh13
#17 before-patch-3264319.png206.07 KBpradipmodh13
#16 3264319-16.patch5.51 KBnitin shrivastava
#15 3264319-15.patch7.51 KBshivam-kumar
#14 3264319-14.patch7.65 KBshivam-kumar
#13 after-header.png101.04 KBsmartsystems160
#13 after-theme-config.png144.84 KBsmartsystems160
#13 patch-success.png125.67 KBsmartsystems160
#13 patch-file-location.png74.56 KBsmartsystems160
#13 before-theme-config.png119.57 KBsmartsystems160
#13 before-header.png130.04 KBsmartsystems160
#13 fix_olivero_extra_header_space-3264319-14410497.patch23.19 KBsmartsystems160
#9 After patch ot.png101.06 KBAamir M
#9 Before patch ot.png80.85 KBAamir M
#9 Screenshot from 2022-07-27 12-17-58.png121.64 KBAamir M
#7 3264319-7.patch1.18 KBanjali_jha
#5 aftercode-applied.png30.92 KBanjali_jha
#5 beforecode-applied.png27.91 KBanjali_jha

Comments

W01F created an issue. See original summary.

w01f’s picture

Issue summary: View changes
w01f’s picture

For anyone else that might be interested, I found the following css overrides did the trick in my case. Any suggestions for improvements, etc. are greatly appreciated, and I still think having a simple toggle option for similar functionality baked in would be nice.

@media (min-width: 75rem) {
  body:not(.is-always-mobile-nav) .site-header__fixable {
    position: fixed;
    z-index: 102;
    top: -4.5rem;
    max-width: 98.125rem;
  }
  body:not(.is-always-mobile-nav).toolbar-vertical.toolbar-fixed .site-header__fixable, body:not(.is-always-mobile-nav).toolbar-horizontal.toolbar-fixed .site-header__fixable {
    top: -2.0625rem;
  }
    body:not(.is-always-mobile-nav).toolbar-horizontal.toolbar-fixed.toolbar-tray-open .site-header__fixable {
      top: 0.4375rem;
  }

  .site-header {
    min-height: 2.5rem;
  }
}
w01f’s picture

Status: Active » Needs review
anjali_jha’s picture

StatusFileSize
new27.91 KB
new30.92 KB

Applied above code successfully.. Adding results as screenshots..

mherchel’s picture

Title: Option for reduced empty space above header/branding » Olivero: Add option for reduced empty space above header/branding
Project: Olivero » Drupal core
Version: 8.x-1.x-dev » 9.5.x-dev
Component: Code » Olivero theme
Category: Support request » Feature request
anjali_jha’s picture

StatusFileSize
new1.18 KB
Aamir M’s picture

Assigned: Unassigned » Aamir M
Aamir M’s picture

Assigned: Aamir M » Unassigned
Status: Needs review » Reviewed & tested by the community
StatusFileSize
new121.64 KB
new80.85 KB
new101.06 KB

Verified and tested patch #7 on Drupal 9.5.x-dev. Patch applied successfully and looks good to me.

Testing steps:
1. Goto admin/Appearance
2. Set Olivero theme in the Administration theme (Scroll down and see)
3. Save configuration
4. Observe the spacing above the Heading
5. Apply the patch
6. Reload the page. Now observe the spacing is reduced above Heading

Testing Result:
1. After applying the patch empty space above the header is reduced

Can be moved to RTBC

mherchel’s picture

Status: Reviewed & tested by the community » Needs work

The patch above doesn't pass tests (see where it says "Custom commands failed"), so it should not be RTBC.

In addition, this patch changes the overall design of Olivero's header, which we do not want.

w01f’s picture

Just jumping back in here to comment/clarify... I'm not recommending an outright change to Olivero - I'm sure the design team has a reason for a tall header (aside: is that rationale discussed somewhere?).

As the initial ticket title states, I'm merely suggesting adding a potentially toggleable option for a narrow or shorter header, as I've now had 4 clients directly ask why the header is a foot high and to reduce it, so I can easily see this becoming a common request.

For an example of what I'm suggesting as an option, implemented responsively, you can look at www.kobejet.com - which uses Olivero as the base theme with a simple css style tweak sheet layered on top.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smartsystems160’s picture

Status: Needs work » Needs review
StatusFileSize
new23.19 KB
new130.04 KB
new119.57 KB
new74.56 KB
new125.67 KB
new144.84 KB
new101.04 KB

Attached is a patch that adds the feature on the theme configuration to remove the extra header space

Steps: (Tested on Drupal ^10.0.x)

1. Upload patch to the /web folder of your Drupal install.
2. cd to the /web folder
3. Apply patch using git apply -v [patchfilename.patch]
4. Go to Appearance => Olivero => Settings
5. Check the box "Remove Extra Space" under Extras section at the bottom of page
6. Save Configuration
7. Clear Cache
8. Extra space should be removed.
9. To add extra space back, Repeat Step 5 and uncheck "Remove Extra Space" and Save.

shivam-kumar’s picture

StatusFileSize
new7.65 KB

Have fixed the Custom commands failed errors, coming at the patch of comment #13.

shivam-kumar’s picture

StatusFileSize
new7.51 KB

Have fixed the Custom commands failed errors, coming at the patch of comment #14.

nitin shrivastava’s picture

StatusFileSize
new5.51 KB

try to fix #15

pradipmodh13’s picture

Status: Needs review » Needs work
StatusFileSize
new206.07 KB
new586.46 KB
new586.35 KB

Applied patch #16 and it is successfully applied.
But seems checkbox functionality is not working as expected.
If we check or uncheck remove extra space it is not reflected on front-end. Hence I am changing the status from Needs review to Needs Work.
@Nitin shrivastava can you check once again please and resubmit patch again.

For ref attaching screenshot.

smartsystems160’s picture

Status: Needs work » Needs review
StatusFileSize
new8 KB

#17 failed on fresh install of 10.1.x for some reason.

Updated patch to add configuration settings for this feature so it can be exported with other site configurations

Steps:

1. Follow steps on #13. Please remember to clear cache after applying patch because it makes changes to .yml files in core
2. Navigate to /admin/config/development/configuration/single/export and select "olivero.settings" from the dropdown under "Configuration name"
3. You should see "extra_space" as a config value. It starts out with null, true when enabled, and false when disabled.

This ensures that the setting is consistent across sites. Tested on 10.1.x-dev

smartsystems160’s picture

StatusFileSize
new6.94 KB

Fix whitespace errors on #18

smartsystems160’s picture

StatusFileSize
new7.42 KB

Fix pcss error on #19

smartsystems160’s picture

StatusFileSize
new7.42 KB

Fix pcss indentation error on #20

smartsystems160’s picture

StatusFileSize
new7.27 KB

Fix PostCSS update error on #21

Please clear cache after applying patch!

gaurav-mathur’s picture

Assigned: Unassigned » gaurav-mathur
w01f’s picture

Can we roll a version for 9.x for testing?

smartsystems160’s picture

StatusFileSize
new7.41 KB

Patch #25 for 9.5.x

w01f’s picture

Tested on 9.4.8 and works beautifully!

gaurav-mathur’s picture

Assigned: gaurav-mathur » Unassigned
smartsystems160’s picture

StatusFileSize
new7.41 KB
new7.27 KB

Keeping both the 10.1.x and 9.5.x patches visible at the top of this issue.

More tests needed for push to RTBC

pradipmodh13’s picture

StatusFileSize
new242.44 KB
new214.16 KB
new242.44 KB

Successfully Applied patch #28 for Drupal 10.1.x version. It is working as expected. For ref attached screenshot.
Now we can move this bug to RTBC.

Thank you @smartsystems160 !

gaurav-mathur’s picture

Applied patch#28 works fine on Drupal 10.1.x version
Refer to the screenshot

RTBC +1

w01f’s picture

Status: Needs review » Reviewed & tested by the community

Moved to RTBC - thanks all for your amazing work on this!

w01f’s picture

w01f’s picture

bnjmnm’s picture

Status: Reviewed & tested by the community » Needs work

The header can be a little chunky looking, so this could be a nice change.

I have some feedback regarding what this would need to move forward:

  1. +++ b/core/themes/olivero/config/schema/olivero.schema.yml
    @@ -24,3 +24,6 @@ olivero.settings:
    +      label: 'Extra Space'
    

    This could benefit from a rename that better explains what it does. 'Extra space' is pretty abstract, and it wouldn't take much to make this more descriptive. That will become more beneficial as Olivero adds more config options.

  2. +++ b/core/themes/olivero/css/components/site-header.css
    @@ -41,6 +41,12 @@
    +/* Removes  extra space from the header */
    +
    +.remove-extra-space {
    +  margin-top: -4.5rem;
    +}
    +
     .site-header__initial {
       position: relative;
       z-index: 102;
    diff --git a/core/themes/olivero/css/components/site-header.pcss.css b/core/themes/olivero/css/components/site-header.pcss.css
    
    diff --git a/core/themes/olivero/css/components/site-header.pcss.css b/core/themes/olivero/css/components/site-header.pcss.css
    index 9eaf220761..9404c0f03c 100644
    
    index 9eaf220761..9404c0f03c 100644
    --- a/core/themes/olivero/css/components/site-header.pcss.css
    
    --- a/core/themes/olivero/css/components/site-header.pcss.css
    +++ b/core/themes/olivero/css/components/site-header.pcss.css
    
    +++ b/core/themes/olivero/css/components/site-header.pcss.css
    +++ b/core/themes/olivero/css/components/site-header.pcss.css
    @@ -20,6 +20,11 @@
    
    @@ -20,6 +20,11 @@
       }
     }
     
    +/* Removes  extra space from the header */
    +.remove-extra-space {
    +  margin-top: -4.5rem;
    +}
    

    It looks like this solution is hoisting the entire element upward - so it doesn't actually address the unwanted whitespace, but instead slides that portion offscreen.

    This is better addressed by altering the style that adds the additional space to begin with .site-branding is set to min-height: var(--sp3);. If that min-height is changed, the unwanted space is actually remove instead of just shifted offscreen.

    Also noticed an excess space in the comment "Removes. extra space from the header"

  3. +++ b/core/themes/olivero/templates/layout/page.html.twig
    @@ -50,43 +50,47 @@
    +      {% endif %}
    

    All the other markup is identical, so this could just conditionally add the class instead of an entire if/else generating a full header tag.

    Also, I believe if extra_space should be sufficient. If this needs to be enforced as boolean, an assert() in the preprocess can do that.

  4. +++ b/core/themes/olivero/templates/layout/page.html.twig
    @@ -50,43 +50,47 @@
    +          {# Gets fixed by JavaScript at wide widths. #}
    +          <div class="site-header__fixable" data-drupal-selector="site-header-fixable">
    +            <div class="site-header__initial">
    +              <button class="sticky-header-toggle" data-drupal-selector="sticky-header-toggle" role="switch" aria-controls="site-header__inner" aria-label="{{ 'Sticky header'|t }}" aria-checked="false">
    +                <span class="sticky-header-toggle__icon">
    +                  <span></span>
    +                  <span></span>
    +                  <span></span>
    +                </span>
    +              </button>
    +            </div>
    

    It looks like here and elsewhere in the file, there is a bunch of indentation changes that are out of scope.

  5. +++ b/core/themes/olivero/theme-settings.php
    @@ -117,6 +117,17 @@ function olivero_form_system_theme_settings_alter(&$form, FormStateInterface $fo
    +  $form['olivero_settings']['olivero_extras']['extra_space'] = [
    +    '#type'          => 'checkbox',
    +    '#title'         => t('Remove Extra Space'),
    +    '#default_value' => theme_get_setting('extra_space'),
    +    '#description'   => t("Remove extra space at the top of the theme"),
    +  ];
    

    "Remove extra space" seems like something that won't make much sense outside of this issue. Space being "extra" is subjective, and it assumes familiarity with Olivero prior to this change.

    The setting name should more explicitly say it will result in a smaller/larger header as that more accurately describes the result.

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

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

oswa_cabrera’s picture

StatusFileSize
new101.04 KB
oswa_cabrera’s picture

StatusFileSize
new88.01 KB
oswa_cabrera’s picture

Hello everyone, I was testing patch #28 and everything seemed fine but when I viewed my site in tablet and mobile mode I realized that the header disappears completely on mobiles and partially on tablets, Here are the screenshots.

mobile_header.png
tablet_header.png

w01f’s picture

Title: Olivero: Add option for reduced empty space above header/branding » Olivero: Add option for reduced header/branding height
w01f’s picture

Updated the title to be clearer regarding the purpose of this issue as requested. Here are some examples of what I think the ideal alternative height should look like, and would like other's opinions.

https://www.kobejet.com
https://www.gordillo.legal

Would a simple toggle option for one reduced height option be sufficient, or would a numeric field to set the desired height in px/rem be desirable? Also, any other options (e.g., vertical centering - top, middle, bottom - for the header elements, manual option to set mobile menu swap width, etc.)?

Version: 11.x-dev » main

Drupal core is now using the main branch as the primary development branch. New developments and disruptive changes should now be targeted to the main branch.

Read more in the announcement.