Skip to content

Commit

Permalink
Improved site search bar (godaddy-wordpress#400)
Browse files Browse the repository at this point in the history
* Add search-modal template partial

* Output search modal in header

* Refactor search_toggle to also toggle close button

* Simplify z-index values

* Set search query as search form value

* Remove z-index value

* Remove close icon from search toggle

* Remove section-inner of search-modal

* style search modal

* Cleanup site-search styles

* Fix search field focus

* Two classes needed to handle animation

* New search-toggle script

* Tweak focus so cursor focuses at end of search input when a term exists

* Remove comment from header.php

* Theme header background is applied to search box

* Use existing --admin-bar-lg media query

* Add reduced motion preference for search bar drop-in

* Tweak transition

* Revert previously committed positioning style

* Tweak site title in modern
  • Loading branch information
jrtashjian authored and Evan Herman committed Nov 8, 2019
1 parent c8be57c commit 6407410
Show file tree
Hide file tree
Showing 16 changed files with 189 additions and 291 deletions.
6 changes: 6 additions & 0 deletions .dev/assets/design-styles/modern/css/style-modern.css
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
@import url("components/carousel.css");
@import url("components/wc-button.css");

.site-title {
@media (--largeMax) {
margin-left: calc(var(--theme-site-title--tracking) * 2.5);
}
}

.primary-menu a {

&::after {
Expand Down
1 change: 0 additions & 1 deletion .dev/assets/shared/css/header/header-4.css
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,6 @@
pointer-events: auto;
text-align: center;
visibility: visible;
z-index: 9998;

& a {
display: block;
Expand Down
1 change: 0 additions & 1 deletion .dev/assets/shared/css/header/header.css
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
.header__title-nav {
flex: 1 0 75%;
order: 2;
z-index: 9999;
}

.header__extras {
Expand Down
3 changes: 1 addition & 2 deletions .dev/assets/shared/css/header/header__nav-toggle.css
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
justify-content: flex-end;
order: 3;
text-align: right;
z-index: 10000;
z-index: 2;

@media (--large) {
flex: 0;
Expand All @@ -23,7 +23,6 @@
margin-right: -0.75rem;
padding: 0.75rem;
position: relative;
z-index: 1;

@media (--large) {
display: none;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ body::before {
pointer-events: auto;
text-align: center;
visibility: visible;
z-index: 9998;

& a {
display: block;
Expand Down
1 change: 1 addition & 0 deletions .dev/assets/shared/css/header/header__navigation.css
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
top: 0;
visibility: hidden;
will-change: opacity, visibility;
z-index: 1;

@media (--large) {
align-items: center;
Expand Down
1 change: 0 additions & 1 deletion .dev/assets/shared/css/header/header__search-toggle.css
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
color: hsl(var(--theme-search-toggle--color));
padding: 0.75rem;
position: relative;
z-index: 10000;

&:active,
&:focus,
Expand Down
1 change: 0 additions & 1 deletion .dev/assets/shared/css/header/header__titles.css
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
justify-content: center;
order: 2;
text-align: center;
z-index: 10000;

@media (--large) {
flex: auto;
Expand Down
63 changes: 63 additions & 0 deletions .dev/assets/shared/css/header/search-modal.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*! Search Modal: */
.search-modal {
background: rgba(0, 0, 0, 0.25);
bottom: 0;
display: none;
left: -9999rem;
opacity: 0;
overflow: -moz-scrollbars-none;
-ms-overflow-style: none;
position: fixed;
top: 0;
transition: opacity 0.15s linear, left 0s 0.15s linear;
width: 100%;
z-index: 10001;

@media (prefers-reduced-motion: reduce) {
transition: 0;
}

&::-webkit-scrollbar {
display: none !important;
}

&.show-modal {
display: block;
left: 0;
}

&.active {
cursor: pointer;
opacity: 1;
transition: opacity 0.2s linear;

& > * {
cursor: default;
}

& .search-modal-inner {
box-shadow: 0 0 2rem 0 rgba(0, 0, 0, 0.08);
transform: translateY(0);
transition: transform 0.25s ease-in-out, box-shadow 0.1s 0.25s linear;
}
}
}

.search-modal-inner {
background-color: hsl(var(--theme-header--bg, var(--color-white, #fff)));
padding: 3vw;
transform: translateY(-100%);
transition: transform 0.15s linear, box-shadow 0.15s linear;

@media (--medium) {
padding: var(--header-padding, 3vw) var(--theme-block-padding-x);
}
}

.admin-bar .search-modal.active {
top: 32px;

@media (--admin-bar-lg) {
top: 46px;
}
}
106 changes: 39 additions & 67 deletions .dev/assets/shared/css/header/site-search.css
Original file line number Diff line number Diff line change
@@ -1,86 +1,58 @@
/*! Header: Site Search */
.header {
/*! Site Search: */
.header .site-search {
z-index: 2;

& .site-search {
z-index: 2;
& .search-form {
display: flex;
}

& .search-form__input {
margin-bottom: 0;
}

@media (--large) {
left: 0;
opacity: 0;
pointer-events: none;
& .search-input__button {
border-radius: var(--theme-search-submit--radius, var(--theme-button--radius));
box-shadow: none;
color: inherit;
margin: 0 0 0 0.5rem;
padding: 0 1.75rem;
position: relative;
transition: var(--theme-button-transition);
width: 50px;

& .search-input__label {
left: -5000px;
position: absolute;
right: -0.75rem;
transform: translateX(60%);
transition: opacity 175ms ease-out 75ms, transform ease-out 175ms;
}

& .search-form {
display: flex;
& .search-input__arrow-icon {
fill: hsl(var(--theme-search-submit--color));
height: auto;
left: 50%;
position: absolute;
top: 50%;
transform: translate3d(-50%, -50%, 0);
width: 20px;
}

& .search-form__input {
margin-bottom: 0;
&::after {
display: none !important;
}

& .search-input__button {
background-color: hsl(var(--theme-search-submit--bg));
border-radius: var(--theme-search-submit--radius, var(--theme-button--radius));
&:active,
&:hover {
background-color: hsl(var(--theme-search-submit--bg-interactive));
border-color: hsl(var(--theme-search-submit--bg-interactive));
box-shadow: none;
color: inherit;
margin: 0 0 0 0.5rem;
padding: 0 1.75rem;
position: relative;
transition: var(--theme-button-transition);
width: 50px;

& .search-input__label {
left: -5000px;
position: absolute;
}

& .search-input__arrow-icon {
fill: hsl(var(--theme-search-submit--color));
height: auto;
left: 50%;
position: absolute;
top: 50%;
transform: translate3d(-50%, -50%, 0);
width: 20px;
}

&::after {
display: none !important;
}

&:active,
&:hover {
background-color: hsl(var(--theme-search-submit--bg-interactive));
border-color: hsl(var(--theme-search-submit--bg-interactive));
box-shadow: none;

& .search-input__arrow-icon {
fill: hsl(var(--theme-search-submit--color));
}
}

&:focus {
@mixin outline;
outline-offset: 2px;
}
}

/* When search becomes visible */
&.is-open {
opacity: 1;
pointer-events: all;
transform: translateX(0);
z-index: 9999;
&:focus {
@mixin outline;
outline-offset: 2px;
}
}
}

/* Override aria defaults */
.header__navigation .site-search[aria-hidden="true"] {
display: none;
visibility: visible;
}
1 change: 1 addition & 0 deletions .dev/assets/shared/css/style-shared.css
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
@import url("header/header__cart-toggle.css");
@import url("header/header__titles.css");
@import url("header/site-search.css");
@import url("header/search-modal.css");
@import url("header/sub-menu.css");

/* Footer */
Expand Down
Loading

0 comments on commit 6407410

Please sign in to comment.