Skip to content

Commit

Permalink
Better integration of Read the Docs' embed
Browse files Browse the repository at this point in the history
This makes it feel more integrated with the rest of the theme.
  • Loading branch information
pradyunsg committed Feb 13, 2022
1 parent 1ee52a7 commit 1e38428
Show file tree
Hide file tree
Showing 4 changed files with 76 additions and 1 deletion.
1 change: 1 addition & 0 deletions src/furo/assets/styles/_scaffold.sass
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ article

.sidebar-scroll,
.toc-scroll
flex-grow: 1
flex-shrink: 1

overflow: auto
Expand Down
40 changes: 40 additions & 0 deletions src/furo/assets/styles/extensions/_readthedocs.sass
Original file line number Diff line number Diff line change
Expand Up @@ -17,3 +17,43 @@

.ethical-callout a
color: var(--color-foreground-secondary) !important

#furo-readthedocs-versions
position: static
width: 100%
background: transparent

.rst-current-version
background: var(--color-sidebar-item-background)
&:hover
background: var(--color-sidebar-item-background--hover)
.fa-book
color: var(--color-foreground-primary)

> .rst-other-versions
padding: 0

.injected
.rst-versions
position: unset

&:hover,
&:focus-within
.rst-current-version
font-size: inherit
background: #272525
&:hover
background: #272525
.fa-book
color: white

.fa-caret-down
display: none

.rst-current-version,
.rst-other-versions,
.injected
display: block

> .rst-current-version
display: none
33 changes: 33 additions & 0 deletions src/furo/theme/furo/sidebar/variant-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{# Add variant selector for Read the Docs embedding #}
{% if READTHEDOCS %}
<div id="furo-readthedocs-versions" class="rst-versions" data-toggle="rst-versions" role="note" aria-label="{{ _('Versions') }}" tabindex="0">
<span class="rst-current-version" data-toggle="rst-current-version">
<span class="fa fa-book">&nbsp;</span>
{{ current_version }}
</span>
<div class="rst-other-versions">
<dl>
<dt>{{ _('Versions') }}</dt>
{% for slug, url in versions %}
<dd><a href="{{ url }}">{{ slug }}</a></dd>
{% endfor %}
</dl>
<dl>
<dt>{{ _('Downloads') }}</dt>
{% for type, url in downloads %}
<dd><a href="{{ url }}">{{ type }}</a></dd>
{% endfor %}
</dl>
<dl>
{# Translators: The phrase "Read the Docs" is not translated #}
<dt>{{ _('On Read the Docs') }}</dt>
<dd>
<a href="//{{ PRODUCTION_DOMAIN }}/projects/{{ slug }}/?fromdocs={{ slug }}">{{ _('Project Home') }}</a>
</dd>
<dd>
<a href="//{{ PRODUCTION_DOMAIN }}/builds/{{ slug }}/?fromdocs={{ slug }}">{{ _('Builds') }}</a>
</dd>
</dl>
</div>
</div>
{% endif %}
3 changes: 2 additions & 1 deletion src/furo/theme/furo/theme.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ sidebars =
sidebar/scroll-start.html,
sidebar/navigation.html,
sidebar/ethical-ads.html,
sidebar/scroll-end.html
sidebar/scroll-end.html,
sidebar/variant-selector.html
# sidebar-end

[options]
Expand Down

0 comments on commit 1e38428

Please sign in to comment.