-
Notifications
You must be signed in to change notification settings - Fork 440
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/3949/allow editing before upload #3988
Changes from 1 commit
722fe35
6ef9611
661348e
07fee78
551305d
d116643
2915171
ef09c4c
9e6e2d5
c49ee85
d738442
6653eb6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,9 @@ | ||
<!-- | ||
- @copyright Copyright (c) 2019 Joas Schilling <coding@schilljs.com> | ||
- @copyright Copyright (c) 2020 Marco Ambrosini <marcoambrosini@pm.me> | ||
- | ||
- @author Joas Schilling <coding@schilljs.com> | ||
- @author Marco Ambrosini <marcoambrosini@pm.me> | ||
- | ||
- @license GNU AGPL version 3 or any later version | ||
- | ||
|
@@ -20,11 +22,9 @@ | |
--> | ||
|
||
<template> | ||
<a :href="link" | ||
<file-preview v-bind="filePreview" | ||
class="container" | ||
:class="{ 'is-viewer-available': isViewerAvailable }" | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
:class="{ 'is-viewer-available': isViewerAvailable, 'upload-editor': isUploadEditor }" | ||
@click="showPreview"> | ||
<img v-if="!isLoading && !failed" | ||
:class="previewSizeClass" | ||
|
@@ -37,8 +37,8 @@ | |
<span v-if="isLoading" | ||
class="preview loading" /> | ||
<strong>{{ name }}</strong> | ||
<ProgressBar v-if="isTemporaryUpload" :value="uploadProgress" /> | ||
</a> | ||
<ProgressBar v-if="isTemporaryUpload && !isUploadEditor" :value="uploadProgress" /> | ||
</file-preview> | ||
</template> | ||
|
||
<script> | ||
|
@@ -97,6 +97,11 @@ export default { | |
type: String, | ||
default: '', | ||
}, | ||
// True if this component is used in the upload editor | ||
isUploadEditor: { | ||
type: Boolean, | ||
default: false, | ||
}, | ||
}, | ||
data() { | ||
return { | ||
|
@@ -105,6 +110,23 @@ export default { | |
} | ||
}, | ||
computed: { | ||
// This is used to decide which outer element type to use | ||
// a or div | ||
filePreview() { | ||
if (this.isUploadEditor || this.isTemporaryUpload) { | ||
return { | ||
is: 'div', | ||
tag: 'div', | ||
} | ||
} | ||
return { | ||
is: 'a', | ||
tag: 'a', | ||
href: this.link, | ||
target: '_blank', | ||
rel: 'noopener noreferrer', | ||
} | ||
}, | ||
defaultIconUrl() { | ||
return imagePath('core', 'filetypes/file') | ||
}, | ||
|
@@ -213,20 +235,14 @@ export default { | |
image. */ | ||
display: inline-block; | ||
|
||
/* Show a hover colour around the preview when navigating with the | ||
* keyboard through the file links (or hovering them with the mouse). */ | ||
&:hover, | ||
&:focus, | ||
&:active { | ||
.preview { | ||
background-color: var(--color-background-hover); | ||
border-radius: 16px; | ||
|
||
/* Trick to keep the same position while adding a padding to show | ||
* the background. */ | ||
box-sizing: content-box !important; | ||
padding: 10px; | ||
margin: -10px; | ||
} | ||
&:hover, | ||
&:focus { | ||
background-color: var(--color-background-hover); | ||
/* Trick to keep the same position while adding a padding to show | ||
* the background. */ | ||
box-sizing: content-box !important; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. While this looks good in the upload editor in my opinion the look in the messages list has regressed. Therefore I would suggest to have both the previous style and the new one, and use one or the other depending on whether the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What do you think has regressed in particular? Before there was an unneeded hover feedback on the preview itself that partially covered the sender's username. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think that the hover feedback should be there, as it shows the user that she can interact with the file. The problem is that the whole message is "highlighted" on hover when showing the reply button, and that hides the specific feedback for the file. Anyway, I would be fine with removing the hover feedback on the file due to that overlap (but I would prefer to find a better solution nevertheless).
I know, it has been haunting me since I added it :-P However, even if it covers the sender's username I prefer that small, focused frame on the file: Rather than highlighting the whole message body (even if it actually matches the real clickable area): For me the previous version feels and looks much better when navigating with the keyboard. Also the change is not directly related to editing the upload, so in any case I would address it in a separate pull request too. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So this is the current behavior (before this pr): So you get the big hover feedback of the message but no clickability unless you hover the preview, and since the hover color is the same, you get the hover feedback of the preview only through unwanted stuff:
The keyboard navigation is a bug with how messages hover feedback is implemented. For a reference of how it should really look refer to the mouse navigation feedback. Plus, I think that a bigger click area is generally better, since that space is unused anyway... I implemented the change in this pr because I'm adapting the filepreview component. |
||
} | ||
|
||
.preview { | ||
|
@@ -244,6 +260,8 @@ export default { | |
/* As the file preview is an inline block the name is set as a block to | ||
force it to be on its own line below the preview. */ | ||
display: block; | ||
overflow: hidden; | ||
white-space: nowrap; | ||
} | ||
|
||
&:not(.is-viewer-available) { | ||
|
@@ -253,4 +271,10 @@ export default { | |
} | ||
} | ||
|
||
.upload-editor { | ||
max-width: 160px; | ||
max-height: 160px; | ||
margin: 10px; | ||
} | ||
|
||
</style> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file really bothers me. The shared part is actually so little, that it should just be 2 maintainable subcomponents instead.