Skip to content

Commit 920c91d

Browse files
authored
Resolve current sidebar link notch and focus ring (#1561)
* Fix sidebar current notch * focus-ring-radius * missed a spot 0.125rem * keep focus ring on top
1 parent 85badcb commit 920c91d

File tree

7 files changed

+34
-11
lines changed

7 files changed

+34
-11
lines changed

src/pydata_sphinx_theme/assets/styles/abstracts/_links.scss

+15-2
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,12 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
123123
&:active {
124124
color: var(--pst-color-link-hover);
125125
}
126+
127+
&:focus-visible {
128+
box-shadow: $focus-ring-box-shadow;
129+
outline: none;
130+
z-index: 10; // keep focus ring on top (prevent the link-sidebar-current notch from lying on top of the ring)
131+
}
126132
}
127133

128134
// Sidebar current page link styles
@@ -135,9 +141,16 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
135141
font-weight: 600;
136142
color: var(--pst-color-primary);
137143
@if $link-hover-decoration-thickness {
138-
border-left: $link-hover-decoration-thickness
139-
solid
144+
$notch-shadow: inset
145+
$link-hover-decoration-thickness
146+
0px
147+
0px
140148
var(--pst-color-primary);
149+
box-shadow: $notch-shadow;
150+
&:focus-visible {
151+
box-shadow: $notch-shadow, $focus-ring-box-shadow;
152+
outline: none;
153+
}
141154
}
142155
}
143156

src/pydata_sphinx_theme/assets/styles/base/_base.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -182,9 +182,9 @@ pre {
182182

183183
// Focus ring
184184
//
185-
// Note: The Bootstrap stylesheet provides the focus ring (customized via Sass
186-
// variables in _bootstrap.scss) in some cases. This rules covers all other
187-
// cases.
185+
// Note: The Bootstrap stylesheet provides the focus ring (customized by this
186+
// theme via Sass variables in _bootstrap.scss) in some cases. This rule covers
187+
// all other cases.
188188
:focus-visible {
189189
outline: $focus-ring-outline;
190190
box-shadow: none; // override Bootstrap

src/pydata_sphinx_theme/assets/styles/components/_switcher-version.scss

+3
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ button.btn.version-switcher__button {
4545
top: 0;
4646
}
4747
}
48+
&:focus-visible {
49+
z-index: 10; // keep focus ring on top (prevent the hover background of the next dropdown item from covering the ring)
50+
}
4851
}
4952
}
5053

src/pydata_sphinx_theme/assets/styles/components/_toc-inpage.scss

+3-3
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ nav.page-toc {
4747
color: var(--pst-color-link-hover);
4848
}
4949
}
50-
}
5150

52-
:focus-visible {
53-
border-radius: 0.125rem;
51+
&:focus-visible {
52+
border-radius: $focus-ring-radius;
53+
}
5454
}
5555
}

src/pydata_sphinx_theme/assets/styles/sections/_header.scss

+5-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
}
3030

3131
:focus-visible {
32-
border-radius: 0.125rem;
32+
border-radius: $focus-ring-radius;
3333
}
3434

3535
// These items will define the height of the header
@@ -123,6 +123,10 @@
123123
&:focus:not(:hover):not(:active) {
124124
background-color: inherit;
125125
}
126+
127+
&:focus-visible {
128+
z-index: 10; // keep focus ring on top (prevent the hover background of the next dropdown item from covering the ring)
129+
}
126130
}
127131

128132
// Hide the menu unless show has been clicked

src/pydata_sphinx_theme/assets/styles/sections/_sidebar-primary.scss

+1-2
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
font-size: var(--pst-sidebar-font-size);
2424
}
2525

26-
// Focus styles
2726
:focus-visible {
28-
border-radius: 0.125rem;
27+
border-radius: $focus-ring-radius;
2928
}
3029

3130
// override bootstrap when navlink are displayed in the sidebar

src/pydata_sphinx_theme/assets/styles/variables/_layout.scss

+4
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,7 @@ $animation-time: 200ms;
3131
* UI shaping and padding
3232
*/
3333
$admonition-border-radius: 0.25rem;
34+
35+
// In this theme, some focus rings have rounded corners while others do not.
36+
// This variable sets the border radius for the rounded focus rings.
37+
$focus-ring-radius: 0.125rem; // 2px at 100% zoom and 16px base font.

0 commit comments

Comments
 (0)