From f096a5c0767eefccdd7b78e5a484c84675a88e6d Mon Sep 17 00:00:00 2001 From: "Mark A. Grondona" Date: Wed, 15 Apr 2026 19:23:37 -0700 Subject: [PATCH 1/2] templates: add cross-project search via RTD Addons Problem: sphinx_immaterial performs single-project client-side search with no way to reach flux-framework subproject documentation. RTD Addons (enabled by default since October 2024) provides native cross-project search but was only accessible via the bottom-right flyout, not the top-bar search input. Override partials/search.html to render a search input that lacks sphinx_immaterial's data-md-component attributes so the theme ignores it, then dispatch the readthedocs-search-show custom event on focus/click to open the RTD Addons cross-project search modal from the header. Position the bar absolutely within .md-header__inner and center it with left:50% + translate(-50%,-50%) so it stays centered regardless of flex siblings. Falls back to sphinx_immaterial's standard search for local builds where RTD Addons is absent. Co-Authored-By: Claude Sonnet 4.6 --- _static/custom.css | 55 +++++++++++ _templates/partials/search.html | 167 +++++++------------------------- 2 files changed, 92 insertions(+), 130 deletions(-) diff --git a/_static/custom.css b/_static/custom.css index 1af7281c..376f2b52 100644 --- a/_static/custom.css +++ b/_static/custom.css @@ -1,3 +1,58 @@ +/* RTD search trigger: center the bar in the header and fix vertical alignment. + Without data-md-component="search", sphinx_immaterial does not manage this element, + so positioning and sizing must be set explicitly. + position:absolute + left:50%/translateX(-50%) centers the bar relative to the + header regardless of where the flex siblings land. */ +.md-header__inner { + position: relative; +} +.md-header .md-search { + display: flex; + align-items: center; + width: 20rem; + position: absolute; + left: 50%; + top: 50%; + transform: translate(-50%, -50%); + pointer-events: auto; +} + +.md-header .md-search .md-search__inner, +.md-header .md-search .md-search__form { + display: flex; + align-items: center; + width: 100%; +} + +.md-header .md-search .md-search__input { + width: 100%; +} + +/* Sync RTD Addons search modal colors with sphinx_immaterial's slate (dark) scheme. + RTD Addons modal defaults to light mode; these overrides make it follow the + site's dark mode toggle by mapping to sphinx_immaterial's own CSS variables. */ +body[data-md-color-scheme="slate"] { + --readthedocs-search-color: var(--md-default-fg-color); + --readthedocs-search-link-color: var(--md-default-fg-color); + --readthedocs-search-content-background-color: var(--md-default-bg-color); + --readthedocs-search-input-background-color: var(--md-default-bg-color--light); + --readthedocs-search-footer-background-color: var(--md-default-bg-color--light); + --readthedocs-search-footer-color: var(--md-default-fg-color); + --readthedocs-search-footer-code-background-color: var(--md-default-bg-color--lighter); + --readthedocs-search-content-border-color: var(--md-default-fg-color--lightest); + --readthedocs-search-filters-border-color: var(--md-default-fg-color--lightest); + --readthedocs-search-result-border-color: var(--md-default-fg-color--lightest); + --readthedocs-search-footer-code-border-color: var(--md-default-fg-color--lightest); + --readthedocs-search-result-active-background-color: var(--md-default-bg-color--light); + --readthedocs-search-result-color: var(--md-default-fg-color--light); + --readthedocs-search-result-heading-color: var(--md-default-fg-color); + --readthedocs-search-result-subheading-color: var(--md-default-fg-color--light); + --readthedocs-search-result-icon-color: var(--md-default-fg-color--light); + --readthedocs-search-badge-color: var(--md-default-fg-color); + --readthedocs-search-badge-background-color: var(--md-default-bg-color--light); + --readthedocs-search-backdrop-color: rgba(0, 0, 0, 0.7); +} + .o-tooltip--left:after{ font-size: 0.8rem; } diff --git a/_templates/partials/search.html b/_templates/partials/search.html index f0290d47..46a03084 100644 --- a/_templates/partials/search.html +++ b/_templates/partials/search.html @@ -1,153 +1,56 @@ -{#- Custom search that uses ReadTheDocs server-side API for cross-project searching -#} +{#- On RTD: forward search interactions to RTD Addons, which provides cross-project + search across all flux-framework subprojects natively. Off RTD: fall back to + sphinx_immaterial's default client-side search. -#} {% if on_rtd %} - {# On ReadTheDocs, use server-side search API which supports cross-project search #} -