Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add search button to header #3483

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

precious-onyenaucheya-ons
Copy link
Contributor

@precious-onyenaucheya-ons precious-onyenaucheya-ons commented Jan 30, 2025

What is the context of this PR?

ONSDESYS-162
Added a search button to the header component. Clicking the button opens a panel containing a search input and a list of popular searches.

I have also increased the size of the ons logo as part of this ticket to fit the figma design

How to review this PR

Check that example-header-with-search-button has the new search button and has the design as specified in figma

Checklist

This needs to be completed by the person raising the PR.

  • I have selected the correct Assignee
  • I have linked the correct Issue

Copy link

netlify bot commented Jan 30, 2025

Deploy Preview for ons-design-system-preview ready!

Name Link
🔨 Latest commit 3df9796
🔍 Latest deploy log https://app.netlify.com/sites/ons-design-system-preview/deploys/67c08db784d2eb000832a6d5
😎 Deploy Preview https://deploy-preview-3483--ons-design-system-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@precious-onyenaucheya-ons precious-onyenaucheya-ons force-pushed the feature/162-header-search-button branch from 5a42c21 to 7bf2beb Compare January 30, 2025 15:18
@precious-onyenaucheya-ons precious-onyenaucheya-ons added the Enhancement Change of existing feature label Jan 30, 2025
@precious-onyenaucheya-ons precious-onyenaucheya-ons marked this pull request as ready for review January 31, 2025 08:45
@precious-onyenaucheya-ons precious-onyenaucheya-ons requested a review from a team as a code owner January 31, 2025 08:45
Copy link
Contributor

@admilne admilne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've got some alignment issues when I view this on my browser

Website:
image

Design:
image

  1. It looks like the icon in the button is too small and isn't centred.
  2. The input looks like perhaps it's not tall enough which makes the button next to the input look squashed.
  3. The button next to the input also looks like it has some sort of black border at the bottom which doesn't appear in the designs.
  4. The design also seems to show a blue border around the input whereas it looks like it currently has a black border. We might need some clarification about how this button should look when clicked as that doesn't seem to be included in the design. At the moment this looks very odd to me.
    image

@rmccar
Copy link
Contributor

rmccar commented Feb 13, 2025

The search button doesn't seem to have any focus state at the moment, which doesn't match new menu button. It also doesn't have an underline like that button when it is open, which I know is not in the figma but I think was suggested after. We need this to be consistent with the way the menu button works. Also has this been tested alongside the menu button? I think we should add this to that example because they are likely to be used together

@rmccar
Copy link
Contributor

rmccar commented Feb 17, 2025

This will also need to be changed so that it is only able to be used on "basic" headers

@rmccar
Copy link
Contributor

rmccar commented Feb 20, 2025

Can you split the logo size change out into its own PR. It makes this PR harder to review because it affects so many pages

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This screenshot is a a bit of an issue, we don't want them wrapping like that

@@ -61,6 +61,10 @@
{% set iconType = "loader" %}
{% set iconPosition = "after" %}
{% set variantClasses = " ons-btn--loader ons-js-loader ons-js-submit-btn" %}
{% elif 'search-icon' in params.variants %}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
{% elif 'search-icon' in params.variants %}
{% elif 'search' in params.variants %}

This should just be search to fit in with the way others are done

