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

feat: Accessible project headings for Publications #6047

Merged

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented Apr 22, 2024

  • give each project a slug eg. galaxy-zoo or backyard-worlds-planet-9.
  • give each project heading an id and tabindex to make it linkable and accessible.
  • add an intersection observer, which sets the active navigation section for each project section (eg. Planet Hunters will set the active section to Space), when that project section is near the top of the viewport.
  • make sure that project sections are labelled.

Please request review from @zooniverse/frontend team or an individual member of that team.

Package

  • app-content-pages

Linked Issue and/or Talk Post

How to Review

Project headings have human-readable IDs, which should work as links. The intersection observer should make sure that the appropriate section is set in the sidebar, when you link directly to a project.

Screenshots are from Firefox but this should work in any standards-compliant browser. Labelled sections should show up as region landmarks in software that supports landmark navigation (eg. VoiceOver, JAWS, NVDA.) Alternatively, you can right-click on a section to inspect its accessible name and role in browser dev tools.

The rule for generating a project's URL slug is: convert to lowercase, remove all punctuation and replace spaces with a single -.

https://localhost:3000/about/publications#when-do-mountain-goats-shed-winter-coats
The publications page, with When Do Mountain Goats Shed Winter Coats focussed and 'medicine' highlighted in the page navigation menu.

https://localhost:3000/about/publications#galaxy-zoo
The publications page, with Galaxy Zoo at the top of the viewport and 'space' highlighted in the navigation.

https://localhost:3000/about/publications#backyard-worlds-planet-9
The publications page, linking directly to Backyard Worlds, as an example of a project with punctuation in its full title.

Checklist

PR Creator - Please cater the checklist to fit the review needed for your code changes.
PR Reviewer - Use the checklist during your review. Each point should be checkmarked or discussed before PR approval.

General

  • Tests are passing locally and on Github
  • Documentation is up to date and changelog has been updated if appropriate
  • You can yarn panic && yarn bootstrap or docker-compose up --build and FEM works as expected
  • FEM works in all major desktop browsers: Firefox, Chrome, Edge, Safari (Use Browserstack account as needed)
  • FEM works in a mobile browser

General UX

Example Staging Project: i-fancy-cats

  • All pages of a FEM project load: Home Page, Classify Page, and About Pages
  • Can submit a classification
  • Can sign-in and sign-out
  • The component is accessible

New Feature

  • The PR creator has listed user actions to use when testing the new feature
  • Unit tests are included for the new feature
  • A storybook story has been created or updated
    • Example of SlideTutorial component with docgen comments, and its story

@coveralls
Copy link

coveralls commented Apr 22, 2024

Coverage Status

coverage: 81.83% (-0.02%) from 81.848%
when pulling cb85b00 on eatyourgreens:publications-project-links
into 358967d on zooniverse:master.

@eatyourgreens eatyourgreens force-pushed the publications-project-links branch 2 times, most recently from b00860f to 0685fd1 Compare April 22, 2024 20:10
@eatyourgreens eatyourgreens changed the title feat: Make project headings linkable in Publications feat: Accessible project headings for Publications Apr 22, 2024
@eatyourgreens
Copy link
Contributor Author

If you want to test this with a screen reader, W3C has a handy guide to landmark navigation.

@eatyourgreens
Copy link
Contributor Author

The region landmark, on MDN, is also relevant to this PR.

@eatyourgreens
Copy link
Contributor Author

eatyourgreens commented Apr 23, 2024

This PR should also fix a minor bug in the live page, where the wrong category is shown if the current category heading is outside the top of the viewport eg. scrolling up from Physics to Space will show 'Physics' for Space projects.

Screenshot of the publications page, showing the Physics category in the sidebar for Space projects like Solar Stormwatch, Planet Four and Planet Hunters.

- give each project a slug eg. `galaxy-zoo` or `backyard-worlds-planet-9`.
- give each project heading an `id` and `tabindex` to make it linkable and accessible.
- add an intersection observer, which sets the active navigation section for each project section.
Copy link
Contributor

@goplayoutside3 goplayoutside3 left a comment

Choose a reason for hiding this comment

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

Looks good - thank you!

Comment on lines +34 to +40
.toLowerCase()
// replace any spaces with Z
.replace(/\s/g, 'Z')
// remove all punctuation and whitespace
.replace(/\W/g, '')
// replace any Zs with a single dash
.replace(/Z+/g, '-')
Copy link
Contributor

Choose a reason for hiding this comment

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

Why do the step with Z rather than .toLowerCase().replaceAll(' ', '-')?

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 was just for convenience. \W includes spaces, so I replaced spaces with a capital letter before stripping punctuation, then replace the capital letters with ‘-‘ after.

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 also wanted to avoid -- appearing in slugs eg. backyard-worlds--planet-9 and this was the first solution that came to mind.

@goplayoutside3 goplayoutside3 merged commit 48b1117 into zooniverse:master Apr 24, 2024
8 checks passed
@eatyourgreens eatyourgreens deleted the publications-project-links branch April 24, 2024 20:55
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