-
Notifications
You must be signed in to change notification settings - Fork 5
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
Conversation
…ced motion is preferred by user.
…for reduced motion setting.
.eslintrc.json
Outdated
@@ -6,6 +6,7 @@ | |||
"plugin:github/typescript" | |||
], | |||
"globals": { | |||
"CustomElementElement": "readonly" | |||
"CustomElementElement": "readonly", | |||
"module": true |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this 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
.
…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.
@jamieshark; If you pull the main branch into this pull request, you should see CI running the tests. |
There was a problem hiding this 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 |
There was a problem hiding this comment.
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.
…eslint config entry.
…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.
There was a problem hiding this 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?
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
New
(refereshed a couple times bc it happens fast ⏩ )
Testing
Unit tests
I added a unit test to confirm that having the
window.matchMedia
returningtrue
for reduced motion will set the delay to0
, but I wasn't sure how to mock thewindow
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 overridingglobal.window.matchMedia
but ran into an error saying I was "setting" a "getter".To manually test reduced motion