forked from cerner/terra-core
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[form-field] [form-input] Add accessibility hooks examples for terra-…
…form-field and terra-input (cerner#3697) * Add accessibility hooks examples for terra-form-field and terra-input * Use email label field and messages for more realistic examples * Update changelog * Add toggle error button for terra-form-input example, fix lint errors * Minor changelog update * Minor changelog update Co-authored-by: ns065186 <[email protected]>
- Loading branch information
1 parent
6432309
commit 9fbbdb8
Showing
4 changed files
with
42 additions
and
0 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
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
27 changes: 27 additions & 0 deletions
27
...es/terra-core-docs/src/terra-dev-site/doc/form-input/common/AccessibilityHooksExample.jsx
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React, { useState } from 'react'; | ||
import Input from 'terra-form-input'; | ||
|
||
const AccessibilityHooksExample = () => { | ||
const [isInvalid, setIsInvalid] = useState(false); | ||
const toggleErrorState = () => { | ||
setIsInvalid(!isInvalid); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<label htmlFor="input_id"> E-mail Label</label> | ||
<Input name="accessible input" id="input_id" aria-describedby="input_id-error input_id-help" ariaLabel="Blank" /> | ||
{(isInvalid) && ( | ||
<p id="input_id-error"> | ||
<font color="red"> | ||
The e-mail address entered is invalid. | ||
</font> | ||
</p> | ||
)} | ||
<p id="input_id-help">Please enter a valid e-mail address.</p> | ||
<button type="button" id="toggle-is-invalid" onClick={toggleErrorState}>Toggle Error State</button> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AccessibilityHooksExample; |