nextstrain / sphinx-theme

A Sphinx theme for Nextstrain's documentation, based on Read The Docs' default theme.
https://docs.nextstrain.org/projects/sphinx-theme/
MIT License
0 stars 5 forks source link

Add custom Nextstrain footer #2

Closed jameshadfield closed 3 years ago

jameshadfield commented 3 years ago

This modifies the footer to mimic the current Nextstrain (docs) footer. The content and styles are largely taken from https://github.com/nextstrain/nextstrain.org/blob/b1e09e57e91ed0c9343e1cd3104877ec3c5344a4/static-site/src/components/Footer/index.jsx

It is not identical -- the RTD footer doesn't fill the available horizontal space for example -- but it's close.

It's largely written in plain HTML + CSS, as opposed to the source material which was JSX + Styled Components. There may be a much nicer way to write this using Jinja functionality.

jameshadfield commented 3 years ago

P.S. We can restore the footer to occupy all the available horizontal space without too much trouble, although there are still some tweaks necessary around the buttons etc:

diff --git a/lib/nextstrain/sphinx/theme/static/css/nextstrain.css b/lib/nextstrain/sphinx/theme/static/css/nextstrain.css
index f4ae133..5a2034c 100644
--- a/lib/nextstrain/sphinx/theme/static/css/nextstrain.css
+++ b/lib/nextstrain/sphinx/theme/static/css/nextstrain.css
@@ -74,7 +74,16 @@ footer span.commit code,
 /* main content section */
 .wy-nav-content {
   background: var(--content-background-color);
+  max-width: inherit; /* we'll set this on a child instead so it doesn't affect the footer */
 }
+div.rst-content > div.document {
+  display: flex;
+  justify-content: center;
+}
+div.rst-content > div.document > div {
+  max-width: 800px;
+}
+
jameshadfield commented 3 years ago

Does this make the footer wider than the main content at times? Or does the whole page adjust to the available horizontal space?

This PR keeps the RTD-theme behavior, where the footer width is the same as the "main docs content" width (as in above screenshot). The patch in my above comment would change this a bit, however I'll leave that for a separate PR as suggested.