Browse Source

[overlay] add overlay

mightyplow 6 years ago
parent
commit
e1a575fba1
2 changed files with 40 additions and 0 deletions
  1. 19 0
      src/overlay/Overlay.jsx
  2. 21 0
      src/overlay/overlay.css

+ 19 - 0
src/overlay/Overlay.jsx

@@ -0,0 +1,19 @@
+import style from './overlay.css';
+
+function preventPropagation (event) {
+    event.stopPropagation();
+}
+
+function Overlay ({onBackgroundClick}, children) {
+    return (
+        <div className={style.overlay} onclick={onBackgroundClick}>
+            <div className={style.contentWrapper} onclick={preventPropagation}>
+                {children}
+            </div>
+        </div>
+    )
+}
+
+export {
+    Overlay
+}

+ 21 - 0
src/overlay/overlay.css

@@ -0,0 +1,21 @@
+.overlay {
+    background: rgba(0, 0, 0, 0.4);
+    display: flex;
+    position: fixed;
+    top: 0;
+    right: 0;
+    bottom: 0;
+    left: 0;
+}
+
+.contentWrapper {
+    position: relative;
+    display: flex;
+    max-width: 80vw;
+    max-height: 80vh;
+    margin: auto;
+    padding: 1em;
+    color: initial;
+    background: #FFF;
+    box-shadow: 0 0 4px #666;
+}