-
Notifications
You must be signed in to change notification settings - Fork 45
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
Adding a loading state on 'regio' page, and added some accessibility tweaks #4
Conversation
…is loaded, that way the content blocks don't jump around. Also added screenreader labels for the BarCharts, and added focus management when changing a region.
@@ -0,0 +1 @@ | |||
{ "singleQuote": 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.
Added prettier because VSCode wanted to add double quotes. This way we ensure everyone uses the single quotes. Didn't seem to change any other code formatting in the files I touched.
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.
We already provide a .prettierrc.js
file with our configuration. There's no need to add this file.
If anything, we could take a look at automatically formatting files with prettier when committing them to the repo with a pre-commit hook. Is this something you'd like to investigate?
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.
Is it than maybe possible that the .prettierrc.js
file is in the private repo but not in the public one, since I don't see it?
As soon as I have the right config I will also add the precommit format, good idea! 👍
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.
I have temporarily split this into a new issue: #7
In there you can hopefully help me find the prettier config, after which I or someone else can add it, together with the precommit hook.
background-color: $text-color-grey; | ||
animation: loadingPlaceholderPulse 1200ms infinite; | ||
display: block; | ||
height: 80px; |
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.
Would could make this height a prop / inline style later if we needed different sizes. For now this is specific for the BartCharts. (Usually I use Styled Components for things like this, so I'm not sure if you would want to add an inline style if we'd made this dynamic)
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.
For now this solution seems fine. I'd like to see 80px
changed to 5em
or 5rem
depending on the parent font-size settings.
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.
Fixed and created a new PR for only this change: #6
@@ -0,0 +1,28 @@ | |||
const curlyBracketRegex = /\{\{(.+?)\}\}/g; | |||
|
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.
Added a very small utility to replace variables inside curly brackets. As far as I could see there wasn't anything in place for this yet? Tried to keep is as simple as possible for now.
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.
It would be great if we can add some tests in Jest for utilities like these. A few basic assertions about input and expected output should be enough.
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.
Created a todo in the new PR #8 which now contains the screenreader descriptions.
Will work on these unit tests ASAP.
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 helping out! We really appreciate it.
I left a few questions and comments as a review.
Besides those questions, could I ask you to split up the concerns in different PR's so we can perform our approvals/disapprovals on a more granular level? It would be a shame if we have to block a PR on minor disagreements on a small feature.
{/* | ||
An optional ref and the tabIndex makes it focussable via JS, | ||
this is used on the region page to focus the first graph header | ||
after the region is changed. | ||
*/} | ||
<h3 ref={headingRef} tabIndex={headingRef ? 0 : undefined}> | ||
{title} | ||
{regio && <ScreenReaderOnly>in {regio}</ScreenReaderOnly>} | ||
</h3> |
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 is the default behavior without these changes? The focus stays on the last clicked anchor element right? Why is that bad?
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.
Move to #9 and answered there.
@@ -0,0 +1,11 @@ | |||
import styles from './loadingPlaceholder.module.scss'; | |||
|
|||
import * as React from 'react'; |
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.
You don't need to import React in Next.js projects
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.
Mind is blown. I work quite extensively with NextJS and have never known this 😄 It is fixed in the new PR.
@@ -0,0 +1,28 @@ | |||
const curlyBracketRegex = /\{\{(.+?)\}\}/g; | |||
|
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.
It would be great if we can add some tests in Jest for utilities like these. A few basic assertions about input and expected output should be enough.
/** | ||
* Focuses the first heading in the content column, | ||
* used after region changes to move focus for visually impaired | ||
* users so they know what has changed. | ||
*/ | ||
const focusFirstHeading = () => { | ||
try { | ||
if (contentRef.current) contentRef.current.focus(); | ||
} catch {} | ||
}; |
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.
Why are you adding a try/catch without a catch?
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.
Move to #9 and answered there.
Thanks for taking the time to review this! |
@VWSCoronaDashboard I have created new PR's ( #6 , #7 , #8 and #9 ), and will leave it up to you to close this issue as soon as you have read my replies. |
Hi there!
I really like to work that is being done on the dashboard. I took some time today to improve a few things I noticed, which because of the short timeline might not have made it into the first version yet. Let me know if you would like to merge these changes or have some feedback. I'd love to help, also with any other more pressing issues.
This PR has been split into #6 , #7 , #8 and #9 and will probably be closed.
The changes I made:1. Added a small simple skeleton loading state for the graphs on the region page. That way the container doesn't jump around when the data is loaded.2. Added screen reader only labels describing what the BarCharts show, for visually impaired users. (The content might need to be checked though).
3. Extended the graph titles on the region page with a (only for screen readers visible) text repeating the region this data is for.
4. Added some focus management which after selecting a region moves the focus to the heading of the first graph, so a user immediately can read the related data.
5. Added a screen reader only button at the end of the content bringing the user back to the region selector. This way a visually impaired user can switch easier between regions multiple times.