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

style: change the search shortcut style #919

Merged
merged 1 commit into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions assets/main/scss/_top-app-bar.scss
Original file line number Diff line number Diff line change
Expand Up @@ -74,10 +74,10 @@ $header-caret-width: 0.35em;
.search-input {
padding-left: 2rem;
}
}

.search-button {
color: var(--#{$prefix}on-primary-secondary);
.search-shortcut {
margin-top: 0.35rem;
}
}

.dropdown-item-icon {
Expand Down
6 changes: 1 addition & 5 deletions layouts/partials/functions/search-input-placeholder.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
{{- $placeholder := "search_input_placeholder" | i18n }}
{{- $shortcut := slice "/" }}
{{- if isset site.Params.search "shortcut" }}
{{- $shortcut = cond (gt (len site.Params.search.shortcut) 0) site.Params.search.shortcut slice }}
{{- end }}
{{- with $shortcut }}
{{- with partialCached "functions/search-shortcut" . }}
{{- $placeholder = i18n "search_shortcut" (dict "Shortcut" (delimit . "+")) }}
{{- end }}
{{- return $placeholder -}}
5 changes: 5 additions & 0 deletions layouts/partials/functions/search-shortcut.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{{- $shortcut := slice "/" }}
{{- if isset site.Params.search "shortcut" }}
{{- $shortcut = cond (gt (len site.Params.search.shortcut) 0) site.Params.search.shortcut slice }}
{{- end }}
{{- return $shortcut -}}
13 changes: 10 additions & 3 deletions layouts/partials/header/search-bar.html
Original file line number Diff line number Diff line change
@@ -1,20 +1,27 @@
{{- if .Site.Params.searchBar }}
{{- $page := .Site.GetPage "/search" }}
{{- if ne $page.RelPermalink .RelPermalink -}}
{{- $placeholder := partialCached "functions/search-input-placeholder" . . }}
{{- $shortcut := partialCached "functions/search-shortcut" . }}
<hr class="d-xxl-none">
<form class="search-bar ms-auto my-1" action="{{ with $page }}{{ .RelPermalink }}{{ end }}" novalidate>
<div class="input-group input-group-sm align-items-center">
<span class="btn btn-search disabled position-absolute left-0 border-0 px-1">
<i class="fas fa-fw fa-search fa-lg"></i>
</span>
<input
class="my-1 form-control border-white rounded search-input bg-body"
class="my-1 form-control border-white rounded-5 search-input bg-body"
name="q"
type="search"
placeholder="{{ $placeholder }}"
placeholder="{{ i18n `search` }}"
aria-label="Search"
required>
{{- with $shortcut }}
<span class="search-shortcut position-absolute end-0 top-0 me-2">
{{- range . }}
<kbd class="bg-primary rounded shadow">{{ . }}</kbd>
{{- end }}
</span>
{{- end }}
</div>
</form>
{{- end }}
Expand Down