Skip to content

Instantly share code, notes, and snippets.

@atonse
Last active June 27, 2016 21:30
Show Gist options
  • Save atonse/fbbb1d8febbaba2e055ac9b46684c124 to your computer and use it in GitHub Desktop.
Save atonse/fbbb1d8febbaba2e055ac9b46684c124 to your computer and use it in GitHub Desktop.
Liquid Tether
import Ember from 'ember';
export default Ember.Component.extend({
wrapperClassNames: ['col-lg-12', 'col-md-12', 'col-sm-11', 'col-xs-12'],
shouldDisplay: false,
actions: {
show() {
this.set('shouldDisplay', true);
},
onClose() {
this.toggleProperty('shouldDisplay');
}
},
setup: function() {
Ember.$('body').on('keyup.modal-dialog', (e) => {
if (e.keyCode === 27) {
this.sendAction('close');
}
});
}.on('didInsertElement'),
teardown: function() {
Ember.$('body').off('keyup.modal-dialog');
}.on('willDestroyElement')
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.slide-in-popover {
background: white;
margin-top: 70px;
box-shadow: 0 5px 10px rgba(0, 0, 0, .4);
border-radius: 3px;
// height: calc(100vh - 90px);
overflow-y: scroll;
.popover-title {
padding: 8px 14px;
margin: 0;
font-size: 18px;
background-color: #f7f7f7;
border-bottom: 1px solid #ebebeb;
background-color: transparent;
color: #7e57c2;
font-weight: 600;
}
.popover-body {
padding: 20px;
}
}
<h1>Welcome to {{appName}}</h1>
<br>
<br>
{{outlet}}
<br>
<br>
{{#st-popover title="myTitle" linkText="click me"}}
Hello World!
{{/st-popover}}
{{#if shouldDisplay}}
{{#liquid-tether target=".navbar"
to="flyout"
close="onClose"
attachment="top right"
targetAttachment="top right"
tetherClass="slide-in-popover"
}}
<h3 class="popover-title">
{{title}} &nbsp;
<a href="#" {{action 'onClose'}} class="pull-right btn btn-default">Close</a>
</h3>
<div class="popover-body">
{{yield}}
</div>
{{/liquid-tether}}
{{/if}}
{{#if linkText}}
<a href="#" {{action 'show'}} class="{{if isButton 'btn btn-default' ''}}">{{linkText}}</a>
{{/if}}
import { onOpenTether, target } from 'liquid-tether';
export default function() {
this.transition(
target('flyout'),
onOpenTether(),
this.use('tether', 'to-left'),
this.reverse('tether', 'to-right')
);
}
{
"version": "0.10.1",
"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.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {
"liquid-tether": "1.1.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment