Skip to content

Instantly share code, notes, and snippets.

@camskene
Created August 13, 2018 01:27
Show Gist options
  • Save camskene/269599aee23fcae2f893c83d25174bac to your computer and use it in GitHub Desktop.
Save camskene/269599aee23fcae2f893c83d25174bac to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
items: Ember.computed(function() {
return [
{
title: 'item 1',
},
{
title: 'item 2',
},
{
title: 'item 3',
},
];
}),
actions: {
toggleActiveItem(item) {
this.set('activeItem', this.get('activeItem') !== item ? item : null);
},
},
});
import Ember from 'ember';
export default Ember.Route.extend({
});
{{#each items as |item|}}
{{#accordion-item
click=(action 'toggleActiveItem' item)
item=item
activeItem=activeItem
title=item.title
}}
<p>body</p>
{{/accordion-item}}
{{/each}}
import Ember from 'ember';
export default Ember.Component.extend({
// isExpanded: Ember.computed.equal('item', 'activeItem'),
item: undefined,
activeItem: undefined,
isExpanded: Ember.computed('activeItem', 'item', function() {
return this.get('activeItem') === this.get('item');
}),
});
<h3>{{title}}</h3>
{{#if isExpanded}}
{{yield}}
{{/if}}
import Ember from 'ember';
export default Ember.Controller.extend({
});
import Ember from 'ember';
export default Ember.Route.extend({
});
{{link-to 'a' 'a'}}
{{outlet}}
import EmberRouter from '@ember/routing/router';
import config from './config/environment';
const Router = EmberRouter.extend({
location: 'none',
rootURL: config.rootURL
});
Router.map(function() {
this.route('a');
});
export default Router;
{
"version": "0.15.0",
"EmberENV": {
"FEATURES": {}
},
"options": {
"use_pods": true,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.js",
"ember": "3.2.2",
"ember-template-compiler": "3.2.2",
"ember-testing": "3.2.2"
},
"addons": {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment