-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Add alt tags to images for a11y #529
Conversation
👋@yangshun let me know if I should make any edits! |
3f03bb5
to
be360a1
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.
Thanks for doing this!
Also, do any CSS updates in main.css
need to be done for this? In the gridBlock.blockImage
section, for example. Maybe not, but just making sure.
docs/api-pages.md
Outdated
@@ -64,6 +64,7 @@ The `contents` attribute is an array containing the contents of each section of | |||
- `imageAlign` field for image alignment relative to the text, which defaults to `top` and can be set to `bottom`, `left`, or `right` | |||
- `title` for the title to display for this section, which is parsed from markdown | |||
- `imageLink` for a link destination from clicking the image | |||
- `imageAlt` provides an alt tag for an image for a11y |
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.
maybe
imageAlt
for the description of what text will be shown in case the image is not available
instead?
if (image) { | ||
if (imageLink) { | ||
return ( | ||
<div className="blockImage"> | ||
<a href={imageLink}> | ||
<img src={image} /> | ||
<img src={image} alt={imageAlt} /> |
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.
maybe we do a check here in case imageAlt
isn't provided?
like
<img src={image} alt={imageAlt ? imageAlt : ''}
or something like that?
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 think it's fine as-is because React does not render any props that are undefined
or null
.
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.
👍 Yeah I didn't add the check, because without an imageAlt
, the alt
didn't show up on inspection in the browser. Thanks @yangshun for explaining why!
</a> | ||
</div> | ||
); | ||
} else { | ||
return ( | ||
<div className="blockImage"> | ||
<img src={image} /> | ||
<img src={image} alt={imageAlt} /> |
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.
Same here
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.
From #529 (comment), leave as-is.
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.
Great work @amyrlam ! LGTM once the comments are responded to. Will leave it to @JoelMarcey to give the final approval and merging.
if (image) { | ||
if (imageLink) { | ||
return ( | ||
<div className="blockImage"> | ||
<a href={imageLink}> | ||
<img src={image} /> | ||
<img src={image} alt={imageAlt} /> |
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 think it's fine as-is because React does not render any props that are undefined
or null
.
@@ -5,7 +5,7 @@ authorURL: http://twitter.com/JoelMarcey | |||
authorFBID: 611217057 | |||
--- | |||
|
|||
![](/img/slash-introducing.png) | |||
![introducing Slash](/img/slash-introducing.png) |
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.
Nit - Title case - "Introducing Slash"
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. Sorry, had done that intentionally thinking it was the alt
standard. I changed some other ones too to Title Case.
@@ -24,7 +24,7 @@ Docusaurus also provides core website and documentation features out-of-the-box | |||
|
|||
## The Birth of docusaurus | |||
|
|||
![](/img/slash-birth.png) | |||
![birth of Slash](/img/slash-birth.png) |
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.
Nit - Title case
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
website/pages/en/about-slash.js
Outdated
<p> | ||
Slash is the official mascot of Docusaurus. You will find different variations of her throughout the <a href="https://docusaurus.io">website</a>, whether she is moving fast on her scooter or writing documentation at her standing desk. At Facebook, we have actual Slash plushies -- and you never know, you may see these plushies at various events and conferences in the future. | ||
</p> | ||
</Container> | ||
<Container className="mainContainer"> | ||
<h2>Birth of Slash</h2> | ||
<img src={`${siteConfig.baseUrl}img/slash-birth.png`} /> | ||
<img src={`${siteConfig.baseUrl}img/slash-birth.png`} alt="birth of Slash"/> |
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.
Nit - Title case
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
d437fd9
to
038e6fa
Compare
- Add imageAlt to GridBlock - Set alt equal to `user.caption` for mapped users - Set alt equal to `post.author` for blog posts - Update documentation
038e6fa
to
e0c2991
Compare
Made edits and squashed them in, wondering if you prefer squashing or a separate commit? I don't think any CSS changes are needed for the Let me know if other edits needed and thanks for the feedback @JoelMarcey @yangshun! |
Both ways are fine Feel free to leave it in non-squashed mode. The project
maintainers have a squash option on GitHub when they merge the PR. So it's
not an issue if your PR branch has many commits (:
…On Sat, Apr 7, 2018, 2:09 PM Amy Lam ***@***.***> wrote:
Made edits and squashed them in, wondering if you prefer squashing or a
separate commit?
I don't think any CSS changes are needed for the alt tag, since it's for
if the images cannot be displayed.
Let me know if other edits needed and thanks for the feedback @JoelMarcey
<https://github.com/JoelMarcey> @yangshun <https://github.com/yangshun>!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#529 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ABQRHQWZX52KeFuwq6WId6Ep9N7czTI0ks5tmSsUgaJpZM4TJjjv>
.
|
Thanks - good to know about the squash option for next time! |
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.
Let's ship it!
Motivation
Have you read the Contributing Guidelines on pull requests?
yes
Test Plan
Ran
pa11y http://localhost:3000/
and confirmed no results forError: Img element missing an alt attribute. Use the alt attribute to specify a short text alternative
from the original gist.Related PRs
N/A
Details
user.caption
for mapped userspost.author
for blog posts