Skip to content

Instantly share code, notes, and snippets.

@dfreeman
Created April 7, 2017 14:28
Show Gist options
  • Save dfreeman/33f0fd920fb71452d3dc60e4f0ecd0a7 to your computer and use it in GitHub Desktop.
Save dfreeman/33f0fd920fb71452d3dc60e4f0ecd0a7 to your computer and use it in GitHub Desktop.
dynamic
import Ember from 'ember';
export default Ember.Component.extend({
classNames: 'my-component',
didReceiveAttrs() {
this._updateVariables();
},
didInsertElement() {
this._updateVariables();
},
_updateVariables() {
let style = this.get('element.style');
if (style) {
style.setProperty('--foreground-color', this.get('foreground'));
style.setProperty('--gradient-color-dark', this.get('dark'));
style.setProperty('--gradient-color-light', this.get('light'));
}
}
});
.my-component {
color: var(--foreground-color);
background:
var(--gradient-color-dark)
linear-gradient(var(--gradient-color-dark), var(--gradient-color-light));
}
{{#my-component dark='#090' light='#6f6'}}
green
{{/my-component}}
{{#my-component dark='#333' light='#888' foreground='white'}}
hello
{{/my-component}}
{
"version": "0.12.1",
"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.12.0",
"ember-template-compiler": "2.12.0",
"ember-testing": "2.12.0"
},
"addons": {
"ember-data": "2.12.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment