Skip to content

Instantly share code, notes, and snippets.

@grapho
Last active October 11, 2017 00:12
Show Gist options
  • Save grapho/9a0ee2e281ea45d45bfb0f758cba35d8 to your computer and use it in GitHub Desktop.
Save grapho/9a0ee2e281ea45d45bfb0f758cba35d8 to your computer and use it in GitHub Desktop.
New Input
import Ember from 'ember';
export default Ember.Component.extend({
classNames: ['input-addon']
});
import Ember from 'ember';
export default Ember.Component.extend({
tagName: 'label',
wasFocused: false,
focusOut() {
Ember.set(this, 'wasFocused', true);
}
});
import Ember from 'ember';
export default Ember.Component.extend({
shouldDisplayValidations: Ember.computed('wasFocused', function() {
return Ember.get(this, 'wasFocused');
})
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'New Denali Input'
});
<h1>Welcome to {{appName}}</h1>
{{#input-text label="Foo" as |f|}}
{{f.input appName update=(action (mut appName))}}
{{f.validation changeset attr}}
{{/input-text}}
{{#if label}}
<span>
{{label}}
</span>
{{/if}}
{{yield (hash
input=(component 'one-way-input')
addon=(component 'input-addon')
validation=(component 'input-validation' wasFocused=wasFocused)
)}}
{{#if shouldDisplayValidations}}
Hi!
{{/if}}
{
"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",
"ember-one-way-controls": "2.0.0"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment