Skip to content

Instantly share code, notes, and snippets.

@koriroys
Last active July 5, 2016 09:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save koriroys/30d99bbc2a1dc35f1811d8172f1e9fa1 to your computer and use it in GitHub Desktop.
Save koriroys/30d99bbc2a1dc35f1811d8172f1e9fa1 to your computer and use it in GitHub Desktop.
Fun with DDAU
import Ember from 'ember';
export default Ember.Component.extend({
init() {
this._super(...arguments);
}
});
import Ember from 'ember';
export default Ember.Component.extend({
parentText: "hello",
actions: {
updateText(text) {
this.set("parentText", text);
}
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle',
parentText: "hello"
});
body {
margin: 12px 16px;
font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
font-size: 12pt;
}
.value {
color: #6ac1b9;
font-size: 1.2em;
}
textarea {
resize: none;
background-color: #fafafa;
border: solid 1px rgba(106, 193, 185, 0.67);
color: #6ac1b9;
}
.text-with-label {
margin-top: 20px;
display: inline-block;
position: relative;
}
.text-with-label textarea {
border: solid 1px rgba(106, 193, 185, 0.67);
border-radius: 3px;
display: inline-block;
font-weight: 500;
font-size: 1.2em;
outline: 0;
padding: 20px;
width: 300px;
}
.text-with-label textarea + label {
background-color: #f8f8f8;
border-radius: 3px;
box-shadow: -1px 1px 0 0 rgba(0, 0, 0, 0.08);
color: #6ac1b9;
display: inline-block;
font-family: "Whitney-Pro", sans-serif;
font-weight: 400;
font-size: 13px;
position: absolute;
top: -15px;
left: 10px;
padding: 5px 8px;
}
<h1>Fun with DDAU</h1>
{{outlet}}
{{my-parent}}
<br>
<br>
{{yield}}
<p>
<div class="text-with-label">
{{textarea id="one" rows="3" value=text}}
<label for="one">Mutable two-way binding</label>
</div>
</p>
<p>
<div class="text-with-label">
<textarea id="two" rows="3" value={{text}} oninput={{action updateText value="target.value"}}></textarea>
<label for="two">Non-mutable with explicit action</label>
</div>
</p>
<p>
<div class="text-with-label">
<textarea id="three" rows="3" value={{text}} oninput={{action (mut text) value="target.value"}}></textarea>
<label for="three">Non-mutable with mut helper</label>
</div>
</p>
<p>
Value:
<span class="value">{{text}}</span>
</p>
{{yield}}
{{my-child text=(mut parentText) updateText=(action "updateText")}}
{
"version": "0.10.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.6.0",
"ember-data": "2.6.1",
"ember-template-compiler": "2.6.0"
},
"addons": {}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment