Ghost/ghost/admin/app/components/settings/form-fields/publication-cover.js
Kevin Ansfield aadbb6ea1c Added unsplash button/selector to publication cover image form field
no issue

- shows an unsplash button when no image is present, opening the full unsplash selector when clicked
- behind the `improvedOnboarding` labs flag
2022-02-07 12:16:57 +00:00

44 lines
1.0 KiB
JavaScript

import Component from '@glimmer/component';
import {
IMAGE_EXTENSIONS,
IMAGE_MIME_TYPES
} from 'ghost-admin/components/gh-image-uploader';
import {action} from '@ember/object';
import {inject as service} from '@ember/service';
import {tracked} from '@glimmer/tracking';
export default class PublicationCoverFormField extends Component {
@service feature;
@service settings;
@tracked showUnsplashSelector = false;
imageExtensions = IMAGE_EXTENSIONS;
imageMimeTypes = IMAGE_MIME_TYPES;
@action
imageUploaded(results) {
if (results[0]) {
this.update(results[0].url);
}
}
@action
update(value) {
this.settings.set('coverImage', value);
this.args.didUpdate('coverImage', value);
}
@action
toggleUnsplashSelector() {
if (this.feature.improvedOnboarding) {
this.showUnsplashSelector = !this.showUnsplashSelector;
}
}
@action
setUnsplashImage({src}) {
this.update(src);
}
}