Skip to content

Instantly share code, notes, and snippets.

@megganeturner
Last active April 27, 2018 04:53
Show Gist options
  • Save megganeturner/fbc83802a59b0f170cf5835b1120c0da to your computer and use it in GitHub Desktop.
Save megganeturner/fbc83802a59b0f170cf5835b1120c0da to your computer and use it in GitHub Desktop.
dropdown action
import Ember from 'ember';
export default Ember.Component.extend({
dropdownVisible: false,
isLoading: null,
dropdownClass: Ember.computed('dropdownVisible', function p () {
const visible = this.get('dropdownVisible');
return visible ? 'visible' : 'hidden';
}),
mouseEnter (e) {
if (e.target.className !== 'clickMe' && this.get('dropdownVisible') === false) {
console.log('hello');
this.set('dropdownVisible', true);
}
},
mouseLeave () {
this.set('dropdownVisible', false);
},
actions: {
handleClick () {
this.set('isLoading', true);
window.setTimeout(() => {
this.set('dropdownVisible', true);
this.set('isLoading', false);
}, 1000);
}
}
});
import Ember from 'ember';
export default Ember.Component.extend({
dropdownVisible: false,
isLoading: null,
dropdownClass: Ember.computed('dropdownVisible', function p () {
const visible = this.get('dropdownVisible');
return visible ? 'visible' : 'hidden';
}),
mouseEnter (e) {
if (e.target.className !== 'clickMe' && this.get('dropdownVisible') === false) {
console.log('hello');
this.set('dropdownVisible', true);
}
},
mouseLeave () {
this.set('dropdownVisible', false);
},
actions: {
handleClick () {
this.set('isLoading', true);
window.setTimeout(() => {
this.set('dropdownVisible', true);
this.set('isLoading', false);
}, 1000);
}
}
});
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;
text-align: center;
}
.clickMe {
border: 1px solid dodgerblue;
}
.visible {
transition: all 500ms linear;
width: auto;
border: 1px solid pink;
visibility: visible;
opacity: 1;
}
.hidden {
transition: all 500ms linear;
transition-delay: 1s;
border: 1px solid pink;
visibility: hidden;
opacity: 0;
}
.loading {
color: dodgerblue;
}
img {
height: 25px;
}
{{pop-up}}
<br><br>
{{popup-with-svg}}
<div class="clickMe" onClick={{action 'handleClick'}}>
{{#if isLoading}}
<span class="loading">loading</span>
{{else}}
click me
{{/if}}
</div>
<div class={{dropdownClass}}>
dropdown content<br>
dropdown content<br>
dropdown content<br>
</div>
<div class="clickMe" onClick={{action 'handleClick'}}>
{{#if isLoading}}
<span class="loading">loading</span>
{{else}}
<img src="http://simpleicon.com/wp-content/uploads/rocket.svg">
{{/if}}
</div>
<div class={{dropdownClass}}>
dropdown content<br>
dropdown content<br>
dropdown content<br>
</div>
{
"version": "0.13.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.16.2",
"ember-template-compiler": "2.16.2",
"ember-testing": "2.16.2"
},
"addons": {
"ember-data": "2.16.3"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment