Darken modal underlay and add actions above screen modal to allow entering full screen or closing

This commit is contained in:
Andrew Kingston 2021-08-03 12:02:20 +01:00
parent 062d7e4450
commit f095be6aac
2 changed files with 33 additions and 6 deletions

View File

@ -70,6 +70,7 @@
> >
<div class="modal-wrapper" on:mousedown|self={cancel}> <div class="modal-wrapper" on:mousedown|self={cancel}>
<div class="modal-inner-wrapper" on:mousedown|self={cancel}> <div class="modal-inner-wrapper" on:mousedown|self={cancel}>
<slot name="outside" />
<div <div
use:focusFirstInput use:focusFirstInput
class="spectrum-Modal is-open" class="spectrum-Modal is-open"
@ -93,6 +94,7 @@
z-index: 999; z-index: 999;
overflow: auto; overflow: auto;
overflow-x: hidden; overflow-x: hidden;
background: rgba(0, 0, 0, 0.75);
} }
.modal-wrapper { .modal-wrapper {
@ -112,6 +114,7 @@
justify-content: center; justify-content: center;
align-items: flex-start; align-items: flex-start;
width: 0; width: 0;
position: relative;
} }
.spectrum-Modal { .spectrum-Modal {

View File

@ -1,6 +1,11 @@
<script> <script>
import { peekStore, dataSourceStore, notificationStore } from "../store" import {
import { Modal, ModalContent, Button } from "@budibase/bbui" peekStore,
dataSourceStore,
notificationStore,
routeStore,
} from "../store"
import { Modal, ModalContent, ActionButton } from "@budibase/bbui"
import { onDestroy } from "svelte" import { onDestroy } from "svelte"
let iframe let iframe
@ -44,6 +49,11 @@
iframe.contentWindow.removeEventListener("notification", proxyNotification) iframe.contentWindow.removeEventListener("notification", proxyNotification)
} }
const handleFullscreen = () => {
routeStore.actions.navigate($peekStore.url)
handleCancel()
}
$: { $: {
if (iframe && !listenersAttached) { if (iframe && !listenersAttached) {
attachListeners() attachListeners()
@ -62,6 +72,14 @@
{#if $peekStore.showPeek} {#if $peekStore.showPeek}
<Modal fixed on:cancel={handleCancel}> <Modal fixed on:cancel={handleCancel}>
<div class="actions spectrum--darkest" slot="outside">
<ActionButton size="S" quiet icon="OpenIn" on:click={handleFullscreen}>
Full screen
</ActionButton>
<ActionButton size="S" quiet icon="Close" on:click={handleCancel}>
Close
</ActionButton>
</div>
<ModalContent <ModalContent
showCancelButton={false} showCancelButton={false}
showConfirmButton={false} showConfirmButton={false}
@ -80,13 +98,19 @@
border: none; border: none;
width: calc(100% + 80px); width: calc(100% + 80px);
height: 640px; height: 640px;
max-height: calc(100vh - 120px);
transition: width 1s ease, height 1s ease, top 1s ease, left 1s ease; transition: width 1s ease, height 1s ease, top 1s ease, left 1s ease;
border-radius: var(--spectrum-global-dimension-size-100); border-radius: var(--spectrum-global-dimension-size-100);
} }
@media (max-width: 600px) { .actions {
iframe { display: flex;
max-height: calc(100vh - 80px); flex-direction: row;
} justify-content: flex-end;
align-items: center;
position: absolute;
top: 0;
width: 640px;
max-width: 100%;
} }
</style> </style>