Frontend: Proof of concept for image preview #2266

Merged
konrad merged 20 commits from Elscrux/vikunja:feature/image-preview into main 2024-05-25 12:11:05 +00:00
Contributor

Adds a proof of concept preview for all images inside the task itself (not related to the cover image feature). Basically it is very convenient to show all images in a task when you click on it, rather than having to individually open images when you search for a specific one or if you want to get a quick overview.
This implementation shows how it could work, but is probably not the best way to do it. Please let me know what you think!

Adds a proof of concept preview for all images inside the task itself (not related to the cover image feature). Basically it is very convenient to show all images in a task when you click on it, rather than having to individually open images when you search for a specific one or if you want to get a quick overview. This implementation shows how it could work, but is probably not the best way to do it. Please let me know what you think!
Member

Hi Elscrux!

Thank you for creating a PR!

I've deployed the frontend changes of this PR on a preview environment under this URL: https://2266-feature-image-preview--vikunja-frontend-preview.netlify.app

You can use this url to view the changes live and test them out.
You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/.

This preview does not contain any changes made to the api, only the frontend.

Have a nice day!

Beep boop, I'm a bot.

Hi Elscrux! Thank you for creating a PR! I've deployed the frontend changes of this PR on a preview environment under this URL: https://2266-feature-image-preview--vikunja-frontend-preview.netlify.app You can use this url to view the changes live and test them out. You will need to manually connect this to an api running somewhere. The easiest to use is https://try.vikunja.io/. This preview does not contain any changes made to the api, only the frontend. Have a nice day! > Beep boop, I'm a bot.
Owner

Needs some styling, but I like the idea!

Needs some styling, but I like the idea!
konrad reviewed 2024-04-11 15:40:04 +00:00
@ -67,6 +67,12 @@
{{ a.file.mime }}
</span>
</p>
<img
Owner

I would extract this out into its own component, which takes the attachment, fetches the image and shows it next to the attachment. We could extend this further to show some kind of icon for pdfs or other file types later on.

I would extract this out into its own component, which takes the attachment, fetches the image and shows it next to the attachment. We could extend this further to show some kind of icon for pdfs or other file types later on.
Author
Contributor

Good point, I did that

Good point, I did that
Owner

It also seems like the preview is not shown when the file is initially uploaded.

It also seems like the preview is not shown when the file is initially uploaded.
Elscrux force-pushed feature/image-preview from 4da881aa99 to be50d3d7b3 2024-04-26 17:05:28 +00:00 Compare
Elscrux changed title from WIP: Frontend: Proof of concept for image preview to Frontend: Proof of concept for image preview 2024-04-26 17:05:54 +00:00
Author
Contributor

@konrad

It also seems like the preview is not shown when the file is initially uploaded.

This should be fixed now.

Needs some styling, but I like the idea!

I styled it in a way so it's displaying like a table. I'm not super used to doing styling so please feel free to touch this up :)

@konrad > It also seems like the preview is not shown when the file is initially uploaded. This should be fixed now. > Needs some styling, but I like the idea! I styled it in a way so it's displaying like a table. I'm not super used to doing styling so please feel free to touch this up :)
konrad requested changes 2024-05-05 14:04:04 +00:00
Dismissed
@ -53,3 +30,1 @@
>
<span v-tooltip="formatDateLong(a.created)">
{{ formatDateSince(a.created) }}
<table class="table table-striped">
Owner

Please do not use a table for multi-column layout.

Please do not use a table for multi-column layout.
Author
Contributor

I used a grid instead now

I used a grid instead now
@ -0,0 +1,34 @@
<template>
<img
Owner

Can you make this always the same size? Use object-fit: cover; to let the image fill the container nicely.

