Skip to content

Instantly share code, notes, and snippets.

@krivaten
Last active July 21, 2016 15:38
Show Gist options
  • Save krivaten/5fa81acfc0791e99c437e65e1dd2fae9 to your computer and use it in GitHub Desktop.
Save krivaten/5fa81acfc0791e99c437e65e1dd2fae9 to your computer and use it in GitHub Desktop.
New Twiddle
import Ember from 'ember';
const { Component, get, computed, String: { loc } } = Ember;
const InlineIconComponent = Component.extend({
tagName: 'span',
classNames: ['noPrint'],
classNameBindings: [
'print::noPrint',
'_iconClass'
],
attributeBindings: [
'hidden:aria-hidden',
'_label:aria-label'
],
icon: computed('attrs.icon', function() {
return get(this, 'attrs.icon');
}),
print: false,
hidden: true,
labelLoc: null,
_label: computed('labelLoc', function() {
let labelLoc = get(this, 'labelLoc');
return labelLoc ? loc(labelLoc) : null;
}),
_iconClass: computed('name', function() {
let icon = get(this, 'icon');
return icon ? `icon-${icon}` : null;
})
});
InlineIconComponent.reopenClass({
positionalParams: ['icon']
});
export default InlineIconComponent;
import Ember from 'ember';
export default Ember.Controller.extend({
appName: 'Ember Twiddle'
});
<h1>Welcome to {{appName}}</h1>
{{inline-icon 'samurai'}}
{
"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