Skip to content

Add React button component and use for settings button - #1972

Merged
jamesmisson merged 16 commits into
UniversalViewer:UIfrom
jamesmisson:button-component
Nov 23, 2026
Merged

jamesmisson merged 16 commits into
UniversalViewer:UIfrom
jamesmisson:button-component

Conversation

@jamesmisson

Copy link
Copy Markdown
Contributor

Pull request description

Summary of changes

This adds a new React base component Button intended to be used for all the buttons in UV. It also makes a new container React component for the buttons in the top right options (HeaderPanelRightOptions), and implements the new component for the settings button to test it. The PR also contains the beginnings of an SVG Icons file, currently only containing the settings icon.

The button component handles the tooltip, getting the label from the relevant UV module content, passed to the button component as a prop. The placement of the tooltip is determined by the tooltipPlacement prop (bottom, top, left, or right; default is bottom). If the tooltip risks going off the edge of UV (e.g. with this settings example, in the top right corner), the tooltipAlignment prop can be set to start, center, or end (default is center) to keep it aligned with either side of the button itself.

The button and the tooltip are built to conform to WCAG 2.2 specifications:

1.4.13 Content on Hover or Focus (AA)

  • Dismissible: Pressing escape hides the tooltip without moving the pointer or focus.
  • Hoverable: the tooltip sits inside the button and an invisible bridge built with css spans the gap, so the pointer can move onto the tooltip without it closing.
  • Persistent: stays visible until hover/focus ends, the user dismisses it, or the button is pressed.

4.1.2 Name, Role, Value (A)

  • Native <button type="button"> with an aria-label.
  • The tooltip is aria-hidden, so screen readers don't read the label twice.

2.5.3 Label in Name (A)

  • Tooltip text is always the same as the accessible name.

2.1.1 Keyboard (A)

  • Tooltips show on keyboard focus (:focus-visible) as well as on hover.

2.4.7 Focus Visible (AA)

  • Focus ring is on the SVG icons with :focus-visible.

1.1.1 Non-text Content (A)

  • SVG icons are aria-hidden and focusable="false". The button's aria-label provides the text alternative.

2.3.3 Animation from Interactions (AAA)

  • With prefers-reduced-motion: reduce, the slide in is removed.

Tooltips should only open on hover on devices that actually support hover (@media (hover: hover)).

In this PR, I've put the React root inside the rightOptions div to maintain keyboard navigation, but ultimately the rightOptions div will become the root for the HeaderPanelRightOptions component and the other buttons converted to React within that, for #1956

Related issues

UI sprint issue: #1805

Contributor checklist

Accessibility & internationalisation

  • Accessibility: Changes have been checked against WCAG 2.2 Level AA, with no known accessibility failures introduced.
  • Keyboard accessibility: All new or modified interactive elements can be operated using a keyboard, with appropriate focus management and visible focus indicators.
  • Internationalisation: Contextual language switching works correctly and all new or modified interface strings have translations available in English, Welsh, Polish, French and Swedish.

Compatibility & interoperability

  • IIIF compatibility: Changes have been tested against relevant IIIF Presentation and Image API resources, with no known regressions in supported functionality.
  • Extension compatibility: Changes have been checked for compatibility with existing Universal Viewer extensions and extension points.
  • Backwards compatibility: Changes do not unintentionally break existing public APIs, integrations or configuration options.
  • Browser & device compatibility: Changes have been tested across relevant supported browsers, devices and screen sizes, including responsive layouts.

Code quality & testing

  • Automated testing: Relevant automated tests have been added or updated, and existing applicable tests pass.
  • Regression testing: Existing functionality affected by the changes has been tested to ensure no unintended regressions.
  • Code quality: Changes follow the project's coding conventions, and relevant linting, formatting and type checks pass.
  • Performance: Changes have been reviewed for potential performance impacts, with no known significant regressions.
  • Security: Changes have been checked for potential security vulnerabilities, including unsafe handling of external data, URLs and user input.

Configuration & documentation

  • Configuration: New or modified configuration options have been added to the appropriate configuration files and documented in 'manual/CONFIG.md`.
    No new config added but I think we ultimately need a config option for tooltipsEnabled
  • Documentation: The repository README and any other affected documentation have been reviewed and updated where necessary.
  • User experience: Changes have been reviewed for usability, consistency with existing interface patterns and clarity of user interactions.

Additional notes for reviewers:

As noted above, I think we need a config option for tooltipsEnabled. Happy to add this to this PR, or save it for a separate one in the UI sprint.

I haven't been able to test this on a non-mobile touch screen.

@vercel

vercel Bot commented Nov 20, 2026

Copy link
Copy Markdown

@jamesmisson is attempting to deploy a commit to the Universal Viewer Team on Vercel.

A member of the Team first needs to authorize it.

@vercel

vercel Bot commented Nov 20, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
universalviewer Ready Ready Preview Nov 23, 2026 10:52am UTC

Request Review

@demiankatz demiankatz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @jamesmisson, this is off to a great start!

How do you plan for the new button components to interact with the mobile view? Since the settings button currently disappears in mobile, I wasn't able to see how it might behave. Perhaps it's worth doing the remaining buttons to get a more complete test case.

See below for a couple of additional comments:

@LanieOkorodudu LanieOkorodudu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks so much for all your work on this, @jamesmisson. Really appreciate it.
Just a couple of small things I noticed while testing. The Settings button looks a little smaller in this PR compared to Dev. I noticed the SVG path size is around 14.9 × 15. Would it be possible to make it slightly bigger, like in Dev? But if that's the standard size, then no worries at all.

I also noticed that the focus indicators for Zoom In, Zoom Out, Rotate and Adjust look a little different. I'm guessing these are still being worked on as part of this PR?

@jamesmisson

jamesmisson commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor Author

Thank you both for taking a look.

@demiankatz in the interests of getting this PR done before the end of the sprint, I've kicked those cans down the road. The mobile footer creates the buttons independently from the desktop header so I've opened a ticket to replace those much like the other components - #1974 . I've changed the tooltip styling but this is just a placeholder for now, I think we can work out a nicer overall design for button highlighting (#1975)

@LanieOkorodudu the settings icon is deliberately a little smaller, I hope this will look more coherent when the other new icon designs are in place, but we can always resize it if not.
The focus outlines for those controls will be fixed in #1957

@demiankatz demiankatz left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks, @jamesmisson -- the tooltip definitely looks better for now, and I'm happy to defer further changes to the issues you've created.

@jamesmisson
jamesmisson merged commit 95befc6 into UniversalViewer:UI Nov 23, 2026
4 of 5 checks passed

This branch was successfully deployed

1 active deployment
Preview – universalviewer — f9f510f8 Deployed Nov 23, 2026 by vercel[bot]
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.

3 participants