Can you make this always the same size? Use [`object-fit: cover;`](https://developer.mozilla.org/en-US/docs/Web/CSS/object-fit) to let the image fill the container nicely.
Author
Contributor

I included it, but it didn't seem like it made a difference

I included it, but it didn't seem like it made a difference
Owner

Did you set a fixed with and height for the image?

Did you set a fixed with and height for the image?
Author
Contributor

Yes, it's at 4rem now

Yes, it's at 4rem now
@ -0,0 +29,4 @@
<style scoped lang="scss">
img {
border-radius: 0.5rem;
Owner

Please use $radius here so that the radius is consistent with other elements.

Please use `$radius` here so that the radius is consistent with other elements.
Author
Contributor

Done!

Done!
konrad marked this conversation as resolved
konrad reviewed 2024-05-15 21:38:19 +00:00
@ -436,2 +447,4 @@
}
.preview-column {
max-width: 125px;
Owner

Please use rem or an existing scss variable (same for the other occurences)

Please use `rem` or an existing scss variable (same for the other occurences)
Author
Contributor

Done

Done
konrad marked this conversation as resolved
Elscrux force-pushed feature/image-preview from 0c201cba59 to 6fa15d30ad 2024-05-15 21:58:39 +00:00 Compare
konrad requested changes 2024-05-16 07:08:12 +00:00
Dismissed
@ -0,0 +2,4 @@
<img
:src="blobUrl"
alt="Attachment preview"
style="object-fit: cover;"
Owner

Please do not use inline styles.

This image should have a rectangular fixed size, then the object-fit property will make sure it looks good.

Please do not use inline styles. This image should have a rectangular fixed size, then the `object-fit` property will make sure it looks good.
konrad requested changes 2024-05-16 07:12:30 +00:00
Dismissed
konrad left a comment
Owner

Please take another look at the failing CI.

Please take another look at the failing CI.
@ -34,3 +31,3 @@
v-for="a in attachments"
:key="a.id"
class="attachment"
class="grid-item clickable"
Owner

grid-item sounds like a child of a grid. Why not call it attachment as it was before?

`grid-item` sounds like a child of a grid. Why not call it `attachment` as it was before?
@ -437,0 +453,4 @@
max-height: 4rem;
}
.clickable {
Owner

What happens when the item is clicked?

What happens when the item is clicked?
Author
Contributor

The image preview is shown, like previously. Nothing changed in that regard. Previously, an tag was used to have the cursor change to a clickable cursor. This comment was there and I fixed it by adding this clickable class.

FIXME: don't use a for element that wraps other links / buttons

The image preview is shown, like previously. Nothing changed in that regard. Previously, an <a> tag was used to have the cursor change to a clickable cursor. This comment was there and I fixed it by adding this clickable class. > FIXME: don't use a for element that wraps other links / buttons
Owner

In terms of a11y, if it's actually clickable, it should be a button or a. Divs are usually not clickable.

In terms of a11y, if it's actually clickable, it should be a button or a. Divs are usually not clickable.
Author
Contributor

Fair. I changed this and it has a little different feel to it now. Let me know what you think!

Fair. I changed this and it has a little different feel to it now. Let me know what you think!
Owner

Looks good! Will do a proper review when I'm back at my computer, early next week.

Looks good! Will do a proper review when I'm back at my computer, early next week.
Elscrux added 2 commits 2024-05-16 12:32:53 +00:00
Rename grid-item class to attachment
Some checks failed
continuous-integration/drone/pr Build is failing
4b4c7840e2
Elscrux added 1 commit 2024-05-16 12:36:45 +00:00
Attempt to fix attachment verification
All checks were successful
continuous-integration/drone/pr Build is passing
230fef3559
Elscrux added 1 commit 2024-05-16 17:29:55 +00:00
Change attachment div to button
Some checks failed
continuous-integration/drone/pr Build is failing
7664534618
konrad requested changes 2024-05-22 20:49:33 +00:00
Dismissed
konrad left a comment
Owner

Here's what I meant with the width change:

image

However, it should keep the spaces between the actions and not add left spacing to the filename.

Here's what I meant with the `width` change: ![image](/attachments/751f00ce-4ee7-4822-a3c6-32ba19739f4c) However, it should keep the spaces between the actions and not add left spacing to the filename.
@ -43,3 +43,3 @@
cy.wait('@uploadAttachment')
cy.get('.attachments .attachments .files a.attachment')
cy.get('.attachments .attachments .files div.attachment')
Owner

This needs to be changed again to make the test pass.

This needs to be changed again to make the test pass.
@ -0,0 +30,4 @@
<style scoped lang="scss">
img {
border-radius: $radius;
object-fit: cover;
Owner

Adding a width: 100% here will make it look like what I meant (will share a screenshot later)

Adding a `width: 100%` here will make it look like what I meant (will share a screenshot later)
Owner

When uploading a file which is not previewable (like a pdf), it still shows an empty box:

image

(it also shows the "Make cover" option, but that's a problem for another day)

When uploading a file which is not previewable (like a pdf), it still shows an empty box: ![image](/attachments/a4fd38c0-c777-4494-832a-aada1379a4f3) (it also shows the "Make cover" option, but that's a problem for another day)
Author
Contributor

When uploading a file which is not previewable (like a pdf), it still shows an empty box:

image

(it also shows the "Make cover" option, but that's a problem for another day)

Imo this is intended behavior. Otherwise you would have an inconsistent spacing to the left border between different file types attachments. The idea is that everything is everything is in one column.
What could be done here is have the preview width be based on the the maximum preview width and capped to a value, so that there would be no preview field when only a pdf without preview is attached. That is why I used a table in the first place.

> When uploading a file which is not previewable (like a pdf), it still shows an empty box: > > > ![image](/attachments/a4fd38c0-c777-4494-832a-aada1379a4f3) > > (it also shows the "Make cover" option, but that's a problem for another day) Imo this is intended behavior. Otherwise you would have an inconsistent spacing to the left border between different file types attachments. The idea is that everything is everything is in one column. What could be done here is have the preview width be based on the the maximum preview width and capped to a value, so that there would be no preview field when only a pdf without preview is attached. That is why I used a table in the first place.
Elscrux added 2 commits 2024-05-23 08:26:49 +00:00
Add width: 100%
All checks were successful
continuous-integration/drone/pr Build is passing
c80d77ca69
Owner

I also think not having it spaced out would feel weird, but now there is a big empty space which feels even worse. Can you add a file icon as a placeholder? We can add other icons or preview images for more file types later on.

The attachment title should not have spacing to the left, it should be aligned with the other information below.

I also think not having it spaced out would feel weird, but now there is a big empty space which feels even worse. Can you add a file icon as a placeholder? We can add other icons or preview images for more file types later on. The attachment title should not have spacing to the left, it should be aligned with the other information below.
Elscrux added 4 commits 2024-05-24 10:47:35 +00:00
Author
Contributor

@konrad I've added a series of changes, let me know what you think, especially about the icons for the attachment actions

@konrad I've added a series of changes, let me know what you think, especially about the icons for the attachment actions
Owner

Pretty good already!

The spacing on this card should be improved so that

  1. The image has the same spacing on the top, bottom, left, right
  2. The top and bottom of the image should be on the same line as the top of the title and the bottom of the icons

image

Pretty good already! The spacing on this card should be improved so that 1. The image has the same spacing on the top, bottom, left, right 2. The top and bottom of the image should be on the same line as the top of the title and the bottom of the icons ![image](/attachments/00749f14-446f-4932-bd59-4c30ff8484c0)
konrad reviewed 2024-05-25 08:19:41 +00:00
@ -105,0 +94,4 @@
>
<icon icon="trash-alt" />
</BaseButton>
<BaseButton
Owner

This needs a tooltip

This needs a tooltip
@ -0,0 +7,4 @@
<icon
v-else
size="6x"
icon="file-image"
Owner

Can you use a simple file icon here? An image icon suggests the file is an image, which it is not.

Can you use a simple [file icon](https://fontawesome.com/icons/file?f=classic&s=regular) here? An image icon suggests the file is an image, which it is not.
Owner

Also please make the file icon in a dark gray, similar to the attachment title.

Also please make the file icon in a dark gray, similar to the attachment title.
Elscrux added 4 commits 2024-05-25 10:06:33 +00:00
Author
Contributor

@konrad all done, let me know if this works. I wasn't quite able to have the filename align to the top of the image because the cover image label is bigger that the filename text and would stick out when I tried that. I've aligned everything with equal spacing now though.

@konrad all done, let me know if this works. I wasn't quite able to have the filename align to the top of the image because the cover image label is bigger that the filename text and would stick out when I tried that. I've aligned everything with equal spacing now though.
konrad reviewed 2024-05-25 11:43:33 +00:00
konrad left a comment
Owner

Love it! One tiny little thing and then we're good to go.

Love it! One tiny little thing and then we're good to go.
@ -298,11 +307,17 @@ async function setCoverImage(attachment: IAttachment | null) {
}
.attachment {
Owner

Please make this width: 100%.

Please make this `width: 100%`.
Author
Contributor

done!

done!
Elscrux added 1 commit 2024-05-25 11:45:33 +00:00
Set attachment width to 100%
All checks were successful
continuous-integration/drone/pr Build is passing
aba045ff24
konrad approved these changes 2024-05-25 11:47:27 +00:00
konrad left a comment
Owner

Thanks!

Thanks!
konrad scheduled this pull request to auto merge when all checks succeed 2024-05-25 11:47:58 +00:00
konrad merged commit 34d69fa588 into main 2024-05-25 12:11:05 +00:00
Sign in to join this conversation.
No description provided.