Created
August 16, 2016 18:23
-
-
Save givanse/2ca45210db14be39962014acc1ea30a6 to your computer and use it in GitHub Desktop.
Exploring components
This file contains hidden or 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.Component.extend({ | |
classNames: ['child-c'], | |
classNameBindings: ['dashed'], | |
dashed: false, | |
value: null, | |
// https://guides.emberjs.com/v2.2.0/components/the-component-lifecycle/ | |
didInsertElement: function() { | |
this._super(...arguments); | |
this._log('didInsertElement'); | |
}, | |
didRender: function() { | |
this._super(...arguments); | |
this._log('didRender'); | |
}, | |
didUpdate: function() { | |
this._super(...arguments); | |
this._log('didUpdate'); | |
}, | |
_log: function(hookName) { | |
let value = this.get('value'); | |
Ember.Logger.log('child-c', hookName, value); | |
}, | |
actions: { | |
toggleCSSClass: function() { | |
this.toggleProperty('dashed'); | |
} | |
} | |
}); |
This file contains hidden or 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.Component.extend({ | |
classNames: ['parent-c'], | |
didInsertElement: function() { | |
this._super(...arguments); | |
Ember.Logger.log('parent-c didInsertElement'); | |
} | |
}); |
This file contains hidden or 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.Controller.extend({ | |
}); |
This file contains hidden or 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
body { | |
margin: 12px 16px; | |
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; | |
font-size: 12pt; | |
} | |
.parent-c, | |
.child-c { | |
border: 1px solid #000; | |
} | |
.parent-c { | |
padding: 2px; | |
} | |
.child-c { | |
margin: 5px; | |
padding: 5px; | |
} | |
.dashed { | |
border: 1px dashed blue; | |
} |
This file contains hidden or 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.4", | |
"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.2.2", | |
"ember-data": "2.7.0", | |
"ember-template-compiler": "2.2.2" | |
}, | |
"addons": {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment