Ghost/ghost/admin/app/components/gh-editor-feature-image.js
Kevin Ansfield 0d30077325 Switched to new component for labs feature image redesign
refs https://github.com/TryGhost/Team/issues/771

- added `<GhEditorFeatureImage>` for more flexibility than offered by `<GhImageUploaderWithPreview>`
  - updated to more closely match intended designs
- removed alt/caption support from `<GhImageUploaderWithPreview>` as it's no longer used
- fixed upload/delete/upload not working due to file input references getting out of sync
2021-06-16 17:56:25 +01:00

43 lines
1018 B
JavaScript

import Component from '@glimmer/component';
import {action} from '@ember/object';
import {tracked} from '@glimmer/tracking';
export default class GhEditorFeatureImageComponent extends Component {
@tracked isEditingAlt = false;
@tracked isHovered = false;
@tracked captionInputFocused = false;
@tracked showUnsplashSelector = false;
get hideButton() {
return !this.isHovered && !this.args.forceButtonDisplay;
}
@action
setUploadedImage(results) {
if (results[0]) {
this.args.updateImage(results[0].url);
}
}
@action
setUnsplashImage({src, caption}) {
this.args.updateImage(src);
this.args.updateCaption(caption);
}
@action
toggleUnsplashSelector() {
this.showUnsplashSelector = !this.showUnsplashSelector;
}
@action
toggleAltEditing() {
this.isEditingAlt = !this.isEditingAlt;
}
@action
onAltInput(event) {
this.args.updateAlt(event.target.value);
}
}