🚧 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 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];
|
||||||
};
|
};
|
||||||
|
|
|
@ -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, []);
|
||||||
|
|
Loading…
Reference in a new issue