forked from marcysutton/js-a11y-workshop
-
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.
- Loading branch information
Marcy Sutton
committed
Jul 25, 2019
1 parent
ba7230a
commit e2f97ce
Showing
10 changed files
with
132 additions
and
35 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import React from "react" | ||
|
||
const LiveRegion = ({ message, level = 'polite'}) => { | ||
return ( | ||
<div aria-live={level} role="log" className="visually-hidden"> | ||
{message ? message : ''} | ||
</div> | ||
) | ||
} | ||
export default LiveRegion |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,66 @@ | ||
import React, {useState} from "react" | ||
|
||
import Layout from '../components/site-chrome/layout' | ||
import SEO from '../components/site-chrome/seo' | ||
|
||
import LiveRegion from "../components/good/live-region" | ||
import {DebounceInput} from 'react-debounce-input' | ||
|
||
const Textarea = ({handleUpdateFunc}) => ( | ||
<DebounceInput | ||
minLength={2} | ||
debounceTimeout={300} | ||
forceNotifyByEnter={false} | ||
element="textarea" | ||
onChange={event => handleUpdateFunc(event.target.value)} /> | ||
) | ||
|
||
const LiveRegionDemoPage = () => { | ||
const [message, setMessage] = useState(null) | ||
const [updating, setUpdating] = useState(false) | ||
|
||
const handleSubmit = (event) => { | ||
event.preventDefault() | ||
} | ||
const handleTextChange = (value) => { | ||
console.log(value) | ||
// setMessage(value) | ||
setUpdating(true) | ||
// setMessage('saved!') | ||
|
||
} | ||
const dismissToast = () => { | ||
setUpdating(false) | ||
} | ||
return ( | ||
<Layout> | ||
<SEO title="Live Regions" keywords={['javascript', 'accessibility', 'react']} /> | ||
<div> | ||
<h2>Live Region Demo</h2> | ||
<form onSubmit={handleSubmit}> | ||
<label> | ||
Enter text here<br /> | ||
<Textarea handleUpdateFunc={handleTextChange} /> | ||
</label> | ||
<div className="updateUI"> | ||
<div className={`toast ${updating ? 'updating' : null}`}> | ||
<span>Form saved</span> | ||
<button | ||
onClick={dismissToast} | ||
className="dismiss" | ||
type="button" | ||
> | ||
X | ||
</button> | ||
</div> | ||
<LiveRegion level="polite" message={message} /> | ||
</div> | ||
</form> | ||
</div> | ||
</Layout> | ||
) | ||
} | ||
|
||
export default LiveRegionDemoPage | ||
|
||
|
This file was deleted.
Oops, something went wrong.
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