Skip to content

a11y reading options bar#5340

Open
StephDriver wants to merge 56 commits into
r-v1.9.xfrom
b-5337-a11y-user-text-format
Open

a11y reading options bar#5340
StephDriver wants to merge 56 commits into
r-v1.9.xfrom
b-5337-a11y-user-text-format

Conversation

@StephDriver

@StephDriver StephDriver commented Jun 9, 2026

Copy link
Copy Markdown
Member

closes #5337

openlibhums/clarity#10 ports these changes to clarity.

@StephDriver
StephDriver changed the base branch from master to r-v1.9.x June 9, 2026 15:30
@StephDriver

This comment was marked as outdated.

@StephDriver StephDriver self-assigned this Jun 16, 2026
@StephDriver

StephDriver commented Jun 16, 2026

Copy link
Copy Markdown
Member Author

Limitations / Future Development.

  • Initially I introduced options for custom colours, but making the colour pickers accessible to both keyboard and screen-reader users across all three themes became a major piece of work which is out of scope for this issue. So I have left the code side of the customisation for use in future, but it is just not wired up to the templates. Note - the custom colour pickers work fine by mouse. see 6a8ab05

  • This has been created as a generic feature, which could be added to any page, however the targets on each page need to be set individually. So for this first version I have focused on areas of high text content (article, preprint, CMS, news item).

  • Material reading bar is not fully screen-reader accessible. But it is as accessible as the Material Nav - the limitation is Material itself. The state of items in the reading bar is announced, but the drop-downs do not have a menu popup collapsed or menu popup expanded state announced to user. This is the same as with the Material Nav.

  • Text size differences between themes - especially noticeable on mobile, the default text size is different on each theme, which means having customised it on say a Press running Clean and then going to a Journal on OLH, the customisations carry across, but the text looks a very different size. I'm classing this as out of scope, because the majority of users will not move between themes, it is easy enough to then adjust and this issue is intended to setup the basic functionality.

@StephDriver
StephDriver force-pushed the b-5337-a11y-user-text-format branch from 64d0182 to 9147cc4 Compare June 22, 2026 12:02
@StephDriver

Copy link
Copy Markdown
Member Author

Screenshots

Non-article pages

image

Article pages

Also include the draw-attention animation toggle, cite, email and print options, depending on settings. And material doesn't have the cite modals.

image

Pre-set colours and fonts

I've created a doc to describe how to amend the fonts and colours, they are kept in src/core/text_formats.py for easy editing. Also see note about custom colours above.

image image

Toggles

I've copied the Italics toggle from the previous dyslexia mode, and added one for dark mode which swaps the foreground and background of the current text colours, and one for the draw attention highlighting which is a way to suppress the animation on using an internal page link that briefly draws attention by highlighting the landing element.

@StephDriver
StephDriver force-pushed the b-5337-a11y-user-text-format branch from 2f8f1c2 to 00fce79 Compare July 10, 2026 15:58
@StephDriver StephDriver assigned mauromsl and unassigned StephDriver Jul 10, 2026
@StephDriver
StephDriver marked this pull request as ready for review July 10, 2026 16:38
@ajrbyers
ajrbyers self-requested a review July 15, 2026 11:09
@ajrbyers ajrbyers assigned ajrbyers and unassigned mauromsl Jul 15, 2026

@ajrbyers ajrbyers left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I've added a couple of inline comments but generally:

  • The bar should remain in its original place as with OLH on all four themes, it feels awkward at the top of the page


1. Put the font files in `src/static/common/fonts/<family>/` (`.woff2`/`.woff`
preferred; `.otf`/`.ttf` work too). Include the font's licence file.
2. Add an `@font-face` block to `src/static/common/css/text_readability.css`:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Does this file exist?

Comment thread src/core/logic.py
# the single source of truth shared with the bar template and the JS. Server-side
# validation means a stale or tampered stored value can never lodge an
# unresolvable preference (the same guarantee the JS rollback gives live).
_HEX_COLOUR_RE = re.compile(r"^#[0-9a-fA-F]{6}$")

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

No need to redefine this here as we can get it from the already imported text_format

// Keep the menu-button labels in step with the selection.
setLabelText('.tf-font-select', (FONTS[state.font] || FONTS['default']).label);
setLabelText('.tf-scheme-select', (COLOURS[state.scheme] || COLOURS['default']).label);
document.querySelectorAll('.tf-custom-colours').forEach(function (block) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Duplicated code here.

if (document.readyState === 'loading') {
document.addEventListener('DOMContentLoaded', initialise);
} else {
initialise();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Do we need to eager call initialise here if we're calling it on demand below?

add marker class `.text-format-region` to define the target parent(s).
{% endcomment %}
<section aria-label="{% trans 'Reading options' %}" class="invisible-landmark reading-options-landmark">
<div id="tf-bar" data-sticky-container class="row reading-options-bar{% if text_format_preferences.hideReadingBar %} tf-bar-hidden{% endif %}">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

data-sticky is on two divs here.

@ajrbyers ajrbyers assigned StephDriver and unassigned ajrbyers Jul 15, 2026
@StephDriver

StephDriver commented Jul 16, 2026

Copy link
Copy Markdown
Member Author

The bar should remain in its original place as with OLH on all four themes, it feels awkward at the top of the page

@ajrbyers I disagree. I tried placing the bar where it was on OLH originally - but it means this was then confusing as it cannot be universally added to non-article pages and the majority do not have banner images. Placing it in different places on different pages felt clunky and meant different CSS was needed in different places. Placing it at the top of the page is the only 'universal' position I could find that worked across other templates, e.g. news and CMS pages. And then I made it sticky so once you scroll down past the banner image it will appear at top of window anyway.

@ajrbyers

Copy link
Copy Markdown
Member

The bar should remain in its original place as with OLH on all four themes, it feels awkward at the top of the page

@ajrbyers I disagree. I tried placing the bar where it was on OLH originally - but it means this was then confusing as it cannot be universally added to non-article pages and the majority do not have banner images. Placing it in different places on different pages felt clunky and meant different CSS was needed in different places. Placing it at the top of the page is the only 'universal' position I could find that worked across other templates, e.g. news and CMS pages. And then I made it sticky so once you scroll down past the banner image it will appear at top of window anyway.

Ah right I was thinking about it specifically from the article POV. I'll take another look this morning.

@StephDriver

Copy link
Copy Markdown
Member Author

@ajrbyers I've added a commit which sets the default to hide the reading options bar. It is then found in the accessibility menu. I hope that is a good compromise to get this out the door.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Extend dyslexia mode to more reading text format options

3 participants