Last active
September 1, 2019 12:52
-
-
Save selvagsz/3daf8d88eb14e6f3322a516d6166f11b to your computer and use it in GitHub Desktop.
ember-accordion DEMO https://ember-twiddle.com/3daf8d88eb14e6f3322a516d6166f11b?openFiles=templates.application.hbs
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.Component.extend({ | |
classNameBindings: [':accordion-item', 'isOpen'], | |
isOpen: Ember.computed('elementId', 'accordion.activeItemId', function() { | |
return this.elementId === this.accordion.activeItemId; | |
}), | |
_open() { | |
this.accordion.actions.open(this.elementId); | |
}, | |
_close() { | |
this.accordion.actions.close(this.elementId); | |
}, | |
actions: { | |
open() { | |
this._open(); | |
}, | |
close() { | |
this._close(); | |
}, | |
toggle() { | |
if (this.isOpen) { | |
this._close(); | |
} else { | |
this._open(this.elementId); | |
} | |
}, | |
}, | |
}); |
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.Component.extend({ | |
init() { | |
this._super(...arguments); | |
this.set('activeItemId', null); | |
}, | |
actions: { | |
open(key) { | |
this.set('activeItemId', key); | |
}, | |
close() { | |
this.set('activeItemId', null); | |
}, | |
}, | |
}); |
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({ | |
}); |
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
.accordion-item { | |
border: 2px solid green; | |
} | |
.accordion-item__trigger { | |
cursor: pointer; | |
} | |
.accordion-item__content { | |
height: 0; | |
overflow: hidden; | |
} | |
.accordion-item__content--open { | |
height: auto; | |
} |
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" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment