Skip to content

Instantly share code, notes, and snippets.

View vitch's full-sized avatar

Kelvin Luck vitch

View GitHub Profile
@vitch
vitch / components.my-component.js
Last active September 13, 2019 15:52
Ember form select
import Ember from 'ember';
export default Ember.Component.extend({
fruits: null,
selectedId: null,
init() {
this._super(...arguments);
this.fruits = [
{ id: 1, name: 'apple' },
import Component from '@ember/component';
import { computed } from '@ember/object';
import { scheduleOnce } from '@ember/runloop';
const { max, pow } = Math;
const FONT_SIZES = Object.freeze([null, null, null, 34, 26]);
export default Component.extend({
tagName: '',
@vitch
vitch / components.my-component.js
Last active February 1, 2019 11:24 — forked from MichalBryxi/controllers.application.js
Dynamic computed property path - v01
import Ember from 'ember';
import {computed} from '@ember/object';
export default Ember.Component.extend({
magicName: 'foo',
foo: 'I am foo',
bar: 'I am bar (not really necessary)',
@vitch
vitch / controllers.application.js
Last active October 3, 2018 14:42 — forked from camskene/controllers.application.js
Ember - Return Promise from Computed Property
import Ember from 'ember';
export default Ember.Controller.extend({
shouldRenderComponent: false,
actions: {
renderComponent() {
this.toggleProperty('shouldRenderComponent');
},
},
@vitch
vitch / controllers.application.js
Created October 3, 2018 13:01 — forked from camskene/controllers.application.js
Ember - Return Promise from Computed Property
import Ember from 'ember';
export default Ember.Controller.extend({
shouldRenderComponent: false,
actions: {
renderComponent() {
this.toggleProperty('shouldRenderComponent');
},
},
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
accordion: Ember.inject.service(),
actions: {
expandAll() {
let accordion = this.get('accordion');
console.log('accordion', accordion);
console.log('expand all');
import Ember from 'ember';
export default Ember.Component.extend({
configuration: undefined,
actions: {
onExpand(item) {
item.toggleProperty('isExpanded');
},
},
});
@vitch
vitch / .block
Created February 5, 2018 09:21 — forked from mbostock/.block
Force-Directed Tree
license: gpl-3.0
@vitch
vitch / .block
Last active February 1, 2018 18:26 — forked from mbostock/.block
Collapsible Force Layout
license: gpl-3.0
@vitch
vitch / controllers.application.js
Last active August 29, 2015 14:26 — forked from jgwhite/controllers.application.js
CP setter without return value misbehaves
import Ember from 'ember';
const { computed } = Ember;
export default Ember.Controller.extend({
goldenRatioWidth: Ember.computed('height', {
get(key) {
return this.get('height') * 1.618;
},
set(key, value) {
this.set('height', value / 1.618);