diff --git a/_static/custom.css b/_static/custom.css index 1af7281c..a764b783 100644 --- a/_static/custom.css +++ b/_static/custom.css @@ -1,3 +1,60 @@ +/* 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. + Variables must be set directly on the readthedocs-search element, not on body — + light-DOM styles on the host element override the shadow DOM's :host rules, + whereas inherited values from body lose to :host. */ +body[data-md-color-scheme="slate"] readthedocs-search { + --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-background-color: var(--md-default-bg-color--light); + --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..5502e4ec 100644 --- a/_templates/partials/search.html +++ b/_templates/partials/search.html @@ -1,153 +1,95 @@ -{#- 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 #} -