From a6c5dbb7b07f139ac4e49de2be29ed54c6792395 Mon Sep 17 00:00:00 2001 From: Stuart Mumford Date: Thu, 7 Sep 2023 17:42:22 +0100 Subject: [PATCH] Assorted fixes (#218) --- src/sunpy_sphinx_theme/__init__.py | 11 ++++++----- .../theme/sunpy/components/navbar_start.html | 17 +++++++++++++---- .../theme/sunpy/static/sunpy_style.css | 2 +- src/sunpy_sphinx_theme/theme/sunpy/theme.conf | 6 +++++- 4 files changed, 25 insertions(+), 11 deletions(-) diff --git a/src/sunpy_sphinx_theme/__init__.py b/src/sunpy_sphinx_theme/__init__.py index b3238d7e..b36a6dd1 100644 --- a/src/sunpy_sphinx_theme/__init__.py +++ b/src/sunpy_sphinx_theme/__init__.py @@ -67,16 +67,17 @@ def update_config(app): # To do this, you must manually modify `app.builder.theme_options`. theme_options = utils.get_theme_options_dict(app) - if not theme_options.get("sst_site_root"): - theme_options["sst_site_root"] = "https://sunpy.org" + if theme_options.get("sst_logo"): + if not isinstance(theme_options["sst_logo"], dict): + sst_logo = str(theme_options["sst_logo"]) + theme_options["sst_logo"] = {"light": sst_logo, "dark": sst_logo} - if not theme_options.get("sst_is_root"): - theme_options["sst_is_root"] = False + theme_options["sst_is_root"] = bool(theme_options.get("sst_is_root", False)) if not theme_options.get("navbar_links"): theme_options["navbar_links"] = default_navbar() - if not theme_options.get("footer_links"): + if 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_start.html b/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_start.html index 6c3247de..01317717 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_start.html +++ b/src/sunpy_sphinx_theme/theme/sunpy/components/navbar_start.html @@ -1,6 +1,15 @@ - {%- block sidebarlogo %} - {%- if logo %}{%- endif %} - {%- endblock %} - SunPy + {% if theme_sst_logo %} + {# Theme switching is only available when JavaScript is enabled. + # Thus we should add the extra image using JavaScript, defaulting + # depending on the value of default_mode; and light if unset. + #} + {% if default_mode is undefined or default_mode == "auto" %} + {% set default_mode = "light" %} + {% endif %} + {% set js_mode = "light" if default_mode == "dark" else "dark" %} + {{ alt }} + + {% endif %} + {{ theme_sst_project_name }} 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 878fbc0a..6b4cbb0c 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css +++ b/src/sunpy_sphinx_theme/theme/sunpy/static/sunpy_style.css @@ -34,7 +34,7 @@ html { } html[data-theme="light"] { - --pst-color-primary: var(--sst-darker-gray); + --pst-color-primary: var(--sst-darker-color); --pst-color-secondary: var(--sst-accent-color-muted); --pst-color-link: var(--sst-accent-color-muted); --sst-footer-background-color: var(--sst-lightest-color); diff --git a/src/sunpy_sphinx_theme/theme/sunpy/theme.conf b/src/sunpy_sphinx_theme/theme/sunpy/theme.conf index a9c4ac7a..309b7ad0 100644 --- a/src/sunpy_sphinx_theme/theme/sunpy/theme.conf +++ b/src/sunpy_sphinx_theme/theme/sunpy/theme.conf @@ -12,8 +12,12 @@ footer_end = components/built-with.html # sunpy-sphinx-theme config footer_center = components/footer-links.html # This config sets the base URL for top navbar items when sst_is_root is False -sst_site_root = "https://sunpy.org" +sst_site_root = https://sunpy.org # If true then the site that's being built is the site that's normally deployed at sst_site_root sst_is_root = False +# This is the name that appears in the top left of the navbar +sst_project_name = SunPy +# The logo to go in the top navbar in place of the project name +sst_logo = navbar_links = footer_links =