89136cbf6a
Manual interventions: • decorators on the same line for service and controller injections and most computed property macros • preserving import order when possible, both per-line and intra-line • moving new imports to the bottom • removal of classic decorator for trivial cases • conversion of init to constructor when appropriate
34 lines
748 B
JavaScript
34 lines
748 B
JavaScript
import Component from '@ember/component';
|
|
import { computed } from '@ember/object';
|
|
import { classNames, tagName } from '@ember-decorators/component';
|
|
import classic from 'ember-classic-decorator';
|
|
|
|
@classic
|
|
@tagName('figure')
|
|
@classNames('image-file')
|
|
export default class ImageFile extends Component {
|
|
'data-test-image-file' = true;
|
|
|
|
src = null;
|
|
alt = null;
|
|
size = null;
|
|
|
|
// Set by updateImageMeta
|
|
width = 0;
|
|
height = 0;
|
|
|
|
@computed('src')
|
|
get fileName() {
|
|
if (!this.src) return;
|
|
return this.src.includes('/') ? this.src.match(/^.*\/(.*)$/)[1] : this.src;
|
|
}
|
|
|
|
updateImageMeta(event) {
|
|
const img = event.target;
|
|
this.setProperties({
|
|
width: img.naturalWidth,
|
|
height: img.naturalHeight,
|
|
});
|
|
}
|
|
}
|