A11Y: avatar upload button should be focusable (#23575)
This commit is contained in:
parent
45adb22abe
commit
3340852328
|
@ -1,24 +1,20 @@
|
||||||
<label
|
<input
|
||||||
class="btn btn-default btn-icon-text"
|
class="hidden-upload-field"
|
||||||
disabled={{this.uploading}}
|
disabled={{this.uploading}}
|
||||||
title={{i18n "user.change_avatar.upload_title"}}
|
type="file"
|
||||||
|
accept="image/*"
|
||||||
|
aria-hidden="true"
|
||||||
|
/>
|
||||||
|
<DButton
|
||||||
|
@translatedLabel={{this.uploadLabel}}
|
||||||
|
@icon="far-image"
|
||||||
|
@disabled={{this.uploading}}
|
||||||
|
@action={{this.chooseImage}}
|
||||||
|
@title="user.change_avatar.upload_title"
|
||||||
|
class="btn-default"
|
||||||
data-uploaded={{this.customAvatarUploaded}}
|
data-uploaded={{this.customAvatarUploaded}}
|
||||||
data-avatar-upload-id={{this.uploadedAvatarId}}
|
data-avatar-upload-id={{this.uploadedAvatarId}}
|
||||||
>
|
/>
|
||||||
{{d-icon "far-image"}}
|
|
||||||
{{#if this.uploading}}
|
|
||||||
{{i18n "uploading"}}
|
|
||||||
{{this.uploadProgress}}%
|
|
||||||
{{else}}
|
|
||||||
{{i18n "upload"}}
|
|
||||||
{{/if}}
|
|
||||||
<input
|
|
||||||
class="hidden-upload-field"
|
|
||||||
disabled={{this.uploading}}
|
|
||||||
type="file"
|
|
||||||
accept="image/*"
|
|
||||||
/>
|
|
||||||
</label>
|
|
||||||
|
|
||||||
{{#if this.imageIsNotASquare}}
|
{{#if this.imageIsNotASquare}}
|
||||||
<div class="warning">{{i18n "user.change_avatar.image_is_not_a_square"}}</div>
|
<div class="warning">{{i18n "user.change_avatar.image_is_not_a_square"}}</div>
|
||||||
|
|
|
@ -2,6 +2,8 @@ import Component from "@ember/component";
|
||||||
import { isBlank } from "@ember/utils";
|
import { isBlank } from "@ember/utils";
|
||||||
import UppyUploadMixin from "discourse/mixins/uppy-upload";
|
import UppyUploadMixin from "discourse/mixins/uppy-upload";
|
||||||
import discourseComputed from "discourse-common/utils/decorators";
|
import discourseComputed from "discourse-common/utils/decorators";
|
||||||
|
import { action } from "@ember/object";
|
||||||
|
import I18n from "I18n";
|
||||||
|
|
||||||
export default Component.extend(UppyUploadMixin, {
|
export default Component.extend(UppyUploadMixin, {
|
||||||
type: "avatar",
|
type: "avatar",
|
||||||
|
@ -31,4 +33,16 @@ export default Component.extend(UppyUploadMixin, {
|
||||||
data(user_id) {
|
data(user_id) {
|
||||||
return { user_id };
|
return { user_id };
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@discourseComputed("uploading", "uploadProgress")
|
||||||
|
uploadLabel() {
|
||||||
|
return this.uploading
|
||||||
|
? `${I18n.t("uploading")} ${this.uploadProgress}%`
|
||||||
|
: I18n.t("upload");
|
||||||
|
},
|
||||||
|
|
||||||
|
@action
|
||||||
|
chooseImage() {
|
||||||
|
this.fileInputEl.click();
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue