-
Notifications
You must be signed in to change notification settings - Fork 21
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
base: main
Are you sure you want to change the base?
Conversation
✅ Deploy Preview for ons-design-system-preview ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
5a42c21
to
7bf2beb
Compare
There was a problem hiding this 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
- It looks like the icon in the button is too small and isn't centred.
- The input looks like perhaps it's not tall enough which makes the button next to the input look squashed.
- 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.
- 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.
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 |
This will also need to be changed so that it is only able to be used on "basic" headers |
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 |
There was a problem hiding this comment.
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
src/components/button/_macro.njk
Outdated
@@ -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 %} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{% 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; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
&--header-search:active:focus &, | ||
&--header-search.active:focus & { | ||
&__inner { | ||
padding: 0.875rem !important; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
src/components/button/_button.scss
Outdated
padding: 0.875rem !important; | ||
border: 0; | ||
border-radius: 0; | ||
box-shadow: none !important; |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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. | |
There was a problem hiding this comment.
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 | |
There was a problem hiding this comment.
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
src/components/header/_macro.njk
Outdated
</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> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
src/components/header/_macro.njk
Outdated
> | ||
<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> #} |
There was a problem hiding this comment.
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": [ |
There was a problem hiding this comment.
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
There was a problem hiding this 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.
- 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.
- There is no hover state on the button to close the search. It's there to open it, but not there to close it.
- 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.
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.