-
Notifications
You must be signed in to change notification settings - Fork 30
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
feat: Accessible project headings for Publications #6047
Conversation
30f460b
to
7bcb033
Compare
b00860f
to
0685fd1
Compare
If you want to test this with a screen reader, W3C has a handy guide to landmark navigation. |
The region landmark, on MDN, is also relevant to this PR. |
0685fd1
to
11f611f
Compare
11f611f
to
116d5cb
Compare
- 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.
116d5cb
to
53cc859
Compare
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.
Looks good - thank you!
.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, '-') |
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 do the step with Z
rather than .toLowerCase().replaceAll(' ', '-')
?
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 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.
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 also wanted to avoid --
appearing in slugs eg. backyard-worlds--planet-9
and this was the first solution that came to mind.
galaxy-zoo
orbackyard-worlds-planet-9
.id
andtabindex
to make it linkable and accessible.Please request review from
@zooniverse/frontend
team or an individual member of that team.Package
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://private-user-images.githubusercontent.com/59547/324524316-23487275-a2e4-48bd-8038-927041855a68.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIwMTExMDgsIm5iZiI6MTcyMjAxMDgwOCwicGF0aCI6Ii81OTU0Ny8zMjQ1MjQzMTYtMjM0ODcyNzUtYTJlNC00OGJkLTgwMzgtOTI3MDQxODU1YTY4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI2VDE2MjAwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTA4N2ZmMDIwOGZlYzMyN2Q0NzY0ODkxZmI4ZWQ5OTc0ZjkwNmEzYmIwZjQ0ZjQwMDFlMTI1MzBkMGZlOTkxNDMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.kX1m1ulSUgp7DAexE4fxNHrXesRcJduWc1DIllDggSU)
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://private-user-images.githubusercontent.com/59547/324523982-7f8609e8-a0e8-4aaf-86a0-f3e68575d5b8.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIwMTExMDgsIm5iZiI6MTcyMjAxMDgwOCwicGF0aCI6Ii81OTU0Ny8zMjQ1MjM5ODItN2Y4NjA5ZTgtYTBlOC00YWFmLTg2YTAtZjNlNjg1NzVkNWI4LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI2VDE2MjAwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTFlNWIxMzgwNGNlOWE4YzNjNzRiNTA4NmU4MjNiZDkyNDQ3ZDc2MDkzYjkxY2Y1M2MxOWI2MzUyZjAzNmU1NzcmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.XaaegOKjd9TrLY0PvLjKiTan_5Y0a4BZ7Ls0koua7Vo)
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.](https://private-user-images.githubusercontent.com/59547/324527088-530c5ded-cca6-4fa4-88aa-05e4144e4a96.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIwMTExMDgsIm5iZiI6MTcyMjAxMDgwOCwicGF0aCI6Ii81OTU0Ny8zMjQ1MjcwODgtNTMwYzVkZWQtY2NhNi00ZmE0LTg4YWEtMDVlNDE0NGU0YTk2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA3MjYlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNzI2VDE2MjAwOFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTk4YzgxYWVjOTQ3MzdmZDBlZTgzYTQ5NjViMDg5OTZmMzEwZWZlZjIyZjJhNjhmNGFmZGZjZmFmZTA4ZWExY2YmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.dFM6OPts0fvACPtQG1kWc3nGurQBQ52vEYPRvYfWyBs)
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
yarn panic && yarn bootstrap
ordocker-compose up --build
and FEM works as expectedGeneral UX
Example Staging Project: i-fancy-cats
New Feature