Skip to content

Instantly share code, notes, and snippets.

@HenryVonfire
Created August 15, 2016 12:36
Show Gist options
  • Select an option

  • Save HenryVonfire/31eeed75d03e551f76a0c3831177bc20 to your computer and use it in GitHub Desktop.

Select an option

Save HenryVonfire/31eeed75d03e551f76a0c3831177bc20 to your computer and use it in GitHub Desktop.
modal with ember-elsewhere
import Ember from 'ember';
export default Ember.Controller.extend({
warn: false
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.modal-backdrop {
position: fixed;
top: 0;
left: 0;
width: 100vw;
height: 100vh;
background-color: black;
opacity: 0.5;
z-index: 9999;
}
.modal-background {
background-color: black;
opacity: 0.5;
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
}
.modal-container {
width: 100vw;
height: 100vh;
position: fixed;
top: 0;
left: 0;
display: flex;
justify-content: center;
align-items: center;
}
.modal-dialog {
background-color: white;
padding: 1em;
border-radius: 5px;
border: 1px solid #B4B4E8;
position: relative;
z-index: 1;
}
{{#from-elsewhere name="modal" as |modal|}}
{{#if modal}}
<div class="modal-container">
<div class="modal-background" onclick={{action modal.onOutsideClick}}></div>
<div class="modal-dialog" >
{{component modal.body}}
</div>
</div>
{{/if}}
{{/from-elsewhere}}
<p><button {{action (action (mut warn) true)}}>Launch a modal</button></p>
{{#if warn}}
{{to-elsewhere
named="modal"
send=(hash body=(component "warning-modal"
onCancel=(action (mut warn) false))
onOutsideClick=(action (mut warn) false)) }}
{{/if}}
{
"version": "0.10.4",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js",
"ember": "2.6.2",
"ember-data": "2.7.0",
"ember-template-compiler": "2.6.2"
},
"addons": {
"ember-elsewhere": "latest"
}
}
<p>This is a sample warning message!</p>
<button {{action onCancel}}>Close It</button>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment