Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2162 from uswds/al-component-audit-fixes-2
USWDS-Site: Fix component pages from audit (Phase 2)
- Loading branch information
Showing
32 changed files
with
117 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
- **Use proper labels and attributes.** Each file input should have a `<label>`. Associate the two by matching the `<label>`’s for attribute to the `<input>`’s `id` attribute. | ||
- **Use as a progressive enhancement.** The file input component should be a progressive enhancement of `<input type="file" />`. If the component doesn't initialize, it should still work and appear like a standard `file` input. | ||
- **Use proper labels and attributes.** Each file input should have a `label` element. Associate the label to your input by defining the value of the label’s `for` attribute with the input’s `id`. | ||
- **Use as a progressive enhancement.** The file input component should be a progressive enhancement of `<input type="file" />`. If the component doesn't initialize, it should still work and appear like a standard `file` input. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- **Initialization properties.** JavaScript will create most elements for file input. To get a file input to initialize, add the class name `usa-file-input` to `<input type="file" />`. | ||
- **Interaction.** When a user selects or drags documents to the file input, the file name and a thumbnail preview are listed. | ||
- **Using the `accept` attribute.** You can allow certain files by placing an accept attribute on the `<input/>`. If a file type is not accepted, the file will not be attached and the file input will display a message. [Learn more about the accept attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) [mozilla.org]. | ||
- **Internet Explorer/Edge.** These browsers do not support dragging items to a file input. Instructions to drag files are removed for these browsers. | ||
- **Limit accepted file types with the `accept` attribute.** Add the `accept` attribute to the `input` element when you want to limit the types of files your input can accept. If a user selects a file that does not match the specified type, the file will not be attached and the file input will display an error message. [Learn more about the accept attribute](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/file#accept) [mozilla.org]. | ||
- **Internet Explorer and older versions of Edge.** These browsers do not support dragging items to a file input. Instructions to drag files are removed for these browsers. | ||
- **Customizing the error message.** Add the data attribute `data-errorMessage` to `usa-file-input` to include a custom error message. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
- **Allow multiple file formats.** Not everyone has access to the same software. Be flexible with file types to avoid unnecessary software requirements. | ||
- **Prefer one file per input.** Some users might not know how to select multiple files in a file browser. Additionally, iOS does not allow multiple-file selection using the Files app. | ||
- **Highlight input restrictions.** Use `usa-hint` to be clear about any file restrictions, such as document types or file size. | ||
- **Prefer one file per input.** Some users might not know how to select multiple files in a file browser. | ||
- **Use hint text to highlight input restrictions.** Create an element with the `usa-hint` class to explain any file restrictions, such as document types or file size. |
4 changes: 2 additions & 2 deletions
4
_components/file-input/guidance/when-to-consider-something-else.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
- **Documents are optional.** Avoid asking users to provide documents if you don't require them. | ||
- **Asynchronous upload.** The file input component doesn't support asynchronous uploading. Files are POSTed only on form submission. | ||
- **Asking for large files.** Be mindful that some users might have limited connectivity or data plans. | ||
- **Asynchronous upload.** The file input component doesn't support asynchronous uploading. Files will `POST` only on form submission. | ||
- **Asking for large files.** Be mindful that some users might have limited connectivity or data plans. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,23 @@ | ||
- **Hide decorative icons from screen readers.** Use the `aria-hidden="true"` and `role="img"` attributes if the icon is redundant and used solely as visual progressive enhancement as in the following code: | ||
```html | ||
<a href="https://twitter.com/uswds"> | ||
<svg class="usa-icon" aria-hidden="true" role="img"> | ||
<use xlink:href="/assets/img/sprite.svg#arrow_forward"></use> | ||
</svg> | ||
USWDS' Twitter account | ||
</a> | ||
``` | ||
|
||
```html | ||
<a href="https://twitter.com/uswds"> | ||
<svg class="usa-icon" aria-hidden="true" role="img"> | ||
<use xlink:href="/assets/img/sprite.svg#arrow_forward"></use> | ||
</svg> | ||
USWDS' Twitter account | ||
</a> | ||
``` | ||
|
||
- **Provide descriptive text if a standalone icon has semantic meaning.** If you need to expose an icon to screen readers, remove the `aria-hidden="true"` attribute and add an `aria-labelledby` attribute with a value that matches the `id` of a `<title>` element added inside the SVG as in the following code: | ||
```html | ||
<a href="https://twitter.com/uswds"> | ||
<svg aria-labelledby="twitter-title" role="img"> | ||
<title id="twitter-title">USWDS' Twitter account</title> | ||
<use xlink:href="/path/to/sprite.svg#twitter"></use> | ||
</svg> | ||
</a> | ||
``` | ||
|
||
```html | ||
<a href="https://twitter.com/uswds"> | ||
<svg aria-labelledby="twitter-title" role="img"> | ||
<title id="twitter-title">USWDS' Twitter account</title> | ||
<use xlink:href="/path/to/sprite.svg#twitter"></use> | ||
</svg> | ||
</a> | ||
``` | ||
- **Check for good color contrast.** Make sure that the icon has a minimum contrast ratio of 3:1 against its background. See [WCAG 2.1 Techniques: Ensuring that a contrast ratio of 3:1 is provided for icons](https://www.w3.org/WAI/WCAG21/Techniques/general/G207) for more information. | ||
- **Place icons inside links.** If icons accompany a text link, place the icon inside the link to prevent the screen reader from announcing the link twice. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- **Use the identifier component for required links.** If your site already includes the federally required links in its site footer, remove them in favor of the links in the identifier. This assures that site visitors find the required links in a consistent location from site to site. | ||
- **Display the parent agency logo, not the product logo.** The identifier is meant to identify a website's parent agency as a complement to the site footer. Site-specific logos, like a product logo, should be in the site footer, not the identifier. | ||
- **Display multiple parents and logos in hierarchical order.** If a site has more than one parent agency, you may display a reference and a logo for each parent in hierarchical order, highest first. For example,"An official website of [Grandparent Department] and [Parent Agency]". | ||
- **Display multiple parents and logos in hierarchical order.** If a site has more than one parent agency, you may display a reference and a logo for each parent in hierarchical order, highest first. For example, "An official website of [Grandparent Department] and [Parent Agency]". | ||
- **Avoid distraction.** The identifier appears on every page of your site. Choose background colors that fit with your site theme and avoid color combinations that draw excessive attention to the identifier. | ||
- **Keep the text up-to-date.** Use the most current version of the identifier. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
- **Placement.** Place the `.usa-input-prefix` before `.usa-input` and `.usa-input-suffix` after the `.usa-input`. Both elements are placed inside `.usa-input-group`. | ||
- **Placement matters.** Place the `.usa-input-prefix` element _before_ the `.usa-input` element, and place the `.usa-input-suffix` element _after_ `.usa-input`. Both elements should be placed inside `.usa-input-group`. | ||
|
||
- **Use text or icons.** Input prefixes and suffixes can accept either plain text or [icons]({{ site.baseurl }}/components/icon/). | ||
|
||
- **Validation.** Place input validation classes on `usa-input-group`. | ||
- **Use validation styles.** Place [input validation classes](#component-variants-input-prefix-suffix) on `usa-input-group`. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.