Last active
November 29, 2018 22:15
-
-
Save samselikoff/6f7da7acd8d064017fb8e50bf0a25981 to your computer and use it in GitHub Desktop.
Nested dropdown
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
import { computed } from '@ember/object'; | |
export default Component.extend({ | |
mouseEnter() { | |
this.setActiveItems(this); | |
}, | |
mouseLeave() { | |
this.clearActiveItems(); | |
}, | |
isActive: computed('activeItems.[]', function() { | |
return this.activeItems.objectAt(0) === this; | |
}) | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Component from '@ember/component'; | |
import { task, timeout } from 'ember-concurrency'; | |
import { isEmpty } from '@ember/utils'; | |
export default Component.extend({ | |
init() { | |
this._super(...arguments); | |
this.set('activeItems', []); | |
}, | |
setActiveItems(...path) { | |
this.updateActiveItems.perform(path); | |
}, | |
clearActiveItems() { | |
this.updateActiveItems.perform([]); | |
}, | |
updateActiveItems: task(function*(path) { | |
if (isEmpty(path)) { | |
yield timeout(1000); | |
} | |
this.set('activeItems', path); | |
}).restartable() | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
appName: 'Ember Twiddle' | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
ul { | |
width: 400px; | |
} | |
li { | |
background: #DAE1E7; | |
display: block; | |
width: 400px; | |
padding: 10px; | |
cursor: pointer; | |
} | |
.active { | |
background: #FFED4A; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.15.1", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js", | |
"ember": "3.4.3", | |
"ember-template-compiler": "3.4.3", | |
"ember-testing": "3.4.3" | |
}, | |
"addons": { | |
"ember-data": "3.4.2", | |
"ember-concurrency": "0.8.19", | |
"ember-modal-dialog": "2.4.4", | |
"ember-composable-helpers": "2.1.0" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment