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

Fixing FontAwesome icon handling in search placeholder #1247

Merged
merged 9 commits into from
Oct 13, 2022
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