We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Keep search icon on mobile screens - Help

Keep search icon on mobile screens - Help

George_Greenhil
Trailblazer
175 0 59

Hey guys,

 
Is there a way to get the search icon to still appear in the header on mobile devices on Blockshop and open the search query entry bit?

I have attached a mock-up image of how this might look and it's ideal placement.
 
Currently, when the screen size goes below 768px, the search icon gets hidden and gets added to the hamburger menu making it a bit hard for UX.
 
 
Many thanks,
George
 
Search-Mobile-Placement (1).pngSearch-Mobile-Example (1).png
 
Replies 8 (8)

Ahsan_ANC
Shopify Partner
1420 255 329

your header file code need to be change for this

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
George_Greenhil
Trailblazer
175 0 59

@Ahsan_ANC  Thank you, yeah I tried editing it, do you know how I'd do that? 🙂

Ahsan_ANC
Shopify Partner
1420 255 329

plz share the code of heade.liquid, i will update it

 

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
George_Greenhil
Trailblazer
175 0 59

Hey @Ahsan_ANC 

 

Please see below 🙂

 

{%- liquid
  assign search_t = 'layout.header.search' | t
  assign account_t = 'layout.header.account' | t

  assign cart_icon = section.settings.cart--icon
  assign logo_image = section.settings.logo
  assign logo_height = section.settings.logo-height
  assign logo_center = section.settings.header-logo-center
  assign menu_center = section.settings.header-menu-center
  assign menu = section.settings.menu
  assign mobile_logo_height = section.settings.mobile-logo-height
  assign transparent_menu = section.settings.transparent-menu

  assign locale_enabled = false
  assign region_enabled = false
  if section.settings.show-region-selector and localization.available_countries.size > 1
    assign region_enabled = true
  endif
  if section.settings.show-locale-selector and localization.available_languages.size > 1
    assign locale_enabled = true
  endif
-%}

<header-root
  class="header--root"
  data-section-id="{{ section.id }}"
  data-section-type="header-section"
  data-spacing="none"
  data-center-logo="{{ logo_center }}"
  data-center-menu="{{ menu_center }}"
  {% if request.page_type == 'index' and transparent_menu %}
    data-transparent-menu="true"
  {% else %}
    data-transparent-menu="false"
  {% endif %}
>
  <div class="header--y-menu-for-off-canvas" style="display:none;">
    {% render 'y-menu', handle: menu %}
  </div>

  {% if locale_enabled or region_enabled %}
    <div class="header--localization-for-off-canvas" style="display:none;">
      {% render
        'localization',
        locale_enabled: locale_enabled,
        region_enabled: region_enabled,
        id: 'off-canvas'
      %}
    </div>
  {% endif %}

  <div class="header--top-row">
    {% if locale_enabled or region_enabled %}
      <div class="header--localization">
        {% render
          'localization',
          locale_enabled: locale_enabled,
          region_enabled: region_enabled,
          id: 'header'
        %}
      </div>
    {% endif %}

    {% if request.page_type == 'index' %}
      <h1 class="header--logo">
        {%
          render 'logo',
          logo: logo_image,
          height: logo_height,
          mobile_height: mobile_logo_height
        %}
      </h1>
    {% else %}
      <div class="header--logo">
        {%
          render 'logo',
          logo: logo_image,
          height: logo_height,
          mobile_height: mobile_logo_height
        %}
      </div>
    {% endif %}

    {% if settings.search--show-in-header %}
      <a
        class="header--search"
        href="{{ routes.search_url }}"
        role="img"
        aria-label="{{ search_t }}"
      >
        {% render 'icons', icon: 'search' %}
      </a>
    {% endif %}

    {% if section.settings.header-account-show and shop.customer_accounts_enabled %}
      <a
        class="header--account-icon"
        {% if customer %}
          href="{{ routes.account_url }}"
        {% else %}
          href="{{ routes.account_login_url }}"
        {% endif %}
        aria-label="{{ account_t }}"
      >
        {% render 'icons', icon: 'account' %}
      </a>
    {% endif %}
  </div>

  <div class="header--bottom-row">
    {%- liquid
      if linklists[menu].links.size > 0
        assign menu_alignment = 'left'
        if menu_center
          assign menu_alignment = 'center'
        endif

        echo '<div class="header--menu">'
          render 'x-menu', align: menu_alignment, overlap_parent: 1, handle: menu
        echo '</div>'
      endif

      echo '<div class="header--cart">'
        render 'header-cart', cart_icon: cart_icon
      echo '</div>'
    -%}
  </div>

  <div class="header--mobile">
    <div class="header--mobile--menu">
      <div
        tabindex="0"
        data-off-canvas--open="left-sidebar"
        aria-haspopup="menu"
      >
        {% render 'icons', icon: 'menu' %}
      </div>
    </div>

    <div class="header--mobile--title">
      {%
        render 'logo',
        logo: logo_image,
        height: logo_height,
        mobile_height: mobile_logo_height
      %}
    </div>

    <div class="header--mobile--cart" data-item="accent-text">
      {% render 'header-cart', cart_icon: cart_icon %}
    </div>

  </div>
