0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-02-24 23:48:13 -05:00

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
This commit is contained in:
Kevin Ansfield 2022-02-07 12:16:57 +00:00
parent bbd4c452b9
commit aadbb6ea1c
2 changed files with 33 additions and 3 deletions

View file

@ -29,9 +29,16 @@
</button>
</div>
{{else}}
<button id="publication-cover" type="button" class="gh-btn gh-btn-white self-start" {{on "click" uploader.triggerFileDialog}} data-test-image-upload-btn="coverImage">
<span>Upload cover</span>
</button>
<div class="self-start">
<button id="publication-cover" type="button" class="gh-btn gh-btn-white" {{on "click" uploader.triggerFileDialog}} data-test-image-upload-btn="coverImage">
<span>Upload cover</span>
</button>
{{#if (feature "improvedOnboarding")}}
<button type="button" class="gh-btn gh-btn-white w10" {{on "click" this.toggleUnsplashSelector}} aria-label="Select photo from Unsplash">
<span>{{svg-jar "unsplash"}}</span>
</button>
{{/if}}
</div>
{{/if}}
<div class="dn">
<GhFileInput
@ -45,4 +52,11 @@
</div>
</div>
</GhUploader>
{{#if this.showUnsplashSelector}}
<GhUnsplash
@select={{this.setUnsplashImage}}
@close={{this.toggleUnsplashSelector}}
/>
{{/if}}
</div>

View file

@ -5,10 +5,14 @@ import {
} 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;
@ -24,4 +28,16 @@ export default class PublicationCoverFormField extends Component {
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);
}
}