pydata / pydata-sphinx-theme

A clean, three-column Sphinx theme with Bootstrap for the PyData community
https://pydata-sphinx-theme.readthedocs.io
BSD 3-Clause "New" or "Revised" License
557 stars 300 forks source link

Change the border color of tabs to --pst-color-border #1863

Closed timhoffm closed 3 weeks ago

timhoffm commented 3 weeks ago

1555 added a border around tabs. It uses --pst-color-primary:

grafik

IMHO primary color gives too much weight on the border. In this PR, suggest to change the color to --pst-color-border: grafik

trallard commented 3 weeks ago

Hey @timhoffm thanks for taking the time to work on this. Though the primary colour border is intentional to signal that such a tab is in an active state. This brings this state in alignment with the rest of the theme where active states are marked with the primary colour and also helps us meet accessibility standards.

I will let @smeragoel chime in as she led the design, but considering that we are prioritising accessible design and that she did quite a fair amount of research and work to make interactive elements design more accessible I would prefer not making this change.

timhoffm commented 3 weeks ago

Thanks @trallard for the feedback. To me (as a non-expert on accessibility) the focus should be on the tab head not the not whole tab box. The box is essentially like any static box. The active part is the head. Maybe something like this can work:

image

Changes:

This is just a suggestion. I'll leave it to you accessibility experts to decide what's best.

smeragoel commented 3 weeks ago

Thank you for your work, @timhoffm!

I considered --pst-color-border when working on this. However, the problem with this is that it does not provide sufficient contrast against the background and the inactive tabs.

Contrast Comparison: Color Background #FFFFFF Inactive Tabs #F3F4F5
--pst-color-border #D1D5DA 1.47:1 1.33:1
Primary Color #0A7D91 4.82:1 4.37:1

The goal behind this redesign was to make the active state clearer and the component more accessible. High contrast is necessary for making the tablist recognizable for all users, which naturally pulls more focus. You can find more details on this here.

Thank you for understanding and supporting our efforts to improve accessibility 😸

timhoffm commented 3 weeks ago

Thanks, understood.

Semi-OT questions:

trallard commented 3 weeks ago

Is the font weight on the tabs intentionally left bold? That setting comes from sphinx-design. I suppose they use it to set their otherwise completely flat tabs apart from regular text (c.f. sphinx-design.readthedocs.io/en/latest/tabs.html#tabs). With the grey background here, bold font seems unnecessary.

Yes, this is intentional. To provide a bit more context, there are at least 4 WCAG success criteria that touch on colour and how/when each applies to a given component is highly dependent on context/purpose/use.
One of such criteria is "Use of colour" which involves not using colour as the only way to indicate meaning or convey information. This ensures that components remain accessible for folks using accessibility settings (for example high contrast, screenshot added), assistive tech, and for folks with a variety of visual impairments/disabilities.

PST tabbed element in high contrast mode

Hence using a sufficiently different font weight (from the surrounding body and code text) helps with meeting such criteria.

Should there be an underline when hovering over tabs? On other navigation elements, we change color and underline. On tabs we only change color.

Yes or some other sort of indicator, we noted this already as it seems to have gone missing during implementation. So we should be fixing this soon.

Should --pst-color-border be darkened? It's used with cards and also doesn't fulfill the 3:1 contrast limit. Or do cards not count because they are not interactive elements?

This is a case where the contrast requirement is not critical for accessibility. Since these are not user interface (control) components, the border is not per se a means to convey information (such as state: hover, active, etc.). So, having a relatively low contrast does not hinder accessibility in any way; basically, the border can be considered purely decorative/visual styling. There is, however, a special case of clickable cards, though the Sufficient contrast criteria are met at the interaction point (hover, focus) by changing the border (colour, thickness) and pointer indicator.

timhoffm commented 3 weeks ago

Thanks for the detailed explanation. 👍

trallard commented 3 weeks ago

Thanks for taking the time and effort to help us make the theme better @timhoffm 💜