</header-root>

<script type="module">
  import "{{ 'header.js' | asset_url }}";
</script>

<noscript>
  <style>
    @media only screen and (min-width: 768px) {
      .x-menu--level-1--container {
        display: flex;
        flex-wrap: wrap;
      }
    }
  </style>
</noscript>

{% if logo_image %}
  <style>
    header .logo-image {
      max-height: {{ logo_height }}px;
    }

    .header--top-row {
      height: {{ logo_height | plus: 16 }}px;
    }
  </style>
{% endif %}

{% schema %}
{
  "name": "Header",
  "class": "section--header",
  "settings": [
    {
      "type": "checkbox",
      "id": "transparent-menu",
      "label": "Transparent on home page",
      "info": "Only recommended with a full width image in top section"
    },
    {
      "type": "checkbox",
      "id": "header-account-show",
      "label": "Enable customer account links",
      "default": true,
      "info": "[You will also need to enable customer accounts in your store settings](https:\/\/docs.shopify.com\/manual\/your-store\/customers\/customer-accounts)"
    },
    {
      "type": "select",
      "id": "cart--icon",
      "label": "Cart icon",
      "options": [
        { "label": "Text", "value": "text" },
        { "label": "Bag", "value": "bag" },
        { "label": "Cart", "value": "cart" }
      ],
      "default": "text"
    },
    {
      "type": "header",
      "content": "Menu"
    },
    {
      "type": "checkbox",
      "id": "header-menu-center",
      "label": "Center align"
    },
    {
      "type": "link_list",
      "id": "menu",
      "label": "Menu",
      "default": "main-menu"
    },
    {
      "type": "header",
      "content": "Country/region Selector",
      "info": "To add a country/region, go to your [payment settings](/admin/settings/payments)."
    },
    {
      "type": "checkbox",
      "id": "show-region-selector",
      "label": "Show country/region selector",
      "default": true
    },
    {
      "type": "header",
      "content": "Language Selector",
      "info": "To add a language, go to your [language settings](/admin/settings/languages)."
    },
    {
      "type": "checkbox",
      "id": "show-locale-selector",
      "label": "Show language selector",
      "default": true
    },
    {
      "type": "header",
      "content": "Logo"
    },
    {
      "type": "checkbox",
      "id": "header-logo-center",
      "label": "Center align"
    },
    {
      "type": "image_picker",
      "id": "logo",
      "label": "Image",
      "info": "1600 x 200px max"
    },
    {
      "label": "Image height",
      "id": "logo-height",
      "type": "range",
      "min": 15,
      "max": 100,
      "step": 5,
      "default": 50,
      "info": "This is referring to the natural height and should be half the height of the image you uploaded to ensure it stays sharp on retina screens."
    },
    {
      "label": "Mobile image height",
      "id": "mobile-logo-height",
      "type": "range",
      "min": 15,
      "max": 100,
      "step": 5,
      "default": 30
    }
  ]
}
{% endschema %}
Ahsan_ANC
Shopify Partner
1420 255 329

plz update header file with this new code. see attchment

 

 

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
George_Greenhil
Trailblazer
175 0 59

Hey @Ahsan_ANC ,

 

Thank you!

 

Just applied that code and also added a margin to the left of 35px so it's more centred between the logo and hamburger icon.

 

How does that look and work for you now? 

 

https://l1awpnr9qivlilwb-22594233.shopifypreview.com/

 

Thanks so much!

George

Ahsan_ANC
Shopify Partner
1420 255 329

The final choice is yours, here is one more look, you can consider

 

download (42).png

Contact for any custom design? Skype : ahsananc
>Was your question answered? Mark it as an Accepted Solution!
Feel Free to Contact Me at my Email: anc2277@gmail.com


To enhance and customize Shopify search and filter, I use Boost Product Filter & Search
NadSH
Visitor
1 0 0

Hello, is there code for doing this to the Spark theme?