🚧 add background overlay to modals

This commit is contained in:
ghalestrilo 2020-08-06 16:05:28 -03:00
parent 8b9dd90ae3
commit 1680c0cd52
2 changed files with 18 additions and 5 deletions

View file

@ -1,11 +1,24 @@
import React from 'react'; import React from 'react';
import styled from 'styled-components';
import { useModalBehavior } from '../utils/custom-hooks'; import { useModalBehavior } from '../utils/custom-hooks';
const BackgroundOverlay = styled.div`
position: absolute;
z-index: 2;
width: 100% !important;
height: 100% !important;
background: black;
opacity: 0.3;
`;
export default (component) => { export default (component, hasOverlay = false) => {
const [visible, trigger, setRef] = useModalBehavior(); const [visible, toggle, setRef] = useModalBehavior();
const wrapper = () => <div ref={setRef}> {visible && component} </div>; // eslint-disable-line const wrapper = () => (<div>
{hasOverlay && visible && <BackgroundOverlay />}
<div ref={setRef}> {visible && component} </div>
</div>); // eslint-disable-line
return [trigger, wrapper]; return [toggle, wrapper];
}; };

View file

@ -99,7 +99,7 @@ const MobileIDEView = (props) => {
const [toggleExplorer, Explorer] = useAsModal(<Sidebar const [toggleExplorer, Explorer] = useAsModal(<Sidebar
title="hahaha" title="hahaha"
onPressClose={() => {}} onPressClose={() => {}}
/>); />, true);
// toggle sidebar starting opened // toggle sidebar starting opened
useEffect(toggleExplorer, []); useEffect(toggleExplorer, []);