Skip to content

Instantly share code, notes, and snippets.

@yuschick
Last active November 9, 2017 11:25
Show Gist options
  • Save yuschick/13897ff62c4c5e87045f042ca1fe1f21 to your computer and use it in GitHub Desktop.
Save yuschick/13897ff62c4c5e87045f042ca1fe1f21 to your computer and use it in GitHub Desktop.
Accessible Web Apps with React, TypeScript & Ally.js
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