forked from cybrespace/pinafore
		
	
		
			
				
	
	
		
			141 lines
		
	
	
		
			No EOL
		
	
	
		
			3.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			141 lines
		
	
	
		
			No EOL
		
	
	
		
			3.5 KiB
		
	
	
	
		
			HTML
		
	
	
	
	
	
<div class="modal-dialog-backdrop {{fadedIn ? '' : 'hidden'}}"
 | 
						|
     tabindex="-1"
 | 
						|
     data-a11y-dialog-hide
 | 
						|
></div>
 | 
						|
<div class="modal-dialog-contents {{fadedIn ? '' : 'hidden'}} {{muted ? 'muted-style' : ''}}"
 | 
						|
     role="dialog"
 | 
						|
     aria-label="{{label || ''}}"
 | 
						|
     ref:node
 | 
						|
>
 | 
						|
  <div class="modal-dialog-document" role="document" style="background: {{background || '#000'}};">
 | 
						|
    <div class="modal-dialog-header">
 | 
						|
      {{#if title}}
 | 
						|
        <h1 class="modal-dialog-title">{{title}}</h1>
 | 
						|
      {{/if}}
 | 
						|
      <div class="close-dialog-button-wrapper">
 | 
						|
        <button class="close-dialog-button"
 | 
						|
                data-a11y-dialog-hide aria-label="Close dialog">
 | 
						|
          <span class="close-dialog-button-span" aria-hidden="true">×</span>
 | 
						|
        </button>
 | 
						|
      </div>
 | 
						|
    </div>
 | 
						|
    <slot></slot>
 | 
						|
  </div>
 | 
						|
</div>
 | 
						|
<style>
 | 
						|
  :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);
 | 
						|
    transition: opacity 0.2s linear;
 | 
						|
  }
 | 
						|
  .modal-dialog-contents {
 | 
						|
    z-index: 10010;
 | 
						|
    position: fixed;
 | 
						|
    top: 50%;
 | 
						|
    left: 50%;
 | 
						|
    -webkit-filter: blur(0);
 | 
						|
    will-change: transform;
 | 
						|
    transform: translate(-50%, -50%);
 | 
						|
    -webkit-font-smoothing: antialiased; /* fix for transform:translate causing blurry text in Chrome/Safari */
 | 
						|
    padding: 0;
 | 
						|
    border: 1px solid var(--main-border);
 | 
						|
    border-radius: 2px;
 | 
						|
    display: flex;
 | 
						|
    flex-direction: row;
 | 
						|
    max-height: calc(100% - 20px);
 | 
						|
    transition: opacity 0.2s linear;
 | 
						|
  }
 | 
						|
 | 
						|
  .modal-dialog-document {
 | 
						|
    display: flex;
 | 
						|
    flex-direction: column;
 | 
						|
    align-items: center;
 | 
						|
    justify-content: center;
 | 
						|
    max-width: calc(100vw - 20px);
 | 
						|
    flex: 1;
 | 
						|
  }
 | 
						|
  .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;
 | 
						|
  }
 | 
						|
  .close-dialog-button-wrapper {
 | 
						|
    flex: 1;
 | 
						|
    display: flex;
 | 
						|
    justify-content: flex-end;
 | 
						|
  }
 | 
						|
  .close-dialog-button {
 | 
						|
    padding: 0;
 | 
						|
    background: none;
 | 
						|
    border: none;
 | 
						|
    display: flex;
 | 
						|
    justify-content: center;
 | 
						|
    align-items: center;
 | 
						|
  }
 | 
						|
  .close-dialog-button-span {
 | 
						|
    padding: 0 10px 5px;
 | 
						|
    font-size: 32px;
 | 
						|
    color: var(--button-primary-text);
 | 
						|
    flex: 1;
 | 
						|
  }
 | 
						|
  .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;
 | 
						|
  }
 | 
						|
</style>
 | 
						|
<script>
 | 
						|
  import A11yDialog from 'a11y-dialog'
 | 
						|
 | 
						|
  export default {
 | 
						|
    oncreate() {
 | 
						|
      let dialogElement = this.refs.node.parentElement
 | 
						|
      let a11yDialog = new A11yDialog(dialogElement)
 | 
						|
      a11yDialog.on('hide', () => {
 | 
						|
        a11yDialog.destroy()
 | 
						|
        this.fire('close')
 | 
						|
        this.destroy()
 | 
						|
      })
 | 
						|
      this.observe('shown', shown => {
 | 
						|
        if (shown) {
 | 
						|
          a11yDialog.show()
 | 
						|
          requestAnimationFrame(() => {
 | 
						|
            this.set({ fadedIn: true })
 | 
						|
          })
 | 
						|
        }
 | 
						|
      })
 | 
						|
      this.observe('closed', closed => {
 | 
						|
        if (closed) {
 | 
						|
          setTimeout(() => { // use setTimeout to workaround svelte timing issue
 | 
						|
            a11yDialog.hide()
 | 
						|
          }, 0)
 | 
						|
        }
 | 
						|
      })
 | 
						|
    }
 | 
						|
  }
 | 
						|
</script> |