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

Adding a loading state on 'regio' page, and added some accessibility tweaks #4

Closed
wants to merge 1 commit into from

Conversation

JeroenReumkens
Copy link
Contributor

@JeroenReumkens JeroenReumkens commented Jun 7, 2020

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.

…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.
@CLAassistant
Copy link

CLAassistant commented Jun 7, 2020

CLA assistant check
All committers have signed the CLA.

@@ -0,0 +1 @@
{ "singleQuote": 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.

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.

Copy link
Contributor

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?

Copy link
Contributor Author

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! 👍

Copy link
Contributor Author

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;
Copy link
Contributor Author

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)

Copy link
Contributor

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.

Copy link
Contributor Author

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;

Copy link
Contributor Author

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.

Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

@VWSCoronaDashboard VWSCoronaDashboard left a comment

Choose a reason for hiding this comment

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

Hi @JeroenReumkens

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.

Comment on lines +13 to +21
{/*
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>
Copy link
Contributor

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?

Copy link
Contributor Author

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';
Copy link
Contributor

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

Copy link
Contributor Author

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;

Copy link
Contributor

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.

Comment on lines +61 to +70
/**
* 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 {}
};
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@JeroenReumkens
Copy link
Contributor Author

Hi @JeroenReumkens

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.

Thanks for taking the time to review this!
I indeed got a bit carried away with multiple changes in 1 brach. Gonna try to create separate branches now and make PRs of these. I'll try to take in any changes based on the comments you made here, in those branches too.

@JeroenReumkens JeroenReumkens changed the title Adding a loading state on 'regio' page, and added some accessibility tweaks [WIP] Adding a loading state on 'regio' page, and added some accessibility tweaks Jun 10, 2020
@JeroenReumkens
Copy link
Contributor Author

JeroenReumkens commented Jun 10, 2020

@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.

@JeroenReumkens JeroenReumkens changed the title [WIP] Adding a loading state on 'regio' page, and added some accessibility tweaks Adding a loading state on 'regio' page, and added some accessibility tweaks Jun 10, 2020
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

3 participants