&--header-search.active:focus & {
&__inner {
padding: 0.875rem !important;
border: 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed? This line seems to make no difference

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@precious-onyenaucheya-ons I don't think this comment has been addressed yet?

@rmccar
Copy link
Contributor

rmccar commented Feb 21, 2025

Screenshot 2025-02-21 at 13 54 06

The underlines are currently misaligned

@rmccar
Copy link
Contributor

rmccar commented Feb 21, 2025

Screenshot 2025-02-21 at 13 55 18

Underline is missing when the search is open

&--header-search:active:focus &,
&--header-search.active:focus & {
&__inner {
padding: 0.875rem !important;
Copy link
Contributor

@rmccar rmccar Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to need important. If we can we should avoid using important and only use it if we need to. Can you review the places youve added important and check that they are needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rmccar I see this hasn't changed. It looks like it is required at the moment because there is some css later on in the file which overrides the padding needed here. On line 780 in _button.scss you have the following:

.ons-search__btn {
    height: 92.5%; //this is to allow the button to be fully aligned with the input by accounting for the shadow box of 3px
    .ons-btn__inner:has(> .ons-icon) {
        padding-right: 0.75rem;
        height: 100%;
    }
}

This looks a little odd to me, anyone know if this is required? But this is the style resulting in @precious-onyenaucheya-ons needing to use !important. It's more specific and comes later in the file

padding: 0.875rem !important;
border: 0;
border-radius: 0;
box-shadow: none !important;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Important doesnt seem to be needed here too

@rmccar
Copy link
Contributor

rmccar commented Feb 21, 2025

Screenshot 2025-02-21 at 13 58 42

Search icon not turning black when focused on

@rmccar
Copy link
Contributor

rmccar commented Feb 21, 2025

Screenshot 2025-02-21 at 14 08 18

Should this have an inner blue boarder? Not a black one like the search on the Service manual header?
If it is meant to be blue I'm not sure there should be a black border between the yellow and blue

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Im not sure why this has changed. It looks like the radios at the bottom with the dropdown have changed slightly

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@precious-onyenaucheya-ons have you looked in to this one? Doesn't look major but curious to see if there is a reason for the change

| id | string | true | The HTML `id` of the `search button` element. Used for the `aria-controls` attribute for the search toggle button displayed on small viewports. |
| classes | string | false | Classes to add to the `search button` element |
| ariaLabel | string | false | The `aria-label` attribute added to the `search button` element. Defaults to Search navigation”. |
| popularSearches | array`<SearchItem>` | true | Settings for an array of [popular searches](#searchitem) for each search link |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I got the impression that the title of Popular Searches could be configurable. Might need to check on that. If the title is configurable, this may need a better name.

@@ -18,6 +18,7 @@
| navigation | array`<Navigation>` | false | Settings for the [main menu links](#navigation) |
| siteSearchAutosuggest | `Autosuggest` [_(ref)_](/components/autosuggest) | false | Sets the autosuggest functionality in the header |
| menuLinks | object`<MenuLinks>` | false | Settings for the [menu button navigation](#menuLinks) in the masthead |
| searchLinks | object`<SearchLinks>` | false | Settings for the [search button navigation](#searchLinks) in the masthead |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should there be something here to say you can only have 5 search links?


| Name | Type | Required | Description |
| ---- | ------ | -------- | ------------------------------------- |
| text | string | false | The text for the popular search item. |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'popular search' may need to be renamed if the title of Popular Searches is configurable

| Name | Type | Required | Description |
| ---- | ------ | -------- | ------------------------------------- |
| text | string | false | The text for the popular search item. |
| url | string | true | The URL for the popular search item |
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'popular search' may need to be renamed if the title of Popular Searches is configurable

</div>
{% if params.searchLinks.popularSearches %}
<div class="ons-container">
<h2 class="ons-u-fs-r--b ons-u-mb-s ons-header-nav-search__heading">Popular Searches</h2>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get the feeling Popular Searches should be configurable based on the information within the ticket. Might need to check on this.
image

>
<div class="ons-container">
<div class="ons-header-nav-search__input">
{# <h2 class="ons-u-fs-r--b ons-u-mb-s ons-header-nav-search__heading">Search the ONS</h2> #}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this commented out code be removed?

"text": 'Search',
"ariaLabel": 'Toggle search'
},
"popularSearches": [
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Again, this may need to be changed if the title of Popular Searches is configurable

Copy link
Contributor

@admilne admilne left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've noticed there are a couple of potential issues here.

  1. There is a gap between the right hand edge of the button and the edge of the header. This is different to the design. Might be ok as it fits with the way the header has been constructed but perhaps worth checking if this is a deal breaker.
  2. There is no hover state on the button to close the search. It's there to open it, but not there to close it.
  3. I think the links under Popular Searches are meant to stack into a single column when on mobile, rather than wrap as it seems to do currently.
    image
    image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Change of existing feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants