2018-03-04 01:31:00 +01:00
|
|
|
<div class="modal-dialog-backdrop {{fadedIn ? '' : 'hidden'}}"
|
|
|
|
tabindex="-1"
|
|
|
|
data-a11y-dialog-hide
|
|
|
|
></div>
|
2018-03-21 05:26:53 +01:00
|
|
|
<div class="modal-dialog-contents {{fadedIn ? '' : 'hidden'}} {{muted ? 'muted-style' : ''}}"
|
2018-03-04 01:31:00 +01:00
|
|
|
role="dialog"
|
|
|
|
aria-label="{{label}}"
|
|
|
|
ref:node
|
|
|
|
>
|
2018-02-05 04:15:35 +01:00
|
|
|
<div class="modal-dialog-document" role="document" style="background: {{background || '#000'}};">
|
2018-02-28 08:18:07 +01:00
|
|
|
<div class="modal-dialog-header">
|
|
|
|
{{#if title}}
|
|
|
|
<h1 class="modal-dialog-title">{{title}}</h1>
|
|
|
|
{{/if}}
|
|
|
|
<div class="close-dialog-button-wrapper">
|
2018-03-21 05:26:53 +01:00
|
|
|
<button class="close-dialog-button"
|
|
|
|
data-a11y-dialog-hide aria-label="Close dialog">
|
2018-02-28 08:18:07 +01:00
|
|
|
<span aria-hidden="true">×</span>
|
|
|
|
</button>
|
|
|
|
</div>
|
2018-02-05 04:15:35 +01:00
|
|
|
</div>
|
2018-02-23 05:04:19 +01:00
|
|
|
<slot></slot>
|
2018-02-04 22:49:43 +01:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<style>
|
2018-02-05 04:15:35 +01:00
|
|
|
:global(#modal-dialog[aria-hidden='true']) {
|
|
|
|
display: none;
|
|
|
|
}
|
|
|
|
.modal-dialog-backdrop {
|
|
|
|
position: fixed;
|
|
|
|
z-index: 10000;
|
|
|
|
left: 0;
|
|
|
|
right: 0;
|
|
|
|
bottom: 0;
|
|
|
|
top: 0;
|
|
|
|
background: rgba(51, 51, 51, 0.9);
|
2018-03-04 01:31:00 +01:00
|
|
|
transition: opacity 0.2s linear;
|
2018-02-05 04:15:35 +01:00
|
|
|
}
|
|
|
|
.modal-dialog-contents {
|
|
|
|
z-index: 10010;
|
2018-02-04 22:49:43 +01:00
|
|
|
position: fixed;
|
|
|
|
top: 50%;
|
2018-02-05 04:15:35 +01:00
|
|
|
left: 50%;
|
|
|
|
transform: translate(-50%, -50%);
|
2018-02-04 22:49:43 +01:00
|
|
|
padding: 0;
|
2018-02-06 18:09:47 +01:00
|
|
|
border: 1px solid var(--main-border);
|
|
|
|
border-radius: 2px;
|
2018-02-23 05:04:19 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: row;
|
|
|
|
max-height: calc(100% - 20px);
|
2018-03-04 01:31:00 +01:00
|
|
|
transition: opacity 0.2s linear;
|
2018-02-04 22:49:43 +01:00
|
|
|
}
|
2018-02-23 05:04:19 +01:00
|
|
|
|
2018-02-05 04:15:35 +01:00
|
|
|
.modal-dialog-document {
|
2018-02-04 22:49:43 +01:00
|
|
|
display: flex;
|
|
|
|
flex-direction: column;
|
|
|
|
align-items: center;
|
|
|
|
justify-content: center;
|
2018-02-06 18:09:47 +01:00
|
|
|
max-width: calc(100vw - 20px);
|
2018-02-23 05:04:19 +01:00
|
|
|
flex: 1;
|
2018-02-04 22:49:43 +01:00
|
|
|
}
|
2018-02-28 08:18:07 +01:00
|
|
|
.modal-dialog-header {
|
|
|
|
width: 100%;
|
|
|
|
background: var(--nav-bg);
|
|
|
|
display: flex;
|
|
|
|
align-items: center;
|
|
|
|
}
|
|
|
|
.modal-dialog-title {
|
|
|
|
color: var(--nav-text-color);
|
|
|
|
padding: 2px 0 2px 10px;
|
|
|
|
margin: 0;
|
|
|
|
font-size: 1.5em;
|
|
|
|
white-space: nowrap;
|
|
|
|
overflow: hidden;
|
|
|
|
text-overflow: ellipsis;
|
|
|
|
}
|
2018-02-04 22:49:43 +01:00
|
|
|
.close-dialog-button-wrapper {
|
2018-02-28 08:18:07 +01:00
|
|
|
flex: 1;
|
2018-02-04 22:49:43 +01:00
|
|
|
text-align: right;
|
|
|
|
}
|
|
|
|
.close-dialog-button {
|
2018-02-05 00:59:42 +01:00
|
|
|
padding: 0 0 7px;
|
2018-02-04 22:49:43 +01:00
|
|
|
background: none;
|
|
|
|
border: none;
|
|
|
|
}
|
|
|
|
.close-dialog-button span {
|
2018-02-23 05:55:00 +01:00
|
|
|
padding: 0 10px 7px;
|
|
|
|
font-size: 32px;
|
2018-02-04 22:49:43 +01:00
|
|
|
color: var(--button-primary-text);
|
|
|
|
}
|
2018-03-21 05:26:53 +01:00
|
|
|
.muted-style .modal-dialog-header {
|
|
|
|
background: var(--muted-modal-bg);
|
|
|
|
}
|
|
|
|
.muted-style .close-dialog-button:focus {
|
|
|
|
outline: 2px solid var(--muted-modal-focus);
|
|
|
|
}
|
|
|
|
.muted-style .close-dialog-button:hover {
|
|
|
|
background: var(--muted-modal-hover);
|
|
|
|
}
|
|
|
|
.muted-style.modal-dialog-contents {
|
|
|
|
border: none;
|
|
|
|
}
|
2018-02-04 22:49:43 +01:00
|
|
|
</style>
|
|
|
|
<script>
|
2018-02-05 04:15:35 +01:00
|
|
|
import A11yDialog from 'a11y-dialog'
|
2018-02-04 22:49:43 +01:00
|
|
|
|
|
|
|
export default {
|
|
|
|
oncreate() {
|
2018-02-05 04:15:35 +01:00
|
|
|
let dialogElement = this.refs.node.parentElement
|
|
|
|
let a11yDialog = new A11yDialog(dialogElement)
|
2018-02-05 18:43:45 +01:00
|
|
|
a11yDialog.on('hide', () => {
|
|
|
|
a11yDialog.destroy()
|
|
|
|
this.fire('close')
|
|
|
|
this.destroy()
|
|
|
|
})
|
2018-02-04 22:49:43 +01:00
|
|
|
this.observe('shown', shown => {
|
|
|
|
if (shown) {
|
2018-02-05 04:15:35 +01:00
|
|
|
a11yDialog.show()
|
2018-03-04 01:31:00 +01:00
|
|
|
requestAnimationFrame(() => {
|
|
|
|
this.set({ fadedIn: true })
|
|
|
|
})
|
2018-02-05 18:43:45 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
this.observe('closed', closed => {
|
|
|
|
if (closed) {
|
|
|
|
setTimeout(() => { // use setTimeout to workaround svelte timing issue
|
|
|
|
a11yDialog.hide()
|
|
|
|
}, 0)
|
2018-02-04 22:49:43 +01:00
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|