From 154f273d07977ad572005b93225633619e1d1c61 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 16 Mar 2022 21:06:26 +0100 Subject: [PATCH 1/3] [fix] don't append CSS files to the end of html_static_path list (#153) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit html_static_path is a list of paths that contain custom static files. They are copied to the output’s _static directory **after** the theme’s static files, so a file named default.css will overwrite the theme’s default.css [1] Without this patch a tabs.css can't be overwritten by the `conf.py` file: html_static_path = [ 'static/tabs.css', ] The /static folder from sphinx-tabs needs to be added in front of html_static_path since the last item in the list will be written last to /_static. [1] https://www.sphinx-doc.org/en/master/usage/configuration.html#confval-html_static_path Signed-off-by: Markus Heiser --- sphinx_tabs/tabs.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sphinx_tabs/tabs.py b/sphinx_tabs/tabs.py index e99c500..4c0b6ca 100644 --- a/sphinx_tabs/tabs.py +++ b/sphinx_tabs/tabs.py @@ -355,7 +355,7 @@ def setup(app): static_dir = Path(__file__).parent / "static" app.connect( "builder-inited", - (lambda app: app.config.html_static_path.append(static_dir.as_posix())), + (lambda app: app.config.html_static_path.insert(0, static_dir.as_posix())), ) app.connect("config-inited", update_config) app.connect("html-page-context", update_context) From 5b2f4eebe457a03eec10c504355727eb167219f7 Mon Sep 17 00:00:00 2001 From: Markus Heiser Date: Wed, 16 Mar 2022 21:09:04 +0100 Subject: [PATCH 2/3] [fix] prefers-color-scheme: use dark theme if body[data-theme="auto"] (#154) Before this patch the CSS implementation assumes that "dark" is supported by the theme if the `data-theme` attribute of the tag is unset. Since most themes are using "light" colors (compare https://sphinx-themes.org) and do not set `data-theme` it is better to assume light is the default, even when the browser setting `prefers-color-scheme: dark`! BTW: remove duplication of styles from dark/light theme that are already set in the common style. Signed-off-by: Markus Heiser --- sphinx_tabs/static/tabs.css | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-) diff --git a/sphinx_tabs/static/tabs.css b/sphinx_tabs/static/tabs.css index 02eaeb4..957ba60 100644 --- a/sphinx_tabs/static/tabs.css +++ b/sphinx_tabs/static/tabs.css @@ -55,23 +55,18 @@ /* Dark theme preference styling */ @media (prefers-color-scheme: dark) { - body:not([data-theme="light"]) .sphinx-tabs-panel { + body[data-theme="auto"] .sphinx-tabs-panel { color: white; background-color: rgb(50, 50, 50); } - body:not([data-theme="light"]) .sphinx-tabs-tab { + body[data-theme="auto"] .sphinx-tabs-tab { color: white; - font-size: 16px; - font-weight: 400; background-color: rgba(255, 255, 255, 0.05); } - body:not([data-theme="light"]) .sphinx-tabs-tab[aria-selected="true"] { - font-weight: 700; - border: 1px solid #a0b3bf; + body[data-theme="auto"] .sphinx-tabs-tab[aria-selected="true"] { border-bottom: 1px solid rgb(50, 50, 50); - margin: -1px; background-color: rgb(50, 50, 50); } } @@ -85,16 +80,10 @@ body[data-theme="dark"] .sphinx-tabs-panel { body[data-theme="dark"] .sphinx-tabs-tab { color: white; - font-size: 16px; - font-weight: 400; - border: 1px solid rgba(255, 255, 255, 0.15); background-color: rgba(255, 255, 255, 0.05); } body[data-theme="dark"] .sphinx-tabs-tab[aria-selected="true"] { - font-weight: 700; - border: 1px solid #a0b3bf; border-bottom: 2px solid rgb(50, 50, 50); - margin: -1px; background-color: rgb(50, 50, 50); } From 0b04c8eb37075d57f6d5ad321ca40f4e800894f8 Mon Sep 17 00:00:00 2001 From: David Foster Date: Thu, 17 Mar 2022 19:47:49 +0000 Subject: [PATCH 3/3] RELEASE: v3.3.1 --- CHANGELOG.md | 7 +++++++ sphinx_tabs/__init__.py | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ad7615..8133a78 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Change Log +## 3.3.1 - 2022-03-17 + +### Fixed + +* Inserting CSS at the start of the static path list, so that it can be overwritten +* Assume light theme is the default, even when browser setting prefers dark. Necessary when most sphinx themes don't set `data-theme`. + ## 3.3.0 - 2022-03-09 ### Added diff --git a/sphinx_tabs/__init__.py b/sphinx_tabs/__init__.py index 5833c51..bec7509 100644 --- a/sphinx_tabs/__init__.py +++ b/sphinx_tabs/__init__.py @@ -1,3 +1,3 @@ -__version__ = "3.3.0" +__version__ = "3.3.1" __import__("pkg_resources").declare_namespace(__name__)