Skip to content

Instantly share code, notes, and snippets.

Avatar

Garrett Welson garrettwelson

View GitHub Profile
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
View components.x-input.js
import Ember from 'ember';
const { Component, computed } = Ember;
export default Component.extend({
tagName: 'p',
classNames: 'x-input',
attributeBindings: ['_lowerCaseLabel:data-field-name'],
_lowerCaseLabel: computed('label', function() {
return (this.get('label') || '').dasherize()
View controllers.application.js
import Ember from 'ember';
import hexColor from '../utils/hex-color';
const {
Controller,
computed
} = Ember;
export default Controller.extend({
/**
View controllers.application.js
import Ember from 'ember';
import hexColor from '../utils/hex-color';
const {
Controller,
computed
} = Ember;
export default Controller.extend({
/**
View controllers.application.js
import Ember from 'ember';
// A computed property macro!
function fullName(firstNameKey, lastNameKey) {
return Ember.computed(firstNameKey, lastNameKey, {
get() {
return `${this.get(firstNameKey)} ${this.get(lastNameKey)}`;
},
set(key, newVal) {
let parts = newVal.split(' ');
View controllers.application.js
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
@garrettwelson
garrettwelson / dayOffset.js
Created Dec 3, 2019
Cassidoo Challenge - Week of 12/2
View dayOffset.js
const days = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"]
const dayOffset = (day, offset) => days[(days.indexOf(day) + offset) % 7]
/* Results
> dayOffset("Wednesday", 4)
< "Sunday"
> dayOffset("Tuesday", 0)
< "Tuesday"
> dayOffset("Tuesday", 8)