From e3ca5ab4e5c80af0144d79503cc87c5096d2ab2b Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 25 Nov 2024 11:54:24 +0100 Subject: [PATCH 1/3] use non-vendorized head variables --- .../styles => }/partials/_head_css_variables.html | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) rename src/crate/theme/rtd/crate/{static/vendor/furo/styles => }/partials/_head_css_variables.html (72%) diff --git a/src/crate/theme/rtd/crate/static/vendor/furo/styles/partials/_head_css_variables.html b/src/crate/theme/rtd/crate/partials/_head_css_variables.html similarity index 72% rename from src/crate/theme/rtd/crate/static/vendor/furo/styles/partials/_head_css_variables.html rename to src/crate/theme/rtd/crate/partials/_head_css_variables.html index 2101208a..9fbca52c 100644 --- a/src/crate/theme/rtd/crate/static/vendor/furo/styles/partials/_head_css_variables.html +++ b/src/crate/theme/rtd/crate/partials/_head_css_variables.html @@ -13,16 +13,21 @@ \ No newline at end of file From 07da0b15e01cb15b0cc7dd54bb69a53a35c4867a Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 25 Nov 2024 11:54:49 +0100 Subject: [PATCH 2/3] use vendorized colors to make mixins work --- .../theme/rtd/crate/static/css/ng/index.scss | 1 - .../vendor/furo/styles/base/_theme.sass | 48 +++++++++++++++++++ .../vendor/furo/styles/variables/_index.sass | 2 +- .../furo/styles/variables}/colors.scss | 4 +- 4 files changed, 51 insertions(+), 4 deletions(-) rename src/crate/theme/rtd/crate/static/{css/ng => vendor/furo/styles/variables}/colors.scss (99%) diff --git a/src/crate/theme/rtd/crate/static/css/ng/index.scss b/src/crate/theme/rtd/crate/static/css/ng/index.scss index ec4d1d97..8ae26e92 100644 --- a/src/crate/theme/rtd/crate/static/css/ng/index.scss +++ b/src/crate/theme/rtd/crate/static/css/ng/index.scss @@ -2,4 +2,3 @@ @import "layout"; @import "furo"; @import "page-tools"; -@import "colors"; diff --git a/src/crate/theme/rtd/crate/static/vendor/furo/styles/base/_theme.sass b/src/crate/theme/rtd/crate/static/vendor/furo/styles/base/_theme.sass index 675e47ed..4865c213 100644 --- a/src/crate/theme/rtd/crate/static/vendor/furo/styles/base/_theme.sass +++ b/src/crate/theme/rtd/crate/static/vendor/furo/styles/base/_theme.sass @@ -11,3 +11,51 @@ body @include default-admonition(#651fff, "abstract") @include default-topic(#14B8A6, "pencil") + @include colors + +.only-light + display: block !important +html body .only-dark + display: none !important + +// Ignore dark-mode hints if print media. +@media not print + // Enable dark-mode, if requested. + body[data-theme="dark"] + @include colors-dark + + html & .only-light + display: none !important + .only-dark + display: block !important + + // Enable dark mode, unless explicitly told to avoid. + @media (prefers-color-scheme: dark) + body:not([data-theme="light"]) + @include colors-dark + + html & .only-light + display: none !important + .only-dark + display: block !important + +// +// Theme toggle presentation +// +body[data-theme="auto"] + .theme-toggle svg.theme-icon-when-auto-light + display: block + + @media (prefers-color-scheme: dark) + .theme-toggle svg.theme-icon-when-auto-dark + display: block + .theme-toggle svg.theme-icon-when-auto-light + display: none + +body[data-theme="dark"] + .theme-toggle svg.theme-icon-when-dark + display: block + +body[data-theme="light"] + .theme-toggle svg.theme-icon-when-light + display: block diff --git a/src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/_index.sass b/src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/_index.sass index ddf94643..d8e7ebfd 100644 --- a/src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/_index.sass +++ b/src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/_index.sass @@ -5,4 +5,4 @@ @import "spacing" @import "icons" @import "admonitions" -//@import "colors" +@import "colors" diff --git a/src/crate/theme/rtd/crate/static/css/ng/colors.scss b/src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/colors.scss similarity index 99% rename from src/crate/theme/rtd/crate/static/css/ng/colors.scss rename to src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/colors.scss index 46e73a4b..fb6657bd 100644 --- a/src/crate/theme/rtd/crate/static/css/ng/colors.scss +++ b/src/crate/theme/rtd/crate/static/vendor/furo/styles/variables/colors.scss @@ -21,7 +21,7 @@ body[data-theme="light"] { } } -[data-theme="light"] { +@mixin colors { // API documentation --color-api-background: var(--color-background-hover--transparent); --color-api-background-hover: var(--color-background-hover); @@ -175,7 +175,7 @@ body[data-theme="light"] { --link-toc: #000; } -[data-theme="dark"] { +@mixin colors-dark { // API documentation --color-api-background: var(--color-background-hover--transparent); --color-api-background-hover: var(--color-background-hover); From 4e6b2528c4ce2950ecaade5e74a630cace4e6c43 Mon Sep 17 00:00:00 2001 From: Matthias Date: Mon, 25 Nov 2024 12:21:54 +0100 Subject: [PATCH 3/3] use proper `base.html` and clean up `page.html` --- src/crate/theme/rtd/crate/base.html | 368 +++++++++++----------------- src/crate/theme/rtd/crate/page.html | 90 ++----- 2 files changed, 169 insertions(+), 289 deletions(-) diff --git a/src/crate/theme/rtd/crate/base.html b/src/crate/theme/rtd/crate/base.html index f5021179..07839cb1 100644 --- a/src/crate/theme/rtd/crate/base.html +++ b/src/crate/theme/rtd/crate/base.html @@ -1,144 +1,63 @@ -{# - basic/layout.html - ~~~~~~~~~~~~~~~~~ - - Master layout template for Sphinx themes. - - :copyright: Copyright 2007-2014 by the Sphinx team, see AUTHORS. - :license: BSD, see LICENSE for details. -#} -{%- block doctype -%} - -{%- endblock %} -{%- set reldelim1 = reldelim1 is not defined and ' »' or reldelim1 %} -{%- set reldelim2 = reldelim2 is not defined and ' |' or reldelim2 %} -{%- set render_sidebar = (not embedded) and (not theme_nosidebar|tobool) and - (sidebars != []) %} -{%- set url_root = pathto('', 1) %} -{# XXX necessary? #} -{%- if url_root == '#' %}{% set url_root = '' %}{% endif %} -{%- if not embedded and docstitle %} - {%- set titlesuffix = " — "|safe + docstitle|e %} -{%- else %} - {%- set titlesuffix = "" %} -{%- endif %} - -{%- macro relbar() %} - -{%- endmacro %} - -{%- macro sidebar() %} - {%- if render_sidebar %} -
-
- {%- block sidebarlogo %} - {%- if logo %} - - {%- endif %} - {%- endblock %} - {%- if sidebars != None %} - {#- new style sidebar: explicitly include/exclude templates #} - {%- for sidebartemplate in sidebars %} - {%- include sidebartemplate %} - {%- endfor %} - {%- else %} - {#- old style sidebars: using blocks -- should be deprecated #} - {%- block sidebartoc %} - {%- include "localtoc.html" %} - {%- endblock %} - {%- block sidebarrel %} - {%- include "relations.html" %} - {%- endblock %} - {%- block sidebarsourcelink %} - {%- include "sourcelink.html" %} - {%- endblock %} - {%- if customsidebar %} - {%- include customsidebar %} - {%- endif %} - {%- block sidebarsearch %} - {%- include "searchbox.html" %} - {%- endblock %} - {%- endif %} -
-
- {%- endif %} -{%- endmacro %} - -{%- macro script() %} - + + + + {%- block site_meta -%} + + + + + {%- if metatags %}{{ metatags }}{% endif -%} + + {%- block linktags %} + {%- if hasdoc('about') -%} + + {%- endif -%} + {#%- if hasdoc('genindex') -%} + + {%- endif -%#} + {%- if hasdoc('search') -%} + + {%- endif -%} + {#%- if hasdoc('copyright') -%} + + {%- endif -%#} + {%- if next -%} + + {%- endif -%} + {%- if prev -%} + + {%- endif -%} + {#- rel="canonical" (set by html_baseurl) -#} + {#%- if pageurl %} + + {%- endif %#} + {%- endblock linktags %} + + {# Favicon #} + + + {%- endblock site_meta -%} + + {% block head_extra %} - - {{ js_tag("_static/bundle/main.js") }} - - {%- for js in script_files %} - {{ js_tag(js) }} - {%- endfor %} - - {%- for js in extra_script_files %} - {{ js_tag(js) }} - {%- endfor %} - -{%- endmacro %} - -{%- macro css() %} - - {%- for css in css_files %} - {%- if css|attr("filename") %} - {{ css_tag(css) }} - {%- else %} - - {%- endif %} - {%- endfor %} - - {%- for css in extra_css_files %} - {%- if css|attr("filename") %} - {{ css_tag(css) }} - {%- else %} - - {%- endif %} - {%- endfor %} - -{%- endmacro %} - - - - - {{ metatags }} - {%- block htmltitle %} - {{ title|striptags|e }}{{ titlesuffix }} - {%- endblock %} - {{ css() }} - {%- if not embedded %} - {%- block scripts %} - {{- script() }} - {%- endblock %} - {%- if use_opensearch %} - - {%- endif %} - + + + + + + + + + {%- if custom_baseurl %} {%- set canonical_page = pagename + ".html" %} {%- endif %} + {% endblock %} + + {#- Site title -#} + {%- block htmltitle -%} + {% if not docstitle %} + {{ title|striptags|e }} + {% elif pagename == master_doc %} + {{ docstitle|striptags|e }} + {% else %} + {{ title|striptags|e }} - {{ docstitle|striptags|e }} + {% endif %} + {%- endblock -%} + + {%- block styles -%} + + {# Custom stylesheets #} + {%- block regular_styles -%} + {% if not omit_skeleton_css -%} + + {%- endif -%} + + {%- for css in css_files -%} + {% if css|attr("filename") -%} + {{ css_tag(css) }} + {%- else -%} + + {%- endif %} + {% endfor -%} + {%- endblock regular_styles -%} - + {#- Theme-related stylesheets -#} + {%- block theme_styles %} + {% include "partials/_head_css_variables.html" with context %} + {%- endblock -%} - - {%- endif %} -{%- block linktags %} - {%- if hasdoc('about') %} - - {%- endif %} - {%- if hasdoc('genindex') %} - - {%- endif %} - {%- if hasdoc('search') %} - - {%- endif %} - {%- if hasdoc('copyright') %} - - {%- endif %} - - {%- if parents %} - - {%- endif %} - {%- if next %} - - {%- endif %} - {%- if prev %} - - {%- endif %} -{%- endblock %} -{%- block extra_head %} {% endblock %} + {%- block extra_styles %} + {%- endblock -%} + + {%- endblock styles -%} + + + {#- Custom front matter #} + {%- block extrahead -%}{%- endblock -%} - {% if project == 'SQL 99' %} - - {% else %} - {% endif %} - - - - -{%- block header %}{% endblock %} - -{%- block relbar1 %}{{ relbar() }}{% endblock %} - -{%- block content %} - {%- block sidebar1 %} {# possible location for sidebar #} {% endblock %} - -
- {%- block document %} -
- {%- if render_sidebar %} -
- {%- endif %} -
- {% block body %} {% endblock %} + {% block body %} + + {% endblock %} + + {%- block scripts -%} + + {# Custom JS #} + {%- block regular_scripts -%} + {% for path in script_files -%} + {{ js_tag(path) }} + {% endfor -%} + {%- endblock regular_scripts -%} + + {# Theme-related JavaScript code #} + {%- block theme_scripts -%} + {%- endblock -%} + + {%- endblock scripts -%} + + {% block footer %} +
+ - {%- endblock %} - - {%- block sidebar2 %}{{ sidebar() }}{% endblock %} -
-
-{%- endblock %} - -{%- block relbar2 %}{{ relbar() }}{% endblock %} - -{%- block custom_footer %} - -{%- endblock %} - + + + {% endblock footer %} diff --git a/src/crate/theme/rtd/crate/page.html b/src/crate/theme/rtd/crate/page.html index 657fc459..38cf42b8 100644 --- a/src/crate/theme/rtd/crate/page.html +++ b/src/crate/theme/rtd/crate/page.html @@ -1,38 +1,21 @@ {# Layout: This is used by _every_ Sphinx content page #} -{% extends "basic-ng/page.html" %} +{% extends "base.html" %} -{% block head_extra %} - - - - - - - - - - - - +{% block body -%} +{{ super() }} +{% include "partials/icons.html" %} - {%- if custom_baseurl %} - {%- set canonical_page = pagename + ".html" %} - - - {%- endif %} + + {%- trans -%} + Skip to content + {%- endtrans -%} + -{% endblock %} +{% block announcement %} +
+ {% include "sections/announcement.html" %} +
+{% endblock announcement %} {% block header %}
@@ -45,6 +28,11 @@ {% block header_secondary %} {% endblock header_secondary %} + + + + + {% block container %}
@@ -67,7 +55,7 @@
{% include "sections/header-article.html" %}
-
+
{% include "sections/article.html" %}
@@ -88,40 +76,4 @@
{% endblock container %} -{# Include Furo icons as first body element #} -{% block body -%} -{% include "partials/icons.html" %} -{{ super() }} -{% endblock %} - -{% block footer %} - -{% endblock footer %} +{%- endblock %}