Skip to content
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

refactor: Misc accessibility improvements #1124

Merged
merged 9 commits into from
May 7, 2024

Conversation

rschristian
Copy link
Member

Been trying to learn more accessibility stuff, figured I'd start here.

@rschristian rschristian changed the title Refactor/logo accessibility reafactor: Logo component accessibility Apr 27, 2024
Comment on lines -87 to +86
class="logo"
aria-label={title}
Copy link
Member Author

Choose a reason for hiding this comment

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

.logo isn't used.

As for aria-label, it replaces a spread title prop (<svg title="...") which does nothing to my knowledge, and is used instead of <title> for two reasons:

  1. On hover, most browsers will show the content of <title> as a tooltip. We don't really need or want this in the places we use this component.
  2. FireFox's accessibility tools show that <title> does not count as heading text in the scenario of <h1><svg><title>..., while aria-label does. This is important as we use this structure on our home page, where the main heading has no text in it, just our logo. With <title>, that heading is completely empty.

Comment on lines -197 to +202
if (to.href == '/' || to.path == '/') {
e.preventDefault();
location.route('/branding');
}
e.preventDefault();
location.route('/branding');
}
const homeProps = to.href == '/' || to.path == '/'
? { onContextMenu: BrandingRedirect, 'aria-label': 'Home' }
: {};
Copy link
Member Author

Choose a reason for hiding this comment

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

Better to only attach the handler to the one route it's used, and the 'aria-label': 'Home' I think is more useful of a description, even if users are probably familiar with the concept that brand/sitename == "home"

@rschristian rschristian marked this pull request as draft April 27, 2024 04:05
@rschristian rschristian changed the title reafactor: Logo component accessibility refactor: Misc accessibility improvements Apr 27, 2024
<nav tabIndex={0} onFocus={this.open}>
<nav onFocus={this.open}>
Copy link
Member Author

@rschristian rschristian Apr 27, 2024

Choose a reason for hiding this comment

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

There's no real reason a user would need to tab onto the nav container, there's nothing for them to do there. They can still tab onto the links within the container though.

<nav
tabIndex={0}
class={cx(style.toc, !(items && items.length > 1) && style.disabled)}
>
<nav class={cx(style.toc, !(items && items.length > 1) && style.disabled)}>
Copy link
Member Author

Choose a reason for hiding this comment

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

Same here, tabbing onto the side bar has no use.

@@ -1,27 +0,0 @@
import marked from 'marked';
Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry, unrelated, but long unused.

? [<a href={'#' + props.id} />, props.children]
? [
<a href={'#' + props.id}>
<svg width="16" height="16" viewBox="0 0 24 24" aria-label={`Link to: ${props.children} (#${props.id})`}>
Copy link
Member Author

@rschristian rschristian Apr 27, 2024

Choose a reason for hiding this comment

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

This implementation (e.g., Link to: Setting up JSX (#setting-up-jsx)) came from Vue's docs which I quite like, makes it quite clear why there's a link right alongside the heading content.

@rschristian rschristian force-pushed the refactor/logo-accessibility branch 5 times, most recently from ecc50f2 to 4b65af0 Compare May 7, 2024 17:08
color: #4b5363;
color: #8b93a3;
Copy link
Member Author

Choose a reason for hiding this comment

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

Was failing contrast checks

@rschristian rschristian marked this pull request as ready for review May 7, 2024 18:00
Copy link
Member

@marvinhagemeister marvinhagemeister left a comment

Choose a reason for hiding this comment

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

Good stuff 👍

@rschristian rschristian merged commit 01aeda8 into master May 7, 2024
5 checks passed
@rschristian rschristian deleted the refactor/logo-accessibility branch May 7, 2024 19:25
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.

None yet

2 participants