Skip to content

Commit

Permalink
Resolve current sidebar link notch and focus ring (#1561)
Browse files Browse the repository at this point in the history
* Fix sidebar current notch

* focus-ring-radius

* missed a spot 0.125rem

* keep focus ring on top
  • Loading branch information
gabalafou authored Nov 16, 2023
1 parent 85badcb commit 920c91d
Show file tree
Hide file tree
Showing 7 changed files with 34 additions and 11 deletions.
17 changes: 15 additions & 2 deletions src/pydata_sphinx_theme/assets/styles/abstracts/_links.scss
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,12 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
&:active {
color: var(--pst-color-link-hover);
}

&:focus-visible {
box-shadow: $focus-ring-box-shadow;
outline: none;
z-index: 10; // keep focus ring on top (prevent the link-sidebar-current notch from lying on top of the ring)
}
}

// Sidebar current page link styles
Expand All @@ -135,9 +141,16 @@ $link-hover-decoration-thickness: unquote("max(3px, .1875rem, .12em)") !default;
font-weight: 600;
color: var(--pst-color-primary);
@if $link-hover-decoration-thickness {
border-left: $link-hover-decoration-thickness
solid
$notch-shadow: inset
$link-hover-decoration-thickness
0px
0px
var(--pst-color-primary);
box-shadow: $notch-shadow;
&:focus-visible {
box-shadow: $notch-shadow, $focus-ring-box-shadow;
outline: none;
}
}
}

Expand Down
6 changes: 3 additions & 3 deletions src/pydata_sphinx_theme/assets/styles/base/_base.scss
Original file line number Diff line number Diff line change
Expand Up @@ -182,9 +182,9 @@ pre {

// Focus ring
//
// Note: The Bootstrap stylesheet provides the focus ring (customized via Sass
// variables in _bootstrap.scss) in some cases. This rules covers all other
// cases.
// Note: The Bootstrap stylesheet provides the focus ring (customized by this
// theme via Sass variables in _bootstrap.scss) in some cases. This rule covers
// all other cases.
:focus-visible {
outline: $focus-ring-outline;
box-shadow: none; // override Bootstrap
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ button.btn.version-switcher__button {
top: 0;
}
}
&:focus-visible {
z-index: 10; // keep focus ring on top (prevent the hover background of the next dropdown item from covering the ring)
}
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ nav.page-toc {
color: var(--pst-color-link-hover);
}
}
}

:focus-visible {
border-radius: 0.125rem;
&:focus-visible {
border-radius: $focus-ring-radius;
}
}
}
6 changes: 5 additions & 1 deletion src/pydata_sphinx_theme/assets/styles/sections/_header.scss
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
}

:focus-visible {
border-radius: 0.125rem;
border-radius: $focus-ring-radius;
}

// These items will define the height of the header
Expand Down Expand Up @@ -123,6 +123,10 @@
&:focus:not(:hover):not(:active) {
background-color: inherit;
}

&:focus-visible {
z-index: 10; // keep focus ring on top (prevent the hover background of the next dropdown item from covering the ring)
}
}

// Hide the menu unless show has been clicked
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,8 @@
font-size: var(--pst-sidebar-font-size);
}

// Focus styles
:focus-visible {
border-radius: 0.125rem;
border-radius: $focus-ring-radius;
}

// override bootstrap when navlink are displayed in the sidebar
Expand Down
4 changes: 4 additions & 0 deletions src/pydata_sphinx_theme/assets/styles/variables/_layout.scss
Original file line number Diff line number Diff line change
Expand Up @@ -31,3 +31,7 @@ $animation-time: 200ms;
* UI shaping and padding
*/
$admonition-border-radius: 0.25rem;

// In this theme, some focus rings have rounded corners while others do not.
// This variable sets the border radius for the rounded focus rings.
$focus-ring-radius: 0.125rem; // 2px at 100% zoom and 16px base font.

0 comments on commit 920c91d

Please sign in to comment.