Skip to content

A11y: Increase the target area for single-letter index links #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Feb 13, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions python_docs_theme/static/pydoctheme.css
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,18 @@ dl > dt span ~ em {
padding-left: 20px;
}

div.genindex-jumpbox,
div.genindex-jumpbox > p {
display: inline-flex;
flex-wrap: wrap;
}

div.genindex-jumpbox a {
margin: 0 5px;
min-width: 30px;
text-align: center;
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Another option would be to use width and/or min-width, even though that only works on block elements IIRC, so you would have to turn the list into a flexbox.
The advantage of doing this is that the target box and the distance between the |s will be the same for all letters, and that the list will stay relatively compact.

You could even try to use negative margins to expand the clickable area on the space characters between the |s and the letters, but for accessibility purposes there should be enough space between a link target and the other, so it's probably not worth messing with negative margins.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea! Updated and rebuilt the demo:

image

https://hugovk-cpython.readthedocs.io/en/accessibilty-index-target-area/genindex.html

image

https://hugovk-cpython.readthedocs.io/en/accessibilty-index-target-area/genindex-all.html

Applied the flexbox container to two places here:

div.genindex-jumpbox,
div.genindex-jumpbox > p {
    display: inline-flex;
    flex-wrap: wrap;
}

Because the structure is slightly different on the two pages.

The first is:

<div class="genindex-jumpbox">
  <p> [all the A-Z links] </p>
  <p> [full index link] </p>
</div>

The second is:

<div class="genindex-jumpbox"> [all the A-Z links] </div>
HTML details
<div class="genindex-jumpbox">
   <p><a href="genindex-Symbols.html"><strong>Symbols</strong></a>
     | <a href="genindex-_.html"><strong>_</strong></a>
     | <a href="genindex-A.html"><strong>A</strong></a>
     | <a href="genindex-B.html"><strong>B</strong></a>
     | <a href="genindex-C.html"><strong>C</strong></a>
     | <a href="genindex-D.html"><strong>D</strong></a>
     | <a href="genindex-E.html"><strong>E</strong></a>
     | <a href="genindex-F.html"><strong>F</strong></a>
     | <a href="genindex-G.html"><strong>G</strong></a>
     | <a href="genindex-H.html"><strong>H</strong></a>
     | <a href="genindex-I.html"><strong>I</strong></a>
     | <a href="genindex-J.html"><strong>J</strong></a>
     | <a href="genindex-K.html"><strong>K</strong></a>
     | <a href="genindex-L.html"><strong>L</strong></a>
     | <a href="genindex-M.html"><strong>M</strong></a>
     | <a href="genindex-N.html"><strong>N</strong></a>
     | <a href="genindex-O.html"><strong>O</strong></a>
     | <a href="genindex-P.html"><strong>P</strong></a>
     | <a href="genindex-Q.html"><strong>Q</strong></a>
     | <a href="genindex-R.html"><strong>R</strong></a>
     | <a href="genindex-S.html"><strong>S</strong></a>
     | <a href="genindex-T.html"><strong>T</strong></a>
     | <a href="genindex-U.html"><strong>U</strong></a>
     | <a href="genindex-V.html"><strong>V</strong></a>
     | <a href="genindex-W.html"><strong>W</strong></a>
     | <a href="genindex-X.html"><strong>X</strong></a>
     | <a href="genindex-Y.html"><strong>Y</strong></a>
     | <a href="genindex-Z.html"><strong>Z</strong></a>
     </p>

   <p><a href="genindex-all.html"><strong>Full index on one page</strong>
                                               (can be huge)</a></p>
   </div>
<div class="genindex-jumpbox">
 <a href="#Symbols"><strong>Symbols</strong></a>
 | <a href="#_"><strong>_</strong></a>
 | <a href="#A"><strong>A</strong></a>
 | <a href="#B"><strong>B</strong></a>
 | <a href="#C"><strong>C</strong></a>
 | <a href="#D"><strong>D</strong></a>
 | <a href="#E"><strong>E</strong></a>
 | <a href="#F"><strong>F</strong></a>
 | <a href="#G"><strong>G</strong></a>
 | <a href="#H"><strong>H</strong></a>
 | <a href="#I"><strong>I</strong></a>
 | <a href="#J"><strong>J</strong></a>
 | <a href="#K"><strong>K</strong></a>
 | <a href="#L"><strong>L</strong></a>
 | <a href="#M"><strong>M</strong></a>
 | <a href="#N"><strong>N</strong></a>
 | <a href="#O"><strong>O</strong></a>
 | <a href="#P"><strong>P</strong></a>
 | <a href="#Q"><strong>Q</strong></a>
 | <a href="#R"><strong>R</strong></a>
 | <a href="#S"><strong>S</strong></a>
 | <a href="#T"><strong>T</strong></a>
 | <a href="#U"><strong>U</strong></a>
 | <a href="#V"><strong>V</strong></a>
 | <a href="#W"><strong>W</strong></a>
 | <a href="#X"><strong>X</strong></a>
 | <a href="#Y"><strong>Y</strong></a>
 | <a href="#Z"><strong>Z</strong></a>
 
</div>


@media (max-width: 1023px) {
/* Body layout */
div.body {
Expand Down