1
0
Fork 0
mirror of https://github.com/betagouv/mon-entreprise synced 2025-02-09 01:45:03 +00:00
mon-entreprise/source/components/Overlay.js
2018-10-03 14:58:18 +00:00

38 lines
909 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import FocusTrap from 'focus-trap-react'
import React, { Component } from 'react'
import * as animate from 'Ui/animate'
import { LinkButton } from 'Ui/Button'
import './Overlay.css'
export default class Overlay extends Component {
render() {
const { onClose, children, ...otherProps } = this.props
return (
<div id="overlayWrapper" onClick={onClose}>
<animate.fromBottom>
<FocusTrap
focusTrapOptions={{
onDeactivate: onClose,
clickOutsideDeactivates: true
}}>
<div
aria-modal="true"
id="overlayContent"
{...otherProps}
onClick={e => {
e.preventDefault()
e.stopPropagation()
}}>
{children}
<LinkButton
aria-label="close"
onClick={onClose}
id="overlayCloseButton">
×
</LinkButton>
</div>
</FocusTrap>
</animate.fromBottom>
</div>
)
}
}