Last active
May 21, 2017 20:28
-
-
Save camskene/d52de0bd6369b2020fdb04778ed1fe90 to your computer and use it in GitHub Desktop.
Ember accordion
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({ | |
tagName: '', | |
}); |
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({ | |
activeItem: {}, | |
title: '', | |
isOpen: false, | |
tagName: '', | |
didInsertElement() { | |
this._super(...arguments); | |
if (this.get('isOpen')) { | |
this.set('activeItem.id', this.get('tabId')); | |
} | |
}, | |
isCollapsed: Ember.computed('tabId', 'activeItem.id', function() { | |
return this.get('tabId') === this.get('activeItem.id'); | |
}), | |
tabId: Ember.computed(function() { | |
return Math.trunc(Math.random() * 10000); | |
}), | |
actions: { | |
toggle() { | |
this.set('activeItem.id', this.get('isCollapsed') ? undefined : this.get('tabId')); | |
}, | |
}, | |
}); |
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
* { | |
line-height: 1; | |
padding: 0; | |
margin: 0; | |
} | |
body { | |
font-family: sans-serif; | |
} | |
[role="tab"] { | |
background-color: #eee; | |
border-bottom: 1px solid #fff; | |
font-weight: normal; | |
padding: 0.5em 1em; | |
} | |
[role="tab"]:focus { | |
background-color: #ddd; | |
outline: 0; | |
} | |
[role="tabpanel"] { | |
padding: 1em; | |
border-bottom: 1px solid #eee; | |
} |
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.12.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.12.0", | |
"ember-template-compiler": "2.12.0", | |
"ember-testing": "2.12.0" | |
}, | |
"addons": { | |
"liquid-fire": "0.27.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment