Skip to content

a11y reduced motion #1

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 9 commits into from
Jun 4, 2021
Merged

a11y reduced motion #1

merged 9 commits into from
Jun 4, 2021

Conversation

jamieshark
Copy link
Contributor

@jamieshark jamieshark commented May 27, 2021

This PR adds functionality to the <typing-effect> component to handle the case where a user has a reduced motion setting. This change was originally brought on to accommodate a reduced-motion version of the new sign up page, but I figure that anywhere else this component is being used, we'll probably want the same behavior rather than having to apply it to every instance.

If reduced motion is preferred, the lines will append immediately to the content rather than being typed out with the character and line delay.

Comparison

Current

join_next_animated

New

join_next_reduced
(refereshed a couple times bc it happens fast ⏩ )

Testing

Unit tests

I added a unit test to confirm that having the window.matchMedia returning true for reduced motion will set the delay to 0, but I wasn't sure how to mock the window object in karma here. @koddsson - do you have any ideas where we could mock this value to be set within the test? (without adding another library / dependency). I tried overriding global.window.matchMedia but ran into an error saying I was "setting" a "getter".

To manually test reduced motion

  1. Go to System Preferences -> Accessibility -> Display -> CHECK "Reduce Motion"
  2. Navigate to http://github.localhost/join_next
    • Confirm the stars in the background do not move
    • Confirm the welcome message renders immediately, instead of typing out

.eslintrc.json Outdated
@@ -6,6 +6,7 @@
"plugin:github/typescript"
],
"globals": {
"CustomElementElement": "readonly"
"CustomElementElement": "readonly",
"module": true
Copy link
Contributor Author

Choose a reason for hiding this comment

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

PS: also added this to prevent module.exports throwing a lint error

Copy link
Contributor

Choose a reason for hiding this comment

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

What lint error are you getting. When I remove this locally and run npm test I don't get any errors.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the error I get:
Screen Shot 2021-05-28 at 11 20 11 AM

@nholden nholden requested review from nholden and koddsson May 27, 2021 18:32
Copy link
Contributor

@nholden nholden left a comment

Choose a reason for hiding this comment

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

Thanks for this! It makes sense to me that the default behavior would be to show the content immediately for users who have enabled prefers-reduced-motion.

jamieshark and others added 2 commits May 27, 2021 14:01
…ribute will override the window media match. If data-reduced-motion is set to true, the component will NOT animate. If data-reduced-motion is set to false, the component WILL animate.
@koddsson
Copy link
Contributor

@jamieshark; If you pull the main branch into this pull request, you should see CI running the tests.

Copy link
Contributor

@koddsson koddsson left a comment

Choose a reason for hiding this comment

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

Overall this looks good to me.

I wouldn't give implementors the option to opt-out of the accessibility feature, and there are some minor whitespace and markdown changes unrelated to the PR feature, but I'm overall 👍🏻 on this change.

I want to make sure @nholden is approving before we merge, though, as his team are the primary users of this component.

.eslintrc.json Outdated
@@ -6,6 +6,7 @@
"plugin:github/typescript"
],
"globals": {
"CustomElementElement": "readonly"
"CustomElementElement": "readonly",
"module": true
Copy link
Contributor

Choose a reason for hiding this comment

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

What lint error are you getting. When I remove this locally and run npm test I don't get any errors.

…the test from setting delay to 0 when user has reduced motion set on their system). Removes code paths and mentions of attribute data-reduced-motion because including an escape hatch right now might be a bit confusing.
…ue check. Also adds a condition to skip the await call for lines if lineDelay is not 0.
Copy link
Contributor

@nholden nholden left a comment

Choose a reason for hiding this comment

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

This is 💯 . Thank you for all the back-and-forth, @jamieshark! 💖

@koddsson: what do you think about merging this now and waiting until #3 is merged to cut a new release?

@koddsson
Copy link
Contributor

koddsson commented Jun 4, 2021

@koddsson: what do you think about merging this now and waiting until #3 is merged to cut a new release?

Let's do it 🚀

@koddsson koddsson merged commit 7369d4f into github:main Jun 4, 2021
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