Skip to content

Commit da86e4d

Browse files
authored
Allow keyboard to activate permalink (#1162)
* Allow keyboard to activate permalink * Change permalink icon with Blendify's suggestion * Set permalink icon properly across Sphinx versions * Match prior style better
1 parent 0580798 commit da86e4d

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

sphinx_rtd_theme/__init__.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,10 @@ def setup(app):
5555
app.add_message_catalog('sphinx', rtd_locale_path)
5656
app.connect('config-inited', config_initiated)
5757

58+
# sphinx emits the permalink icon for headers, so choose one more in keeping with our theme
59+
if sphinx_version >= (3, 5, 0):
60+
app.config.html_permalinks_icon = "\uf0c1"
61+
else:
62+
app.config.html_add_permalinks = "\uf0c1"
63+
5864
return {'parallel_read_safe': True, 'parallel_write_safe': True}

src/sass/_theme_rst.sass

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -200,14 +200,15 @@
200200
// This is the #href that shows up on hover. Sphinx's is terrible so I hack it away.
201201
h1, h2, h3, h4, h5, h6, dl dt, p.caption, table > caption, .code-block-caption
202202
.headerlink
203-
visibility: hidden
203+
opacity: 0
204204
font-size: 14px
205+
font-family: FontAwesome
206+
margin-left: 0.5em
205207
@extend .fa
206-
&:after
207-
content: "\f0c1"
208-
font-family: FontAwesome
209-
&:hover .headerlink:after
210-
visibility: visible
208+
&:focus
209+
opacity: 1
210+
&:hover .headerlink
211+
opacity: 1
211212

212213
// override the Wyrm accessibility anti-pattern of hiding button focus
213214
.btn:focus

0 commit comments

Comments
 (0)