Skip to content

Commit

Permalink
Fixing FontAwesome icon handling in search placeholder (google#1247)
Browse files Browse the repository at this point in the history
  • Loading branch information
mkruskal-google authored and dseynaev committed Jan 30, 2023
1 parent cdc2ebc commit daf4011
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 4 deletions.
4 changes: 4 additions & 0 deletions assets/scss/_nav.scss
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@
font-weight: $font-weight-bold;
}

.td-search-wrapper .fa {
color: $navbar-dark-color;
}

.td-search-input {
border: none;
color: $navbar-dark-color;
Expand Down
41 changes: 38 additions & 3 deletions assets/scss/_search.scss
Original file line number Diff line number Diff line change
@@ -1,8 +1,21 @@
// Search
.td-search-wrapper {
position: relative;
background: transparent;
width: 90%;
}

.td-search-wrapper:not(:focus-within) {
color: $input-placeholder-color;
}

.td-search-input {
.td-search-wrapper .td-search-input:not(:focus) {
background: transparent;
max-width: 90%;
}

.td-search-wrapper .td-search-input {
width: 100%;
text-indent: 1.25em;

&.form-control:focus {
border-color: lighten($primary, 60%);
Expand All @@ -13,8 +26,30 @@
@if $enable-rounded {
border-radius: 1rem;
}
}

.td-search-wrapper .fa {
// Vertically center the content.
display: flex;
justify-content: center;
align-items:center;
height: 100%;

// Position this on the left of the input.
position: absolute;
left: 0.75em;

// Click-through to the underlying input.
pointer-events: none;
}

// Hide the icon on focus.
.td-search-wrapper:focus-within .fa {
display: none;
}

font-family: $font-family-base, $font-awesome-font-name;
.td-search-wrapper:focus-within .td-search-input {
text-indent: 0px;
}

.popover.offline-search-result {
Expand Down
5 changes: 4 additions & 1 deletion layouts/partials/search-input.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
{{ if .Site.Params.gcs_engine_id -}}
<input type="search" class="form-control td-search-input" placeholder="&#xf002; {{ T "ui_search" }}" aria-label="{{ T "ui_search" }}" autocomplete="off">
<div class="td-search-wrapper">
<i class="fa fa-search"></i>
<input type="search" class="form-control td-search-input" placeholder="{{ T "ui_search" }}" aria-label="{{ T "ui_search" }}" autocomplete="off">
</div>
{{ else if .Site.Params.algolia_docsearch -}}
<div id="docsearch"></div>
{{ else if .Site.Params.offlineSearch -}}
Expand Down

0 comments on commit daf4011

Please sign in to comment.