From b746f2dd5928c1aa25bac7d0b637c65e04df5d0d Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Fri, 22 Mar 2024 16:41:41 +0000 Subject: [PATCH] Various post 0.15 fixes (#241) * SunPyify the surface colors to fix rtd popout * Style search better * Update src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css * Fix dropdown offset so it's correct on default zoom * Add transparent non-hover border to search button So that it dosen't suddenly grow by 6px * More RTD Flyout tweaks * More tweaks * Test that we can set footer links * Add back support for upstream external links * Remove old footer.html we can rely on upstream now --- docs/conf.py | 10 ++++ src/sunpy_sphinx_theme/__init__.py | 2 +- .../theme/sunpy/components/navbar_center.html | 5 ++ .../theme/sunpy/sections/footer.html | 25 --------- .../theme/sunpy/static/sunpy_style.css | 53 +++++++++++++++++-- 5 files changed, 65 insertions(+), 30 deletions(-) delete mode 100644 src/sunpy_sphinx_theme/theme/sunpy/sections/footer.html diff --git a/docs/conf.py b/docs/conf.py index 7e6e080c..87afe702 100644 --- a/docs/conf.py +++ b/docs/conf.py @@ -68,6 +68,16 @@ "reproject": ("https://reproject.readthedocs.io/en/stable/", None), } html_theme = "sunpy" + +html_theme_options = { + "footer_links": [ + ("Google", "https://google.com", 3), + ("DDG", "https://duckduckgo.com", 3), + ], + "external_links": [ + {"name": "Python", "url": "https://www.python.org/"}, + ], +} graphviz_output_format = "svg" graphviz_dot_args = [ "-Nfontsize=10", diff --git a/src/sunpy_sphinx_theme/__init__.py b/src/sunpy_sphinx_theme/__init__.py index ecf8679a..3363e13e 100644 --- a/src/sunpy_sphinx_theme/__init__.py +++ b/src/sunpy_sphinx_theme/__init__.py @@ -78,7 +78,7 @@ def update_config(app): if not theme_options.get("navbar_links"): theme_options["navbar_links"] = default_navbar() - if theme_options.get("footer_links", False) != []: + if not theme_options.get("footer_links", False): theme_options["footer_links"] = [ ("Code", "https://github.com/sunpy", 3), ("Forum", "https://community.openastronomy.org/c/sunpy", 3), diff --git a/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_center.html b/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_center.html index 898f43bd..51f7136e 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_center.html +++ b/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_center.html @@ -29,5 +29,10 @@ {% endif %} {%- endfor %} {% endif %} + {% if theme_external_links %} + {%- for external_link in theme_external_links %} + + {%- endfor %} + {% endif %} diff --git a/src/sunpy_sphinx_theme/theme/sunpy/sections/footer.html b/src/sunpy_sphinx_theme/theme/sunpy/sections/footer.html deleted file mode 100644 index 691cd5f6..00000000 --- a/src/sunpy_sphinx_theme/theme/sunpy/sections/footer.html +++ /dev/null @@ -1,25 +0,0 @@ -{% if theme_footer_start or theme_footer_end %} - -{% endif %} diff --git a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css index c6f48839..a2ef540a 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +++ b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css @@ -39,7 +39,7 @@ /* Component Colors */ /* If you add or change the names of these please update the docs */ - --sst-footer-background-color: var(--sst-dark-color); + --sst-footer-background-color: var(--sst-lightest-color); --sst-header-background: var(--sst-dark-color); --sst-header-text: var(--sst-lighter-color); --sst-sidebar-background-color: var(--pst-color-background); @@ -82,7 +82,7 @@ html[data-theme="light"] { --pst-color-secondary: var(--sst-accent-color-bright); --pst-color-shadow: rgba(0, 0, 0, 0.1); --pst-color-success-bg: #d6ece1; - --pst-color-surface: #f3f4f5; + --pst-color-surface: var(--sst-lightest-color); --pst-color-target: #f3cf95; --pst-color-text-muted: #48566b; --pst-color-warning-bg: #f8e3d0; @@ -116,7 +116,7 @@ html[data-theme="dark"] { --pst-color-secondary: var(--sst-accent-color-bright); --pst-color-shadow: rgba(0, 0, 0, 0.2); --pst-color-success-bg: #002f17; - --pst-color-surface: #29313d; + --pst-color-surface: var(--sst-darker-color); --pst-color-target: #675c04; --pst-color-text-muted: #9ca4af; --pst-color-warning-bg: #652a02; @@ -232,7 +232,7 @@ html[data-theme="light"] .bd-sidebar-primary .theme-switch-button span { --bs-dropdown-border-radius: 0rem; background-color: var(--sst-header-background); box-shadow: none; - margin-top: 0.85rem; + margin-top: 0.86rem; border: 0; border-color: var(--sst-accent-color-bright); } @@ -281,12 +281,57 @@ img.logo__image { color: var(--pst-color-primary); } +/* Hide the search bar in the flyout */ +.rst-other-versions dl:has(form#flyout-search-form) { + display: none; +} + +/* Reduce the margin at the end */ +.rst-versions .rst-other-versions hr { + margin: 5px 0; + border-top-color: var(--pst-color-border); +} + /* Bizzarely having a minimum height here fixes the permanent appearance of the */ /* sidebar scrollbar */ #rtd-footer-container { min-height: 1rem; } +/* Revert the flyout footer to the RTD font size */ +.rst-versions small { + font-size: 90%; +} + +/* Search Box */ +.search-button__wrapper.show input { + border: none; +} +.form-control { + border: none; +} + +.form-control:focus, +.form-control:focus-visible { + outline: none; +} + +form.bd-search:focus-within { + border: 2px solid var(--pst-color-accent); +} + +.search-button-field { + border: 2px solid rgba(0, 0, 0, 0); +} + +html[data-theme="light"] .search-button-field:hover { + background-color: var(--sst-light-color); +} + +html[data-theme="dark"] .search-button-field:hover { + background-color: var(--sst-darkest-color); +} + /* Footers */ .bd-footer {