mirror of
https://github.com/discourse/discourse.git
synced 2025-09-07 12:02:53 +08:00
UX: Refactor avatar upload modal for better mobile spacing
This commit is contained in:
parent
b73bd7fc1b
commit
5a3a6824c4
6 changed files with 66 additions and 33 deletions
|
@ -6,13 +6,6 @@ export default Ember.Component.extend(UploadMixin, {
|
||||||
tagName: "span",
|
tagName: "span",
|
||||||
imageIsNotASquare: false,
|
imageIsNotASquare: false,
|
||||||
|
|
||||||
@computed("uploading")
|
|
||||||
uploadButtonText(uploading) {
|
|
||||||
return uploading
|
|
||||||
? I18n.t("uploading")
|
|
||||||
: I18n.t("user.change_avatar.upload_picture");
|
|
||||||
},
|
|
||||||
|
|
||||||
validateUploadedFilesOptions() {
|
validateUploadedFilesOptions() {
|
||||||
return { imagesOnly: true };
|
return { imagesOnly: true };
|
||||||
},
|
},
|
||||||
|
|
|
@ -7,9 +7,7 @@ export default Ember.Component.extend(UploadMixin, {
|
||||||
|
|
||||||
@computed("uploading")
|
@computed("uploading")
|
||||||
uploadButtonText(uploading) {
|
uploadButtonText(uploading) {
|
||||||
return uploading
|
return uploading ? I18n.t("uploading") : I18n.t("upload");
|
||||||
? I18n.t("uploading")
|
|
||||||
: I18n.t("user.change_avatar.upload_picture");
|
|
||||||
},
|
},
|
||||||
|
|
||||||
validateUploadedFilesOptions() {
|
validateUploadedFilesOptions() {
|
||||||
|
|
|
@ -1,10 +1,14 @@
|
||||||
<label class="btn" disabled={{uploading}} title="{{i18n 'user.change_avatar.upload_title'}}">
|
<label class="btn btn-default btn-icon-text" disabled={{uploading}} title="{{i18n 'user.change_avatar.upload_title'}}">
|
||||||
{{d-icon "far-image"}} {{uploadButtonText}}
|
{{d-icon "far-image"}}
|
||||||
|
{{#if uploading}}
|
||||||
|
{{i18n 'uploading'}} {{uploadProgress}}%
|
||||||
|
{{else}}
|
||||||
|
{{i18n 'upload'}}
|
||||||
|
{{/if}}
|
||||||
|
|
||||||
<input class="hidden-upload-field" disabled={{uploading}} type="file" accept="image/*" />
|
<input class="hidden-upload-field" disabled={{uploading}} type="file" accept="image/*" />
|
||||||
</label>
|
</label>
|
||||||
{{#if uploading}}
|
|
||||||
<span>{{i18n 'upload_selector.uploading'}} {{uploadProgress}}%</span>
|
|
||||||
{{/if}}
|
|
||||||
{{#if imageIsNotASquare}}
|
{{#if 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>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="avatar-choice">
|
<div class="avatar-choice">
|
||||||
{{radio-button id="gravatar" name="avatar" value="gravatar" selection=selected}}
|
{{radio-button id="gravatar" name="avatar" value="gravatar" selection=selected}}
|
||||||
<label class="radio" for="gravatar">{{bound-avatar-template user.gravatar_avatar_template "large"}} {{{i18n 'user.change_avatar.gravatar'}}} {{user.email}}</label>
|
<label class="radio" for="gravatar">{{bound-avatar-template user.gravatar_avatar_template "large"}} <span>{{{i18n 'user.change_avatar.gravatar'}}} {{user.email}}</span></label>
|
||||||
|
|
||||||
{{d-button action=(action "refreshGravatar")
|
{{d-button action=(action "refreshGravatar")
|
||||||
title="user.change_avatar.refresh_gravatar_title"
|
title="user.change_avatar.refresh_gravatar_title"
|
||||||
|
|
|
@ -392,26 +392,65 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
.avatar-selector {
|
.avatar-selector {
|
||||||
label.radio {
|
|
||||||
padding-left: 10px;
|
|
||||||
}
|
|
||||||
.avatar-choice {
|
.avatar-choice {
|
||||||
min-height: 40px;
|
display: grid;
|
||||||
|
grid-template-columns: 2em 1fr auto;
|
||||||
|
grid-template-rows: auto auto;
|
||||||
|
align-items: center;
|
||||||
|
&:not(:last-of-type) {
|
||||||
|
margin-bottom: 0.75em;
|
||||||
|
}
|
||||||
|
span {
|
||||||
|
word-break: break-word; // Prevents long emails from breaking the modal width
|
||||||
|
}
|
||||||
|
input[type="radio"] {
|
||||||
|
margin-top: 0;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
margin-left: auto;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
label {
|
$label-max-width: 300px;
|
||||||
display: inline-block;
|
label.radio {
|
||||||
margin-right: 10px;
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
max-width: $label-max-width;
|
||||||
|
margin: 0 0.5em 0 0;
|
||||||
|
padding: 0;
|
||||||
|
.avatar {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
margin: 0 0.75em 0 0;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
#avatar-input {
|
.error {
|
||||||
width: 0;
|
|
||||||
height: 0;
|
|
||||||
overflow: hidden;
|
|
||||||
}
|
|
||||||
.avatar {
|
|
||||||
margin: 5px 10px 5px 0;
|
|
||||||
}
|
|
||||||
p.error {
|
|
||||||
color: $danger;
|
color: $danger;
|
||||||
|
margin: 0;
|
||||||
|
max-width: calc(#{$label-max-width} - 20px);
|
||||||
|
grid-column-start: 2;
|
||||||
|
grid-column-end: 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
// IE11 Support
|
||||||
|
.avatar-choice {
|
||||||
|
display: -ms-grid;
|
||||||
|
-ms-grid-columns: 2em 1fr auto;
|
||||||
|
-ms-grid-rows: auto auto;
|
||||||
|
input[type="radio"] {
|
||||||
|
-ms-grid-row: 1;
|
||||||
|
-ms-grid-column: 1;
|
||||||
|
}
|
||||||
|
label.radio {
|
||||||
|
-ms-grid-row: 1;
|
||||||
|
-ms-grid-column: 2;
|
||||||
|
}
|
||||||
|
button {
|
||||||
|
-ms-grid-row: 1;
|
||||||
|
-ms-grid-column: 3;
|
||||||
|
}
|
||||||
|
.error {
|
||||||
|
-ms-grid-row: 2;
|
||||||
|
-ms-grid-column-span: 3;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -991,7 +991,6 @@ en:
|
||||||
uploaded_avatar: "Custom picture"
|
uploaded_avatar: "Custom picture"
|
||||||
uploaded_avatar_empty: "Add a custom picture"
|
uploaded_avatar_empty: "Add a custom picture"
|
||||||
upload_title: "Upload your picture"
|
upload_title: "Upload your picture"
|
||||||
upload_picture: "Upload Picture"
|
|
||||||
image_is_not_a_square: "Warning: we've cropped your image; width and height were not equal."
|
image_is_not_a_square: "Warning: we've cropped your image; width and height were not equal."
|
||||||
|
|
||||||
change_profile_background:
|
change_profile_background:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue