Skip to content

Instantly share code, notes, and snippets.

@krivaten
Last active May 22, 2017 18:16
Show Gist options
  • Save krivaten/0f3c38159c6364cb1130fb15bc2a89b9 to your computer and use it in GitHub Desktop.
Save krivaten/0f3c38159c6364cb1130fb15bc2a89b9 to your computer and use it in GitHub Desktop.
UI Image
import Ember from 'ember';
const {
Component,
get,
computed,
} = Ember;
let UiImg = Component.extend({
classNames: ['ui-img'],
tagName: 'img',
attributeBindings: [
'src',
'alt',
'_ariaHidden:aria-hidden',
],
path: null,
alt: null,
src: computed('path', function() {
let path = get(this, 'path');
return path;
}),
_ariaHidden: computed('alt', function() {
return get(this, 'alt') ? undefined : 'true';
}),
});
UiImg.reopenClass({
positionalParams: ['path']
});
export default UiImg;
import Ember from 'ember';
export default Ember.Controller.extend({
});
<h1>A <code>UI-IMG</code> Component</h1>
{{ui-img 'https://unsplash.it/200/300?image=0'}}
{{ui-img 'https://unsplash.it/200/300?image=500' alt='Magic'}}
{
"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"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment