Last active
November 9, 2017 11:25
-
-
Save yuschick/13897ff62c4c5e87045f042ca1fe1f21 to your computer and use it in GitHub Desktop.
Accessible Web Apps with React, TypeScript & Ally.js
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
interface Props { | |
children: object; | |
title: string; | |
description: string; | |
close(): void; | |
} | |
class Dialog extends React.Component<Props> { | |
dialog: HTMLElement | null; | |
render() { | |
return ( | |
<div | |
role="dialog" | |
tabIndex={0} | |
className="popup-outer-container" | |
aria-hidden={false} | |
aria-labelledby="dialog-title" | |
aria-describedby="dialog-description" | |
ref={(popup) => { | |
this.dialog = popup; | |
} | |
} | |
> | |
<h5 | |
id="dialog-title" | |
className="is-visually-hidden" | |
> | |
{this.props.title} | |
</h5> | |
<p | |
id="dialog-description" | |
className="is-visually-hidden" | |
> | |
{this.props.description} | |
</p> | |
<div className="popup-inner-container"> | |
<button | |
className="close-icon" | |
tabIndex={0} | |
type="button" | |
title="Close Dialog" | |
onClick={() => { | |
this.props.close(); | |
}} | |
> | |
× | |
</button> | |
{this.props.children} | |
</div> | |
</div> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment