|
8 | 8 | button.toggle-button {
|
9 | 9 | color: inherit;
|
10 | 10 | }
|
| 11 | + |
| 12 | + // Focus ring |
| 13 | + // |
| 14 | + // Sphinx-togglebutton makes the entire admonition header clickable, but |
| 15 | + // only the button within the header is focusable. We want the entire |
| 16 | + // clickable area to be surrounded with a focus ring, so that's why we use |
| 17 | + // the :focus-within selector, rather than a :focus-visible selector on the |
| 18 | + // button. |
| 19 | + &:focus-within { |
| 20 | + overflow: visible; |
| 21 | + |
| 22 | + // The complicated focus ring styles here are a consequence of the markup |
| 23 | + // and border styles for this particular admonition class. (For the other |
| 24 | + // type of admonition on this site, the focus ring style is achieved with |
| 25 | + // simple `outline` and `outline-offset` rules on the admonition's |
| 26 | + // header.) The problem is that Sphinx-togglebutton puts the admonition's |
| 27 | + // left border on the outermost container (rather than separately setting |
| 28 | + // the left border on the container's children). This makes it complicated |
| 29 | + // to get the focus ring to simultaneously cover the left border in the |
| 30 | + // header and align perfectly on the right with the body. |
| 31 | + .admonition-title:focus-within:before { |
| 32 | + content: ""; |
| 33 | + transform: translateX( |
| 34 | + -$admonition-left-border-width |
| 35 | + ); // align left edges of admonition and ring |
| 36 | + width: calc(100% + $admonition-left-border-width); // align right edges |
| 37 | + height: 100%; |
| 38 | + border: $focus-ring-outline; |
| 39 | + border-radius: $focus-ring-width; |
| 40 | + } |
| 41 | + |
| 42 | + // When expanded, sharpen the bottom left and right corners of the focus ring |
| 43 | + &:not(.toggle-hidden) .admonition-title:focus-within:before { |
| 44 | + border-bottom-left-radius: 0; |
| 45 | + border-bottom-right-radius: 0; |
| 46 | + } |
| 47 | + } |
11 | 48 | }
|
12 | 49 |
|
13 | 50 | // Details buttons
|
|
16 | 53 | summary {
|
17 | 54 | border-left: 3px solid var(--pst-color-primary);
|
18 | 55 | }
|
| 56 | + |
| 57 | + // When expanded, sharpen the bottom left and right corners of the focus ring |
| 58 | + &[open] :focus-visible { |
| 59 | + border-bottom-left-radius: 0; |
| 60 | + border-bottom-right-radius: 0; |
| 61 | + } |
19 | 62 | }
|
20 | 63 | }
|
0 commit comments