Last active
December 28, 2016 00:17
-
-
Save lukemelia/54ad94b74246529c57286369273f410c to your computer and use it in GitHub Desktop.
Bug
This file contains 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'; | |
const { computed } = Ember; | |
export default Ember.Component.extend({ | |
backgroundColor: computed('model.backgroundColor', { | |
get() { | |
return this.get('model.backgroundColor'); | |
}, | |
set(key, val) { | |
if (val && !/^#/.test(val) && val !== 'transparent') { | |
val = `#${val}`; | |
} | |
this.set('model.backgroundColor', val); | |
return val; | |
} | |
}), | |
actions: { | |
colorChanged(color) { | |
this.set('backgroundColor', color); | |
this.set('model.backgroundType', 'color'); | |
this.set('model.backgroundImage', null); | |
} | |
} | |
}); |
This file contains 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'; | |
const { computed } = Ember; | |
export default Ember.Controller.extend({ | |
model: null, | |
backgroundStyle: computed('model.cover.backgroundColor', function() { | |
let backgroundColor = this.get('model.cover.backgroundColor'); | |
if (backgroundColor) { | |
return `background-color: ${backgroundColor};`; | |
} | |
}), | |
bgStyle: computed.readOnly('backgroundStyle') | |
}); |
This file contains 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'; | |
const htmlSafe = Ember.String.htmlSafe; | |
const escape = Ember.Handlebars.Utils.escapeExpression; | |
export default Ember.Helper.helper(function ([color]) { | |
if (!color) { | |
return; | |
} | |
if (color) { | |
return htmlSafe(`background: ${escape(color)}`); | |
} | |
}); |
This file contains 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.Route.extend({ | |
model() { | |
let model = Ember.Object.create({ | |
cover: Ember.Object.create({ | |
backgroundColor: null | |
}) | |
}); | |
return model; | |
} | |
}); |
This file contains 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.10.7", | |
"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.10.2", | |
"ember-template-compiler": "2.10.0", | |
"ember-testing": "2.10.0" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment