🚧 add background overlay to modals
This commit is contained in:
parent
8b9dd90ae3
commit
1680c0cd52
2 changed files with 18 additions and 5 deletions
|
@ -1,11 +1,24 @@
|
|||
import React from 'react';
|
||||
import styled from 'styled-components';
|
||||
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) => {
|
||||
const [visible, trigger, setRef] = useModalBehavior();
|
||||
export default (component, hasOverlay = false) => {
|
||||
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];
|
||||
};
|
||||
|
|
|
@ -99,7 +99,7 @@ const MobileIDEView = (props) => {
|
|||
const [toggleExplorer, Explorer] = useAsModal(<Sidebar
|
||||
title="hahaha"
|
||||
onPressClose={() => {}}
|
||||
/>);
|
||||
/>, true);
|
||||
|
||||
// toggle sidebar starting opened
|
||||
useEffect(toggleExplorer, []);
|
||||
|
|
Loading…
Reference in a new issue