Last active
July 3, 2019 19:51
-
-
Save Bestra/52f53a0913cc4d143ae1453a466bc2ac to your computer and use it in GitHub Desktop.
Accordion list
This file contains 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
// components/accordion-item.js | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
item: null, | |
activeItem: null, | |
isExpanded: Ember.computed('activeItem', 'item', function() { | |
return this.get('activeItem') === this.get('item'); | |
}) | |
}); |
This file contains 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
// components/accordion-list.js | |
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
items: null, | |
activeItem: null, | |
actions: { | |
toggleActiveItem(item) { | |
if (this.get('activeItem') !== item) { | |
this.set('activeItem', item); | |
} else { | |
this.set('activeItem', null); | |
} | |
} | |
} | |
}); |
This file contains 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
// controllers/application.js | |
import Ember from 'ember'; | |
export default Ember.Controller.extend({ | |
items: Ember.computed(function() { | |
return [ | |
{title: "Item 1", details: "Details here"}, | |
{title: "Item 2", details: "Details here"}, | |
{title: "Item 3", details: "Details here"} | |
] | |
}) | |
}); |
This file contains 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 list | | |
+---+------------------+----------+ | |
^ | | |
| | item, expandedItem | |
toggleExpanded | | |
| | | |
| +---------v----------+ | |
| | accordion-item | | |
+--------+ | | |
+--------------------+ | |
This file contains 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; | |
} | |
.header { | |
background: #eee; | |
padding: 10px; | |
} | |
.details { | |
padding: 10px 10px 20px 10px; | |
} |
This file contains 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.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.7.0", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.7.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment