2020-07-30 17:30:45 +00:00
|
|
|
import React from 'react';
|
2020-08-06 19:05:28 +00:00
|
|
|
import styled from 'styled-components';
|
2020-07-30 17:30:45 +00:00
|
|
|
import { useModalBehavior } from '../utils/custom-hooks';
|
|
|
|
|
2020-08-06 19:05:28 +00:00
|
|
|
const BackgroundOverlay = styled.div`
|
|
|
|
position: absolute;
|
|
|
|
z-index: 2;
|
|
|
|
width: 100% !important;
|
|
|
|
height: 100% !important;
|
|
|
|
|
|
|
|
background: black;
|
|
|
|
opacity: 0.3;
|
|
|
|
`;
|
2020-08-06 18:59:22 +00:00
|
|
|
|
2020-08-06 19:24:47 +00:00
|
|
|
export default (Element, hasOverlay = false) => {
|
2020-08-06 19:05:28 +00:00
|
|
|
const [visible, toggle, setRef] = useModalBehavior();
|
2020-07-30 17:30:45 +00:00
|
|
|
|
2020-08-06 19:24:47 +00:00
|
|
|
// const Comp = styled(() => Element).attrs({ onPressClose: toggle });
|
|
|
|
|
|
|
|
const wrapper = () => (visible &&
|
|
|
|
<div>
|
|
|
|
{hasOverlay && <BackgroundOverlay />}
|
|
|
|
<div ref={setRef}> {Element} </div>
|
2020-08-07 14:24:25 +00:00
|
|
|
</div>);
|
2020-07-30 17:30:45 +00:00
|
|
|
|
2020-08-06 19:05:28 +00:00
|
|
|
return [toggle, wrapper];
|
2020-07-30 17:30:45 +00:00
|
|
|
};
|