Skip to content

Instantly share code, notes, and snippets.

@ef4
Last active May 24, 2016 17:40
Show Gist options
  • Save ef4/f832332f8662cb190983d9e4499c4ba2 to your computer and use it in GitHub Desktop.
Save ef4/f832332f8662cb190983d9e4499c4ba2 to your computer and use it in GitHub Desktop.
classnames
import Ember from 'ember';
import computed, { equal } from 'ember-computed';
export default Ember.Component.extend({
tagName: '',
didRender() {
// show classes in DOM for debug purposes
$('body > .my-debug').remove();
$('body').append(`<div class="my-debug">${$('button').attr('class')}</div>`);
}
});
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
import Ember from 'ember';
export function myHelper([a, b]/*, hash*/) {
return a === b;
}
export default Ember.Helper.helper(myHelper);
<h1>Welcome to {{appName}}</h1>
<br>
<br>
<div>
withIcon: {{input type="checkbox" checked=withIcon}}
</div>
<div>
buttonType: {{input value=buttonType}}
</div>
<div>
onlyIcon: {{input type="checkbox" checked=onlyIcon}}
</div>
<div>
fullWidth: {{input type="checkbox" checked=fullWidth}}
</div>
<div>
iconType: {{input value=iconType}}
</div>
{{#my-component withIcon=withIcon buttonType=buttonType onlyIcon=onlyIcon fullWidth=fullWidth iconType=iconType}}Hello world{{/my-component}}
<br>
<br>
<button class="
{{if buttonType (concat 'Button--' buttonType)}}
{{if onlyIcon 'Button--icon'}}
{{if withIcon 'Button--withIcon'}}
{{if iconType (concat 'Icon--' iconType)}}
{{if (eq buttonType 'red') 'Button--outline'}}
{{if fullWidth 'Button--fullWidth'}}
">
{{yield}}
</button>
{
"version": "0.8.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.5.1",
"ember-data": "2.5.2",
"ember-template-compiler": "2.5.1"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment