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

Only show search when JS is enabled #591

Open
leoheitmannruiz opened this issue Feb 26, 2024 · 3 comments
Open

Only show search when JS is enabled #591

leoheitmannruiz opened this issue Feb 26, 2024 · 3 comments

Comments

@leoheitmannruiz
Copy link
Contributor

Hey, thanks for the lovely theme!!

What do you think about only showing the search bar when JS is enabled? I feel like this would be a caring touch :)

I know very little about this type of development, but can't you have an empty div, which is filled with the search, in case JS is enabled? Is it that simple?

@alex-shpak
Copy link
Owner

Hi!
I thought about it, option could be to have search box hidden by default and unhide it with JS, not sure if it worth an extra JS script tho

@alex-shpak
Copy link
Owner

Perhaps like this
search.html

{{ if default true .Site.Params.BookSearch }}
<div class="book-search hidden">
  <input type="text" id="book-search-input" placeholder="{{ i18n "Search" }}" aria-label="{{ i18n "Search" }}" maxlength="64" data-hotkeys="s/" />
  <div class="book-search-spinner hidden"></div>
  <ul id="book-search-results"></ul>
</div>
<script>document.querySelector(".book-search").classList.remove("hidden")</script>
{{ end }}

@leoheitmannruiz
Copy link
Contributor Author

I tested this and it LGTM. Very cool!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants