Skip to content

Instantly share code, notes, and snippets.

@amessinger
Last active July 31, 2020 09:53
Show Gist options
  • Save amessinger/aebdb9d9aebc6ef7378917e99c825aef to your computer and use it in GitHub Desktop.
Save amessinger/aebdb9d9aebc6ef7378917e99c825aef to your computer and use it in GitHub Desktop.
Base
import Component from '@glimmer/component';
import { action } from '@ember/object';
export default class extends Component {
get isActive() {
const { item, options: { activeItem } } = this.args;
return item === activeItem;
}
@action
setActive(event) {
event.preventDefault();
console.log('hello');
}
}
import Component from '@glimmer/component';
export default class extends Component {
}
import Controller from '@ember/controller';
import EmberObject from '@ember/object';
export default class ApplicationController extends Controller {
appName = 'Ember Twiddle';
items = [1, 2, 3, 4];
options = EmberObject.create({
activeItem: 3
});
}
<ItemsContainer
@items={{this.items}}
@options={{this.options}}
/>
<input
type="checkbox"
checked={{this.isActive}}
{{on 'click' setActive}}
/> Item #{{@item}}
{{#if @items}}
<ul>
{{#each @items as |item|}}
<li>
<Item
@item={{item}}
@options={{@options}}
/>
</li>
{{/each}}
</ul>
{{else}}
<p>
No items :'(
</p>
{{/if}}
{
"version": "0.17.1",
"EmberENV": {
"FEATURES": {},
"_TEMPLATE_ONLY_GLIMMER_COMPONENTS": false,
"_APPLICATION_TEMPLATE_WRAPPER": true,
"_JQUERY_INTEGRATION": true
},
"options": {
"use_pods": false,
"enable-testing": false
},
"dependencies": {
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.js",
"ember": "3.18.1",
"ember-template-compiler": "3.18.1",
"ember-testing": "3.18.1"
},
"addons": {
"@glimmer/component": "1.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment