From 30a886ee1ca751a1fed1e0c0617d2eada370c809 Mon Sep 17 00:00:00 2001 From: Min RK Date: Mon, 12 Sep 2022 10:58:44 +0200 Subject: [PATCH 1/2] Add #searchbox to sidebar for "Hide Search Matches" link part of the base sphinx theme, creates a link to remove ?highlight=... from the URL added to sidebar --- .../styles/sections/_sidebar-secondary.scss | 18 ++++++++++++++++++ .../components/searchbox.html | 2 ++ .../theme/pydata_sphinx_theme/theme.conf | 2 +- 3 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/searchbox.html diff --git a/src/pydata_sphinx_theme/assets/styles/sections/_sidebar-secondary.scss b/src/pydata_sphinx_theme/assets/styles/sections/_sidebar-secondary.scss index 986eadfa6..37459a557 100644 --- a/src/pydata_sphinx_theme/assets/styles/sections/_sidebar-secondary.scss +++ b/src/pydata_sphinx_theme/assets/styles/sections/_sidebar-secondary.scss @@ -52,3 +52,21 @@ padding-left: 1rem; } } + +// The 'Hide Search Matches' link +div#searchbox { + p.highlight-link { + // remove excess margin from p tag + margin-bottom: 0px; + a { + // add icon via CSS because the link is created by javascript + // match padding to .toc-item > i above + // f010 is magnifying glass minus + &:before { + content: "\f010"; + font-family: FontAwesome; + padding-right: 0.5rem; + } + } + } +} diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/searchbox.html b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/searchbox.html new file mode 100644 index 000000000..3437e8d27 --- /dev/null +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/components/searchbox.html @@ -0,0 +1,2 @@ +{# div#searchbox hosts the "Hide Search Matches" link #} + diff --git a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf index 4fd5b8d4e..821f3782c 100644 --- a/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf +++ b/src/pydata_sphinx_theme/theme/pydata_sphinx_theme/theme.conf @@ -34,7 +34,7 @@ navbar_end = theme-switcher.html, navbar-icon-links.html header_links_before_dropdown = 5 left_sidebar_end = sidebar-ethical-ads.html footer_items = copyright.html, sphinx-version.html -page_sidebar_items = page-toc.html, edit-this-page.html, sourcelink.html +page_sidebar_items = page-toc.html, searchbox.html, edit-this-page.html, sourcelink.html switcher = pygment_light_style = tango pygment_dark_style = native From acd625a70dcab0250751fdbc1e89198281e172b3 Mon Sep 17 00:00:00 2001 From: Min RK Date: Tue, 13 Sep 2022 12:14:36 +0200 Subject: [PATCH 2/2] add searchbox.html to layout docs --- docs/user_guide/layout.rst | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/user_guide/layout.rst b/docs/user_guide/layout.rst index e4deded42..113cdcded 100644 --- a/docs/user_guide/layout.rst +++ b/docs/user_guide/layout.rst @@ -452,6 +452,7 @@ will be named accordingly). - ``navbar-logo.html`` - ``navbar-nav.html`` - ``page-toc.html`` +- ``searchbox.html`` - ``search-button.html`` - ``search-field.html`` - ``sidebar-ethical-ads.html``