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

Create a 'search field' component for themes #11045

Merged
merged 1 commit into from
Apr 21, 2023

Conversation

timhoffm
Copy link
Contributor

@timhoffm timhoffm commented Dec 22, 2022

Feature or Bugfix

Purpose

searchfield.html is similar to the existing searchbox.html, but does not have the heading "Quick Search". Instead, it uses "Search" as a placeholder text. This gives a cleaner and less cluttered appearance.

Before:
image

After:
image

Detail

The searchfield component is added to the basic theme and thus can be used in any derivative theme. It is not used by default for backward compatibility. Also searchbox.html was deliberately not modified for backward compatibility.

The searchfield component is made the default in the new sphinx13 theme.

CSS adaptions ensure that the top of the search field is aligned with the top of the main content.

@mgeier
Copy link
Contributor

mgeier commented Dec 22, 2022

Please note that the searchbox also has a "Hide Search Matches" feature:

const searchBox = document.getElementById("searchbox");
if (searchBox === null) return;
searchBox.appendChild(
document
.createRange()
.createContextualFragment(
'<p class="highlight-link">' +
'<a href="javascript:SphinxHighlight.hideSearchWords()">' +
_("Hide Search Matches") +
"</a></p>"
)
);

You might want to duplicate this for your searchfield.

Alternatively, you might be able to just re-use the #searchbox ID, which would give you this feature for free.

@timhoffm timhoffm force-pushed the serach-field branch 2 times, most recently from eb78b33 to ec407a6 Compare December 22, 2022 23:25
searchfield.html is similar to the existing searchbox.html, but does not
have the heading "Quick Search". Instead, it uses "Search" as a placeholder
text. This gives a cleaner and less cluttered appearance.

The searchfield component is added to the basic theme and thus can be used
in any derivative theme. It is not used by default for backward compatibility.

The searchfield compenent is made the default in the new sphinx13 theme.

CSS adaptions ensure that the top of the search field is aligned with the
top of the main content.
@timhoffm
Copy link
Contributor Author

Thanks for the feedback. I've gone back to #searchbox, which seems more robust compared to duplicating style and logic.

@timhoffm
Copy link
Contributor Author

Ping @mgeier. I've addressed your comment and believe this is ready to go.

@mgeier
Copy link
Contributor

mgeier commented Jan 19, 2023

Yes, thanks, my comment has been fully addressed.

However, I'm not the right person to approve or reject this PR as a whole.

@timhoffm
Copy link
Contributor Author

ping @AA-Turner. You approved the fundamental idea in #10791 (comment). Would you be willing to review? Thanks.

@AA-Turner AA-Turner changed the title Create a search field component Create a 'search field' component for themes Apr 21, 2023
@AA-Turner AA-Turner merged commit b430e05 into sphinx-doc:master Apr 21, 2023
@AA-Turner
Copy link
Member

Thanks!

A

@timhoffm timhoffm deleted the serach-field branch April 21, 2023 16:01
mgeier added a commit to mgeier-forks/insipid-sphinx-theme that referenced this pull request May 21, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators May 22, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove heading from search box in sphinx13 style
3 participants