Skip to content
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

va-file-input: new design variation #1142

Merged
merged 26 commits into from
May 23, 2024
Merged

va-file-input: new design variation #1142

merged 26 commits into from
May 23, 2024

Conversation

nickjg231
Copy link
Contributor

@nickjg231 nickjg231 commented May 6, 2024

Chromatic

https://2642-file-input-update--65a6e2ed2314f7b8f98609d8.chromatic.com

Description

Updates the va-file-input V3 component with new designs and features. These include:

Closes department-of-veterans-affairs/vets-design-system-documentation#2642

QA Checklist

  • Component maintains 1:1 parity with design mocks
  • Text is consistent with what's been provided in the mocks
  • Component behaves as expected across breakpoints
  • Accessibility expert has signed off on code changes (if applicable. If not applicable provide reason why)
  • Designer has signed off on changes (if applicable. If not applicable provide reason why)
  • Tab order and focus state work as expected
  • Changes have been tested against screen readers (if applicable. If not applicable provide reason why)
  • New components are covered by e2e tests; updates to existing components are covered by existing test suite
  • Changes have been tested in vets-website using Verdaccio (if applicable. If not applicable provide reason why)

Screenshots

Base component:
image

File uploaded:
image

Error message:
image

Different size header:
image

Additional Info:
image

Acceptance criteria

  • QA checklist has been completed
  • Screenshots have been attached that cover desktop and mobile screens

Definition of done

  • Documentation has been updated, if applicable
  • A link has been provided to the originating GitHub issue (or connected to it via ZenHub)

@nickjg231 nickjg231 added the minor For a minor Semantic Version change label May 6, 2024
@nickjg231 nickjg231 self-assigned this May 6, 2024
@nickjg231 nickjg231 marked this pull request as ready for review May 8, 2024 16:08
@nickjg231 nickjg231 requested a review from a team as a code owner May 8, 2024 16:08
Copy link
Contributor

@jamigibbs jamigibbs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this Nick! Can you please add a link to the Figma designs in the PR description?

@Element() el: HTMLElement;
@State() file?: File;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know we had discussed keeping file management/state out of the component and having teams do that in their apps instead. But maybe there's a specific reason it's needed here. Do you mind providing some more context?

Copy link
Contributor Author

@nickjg231 nickjg231 May 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Edit: I think this is still necessary here, at least for constructing labels. Now, we are creating the labels for filename and file size instead of the USWDS script. Keeping a reference locally will let us do that a lot easier and more cleanly IMO.

@@ -114,6 +127,29 @@ export class VaFileInput {
this.el.shadowRoot.getElementById('fileInputField').click();
};

private removeFile = () => {
this.file = undefined;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be better to assign this as null instead of undefined?

{error && (
<Fragment>
<span class="usa-sr-only">{i18next.t('error')}</span>
<span class="usa-error-message">{error}</span>
<span class="sr-only">{i18next.t('error')}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think that we can still use the USWDS module for usa-sr-only. That is not specific to file input.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @nickjg231 Please import the USWDS module for usa-sr-only. The sr-only class will be going away with Formation.

Here is an example:
https://github.com/department-of-veterans-affairs/component-library/blob/main/packages/web-components/src/components/va-checkbox/va-checkbox.scss#L3

<span class="usa-sr-only">{i18next.t('error')}</span>
<span class="usa-error-message">{error}</span>
<span class="sr-only">{i18next.t('error')}</span>
<span>{error}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usa-error-message also is not specific to file input. Do the VA designs diverge from the USWDS error styles? If not, can we continue to use the module that contains that class?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am using the USWDS styles for hint and error again

@LWWright7
Copy link

@nickjg231 - just a few minor things..... there is a black border line missing around the blue background that appears in the design. The only other thing I'm seeing is the difference in the icon. For the design, I'm not sure where @danbrady got that icon, as I'm not seeing it in our icon library in Figma under Font Awesome or USWDS icons, so it may be a custom .svg icon.

@jamigibbs
Copy link
Contributor

Are there examples in Storybook to preview for the upload indicator or additional info slot like shown in the ticket's screenshots? I wasn't sure how to reproduce that to test it.

Screenshot 2024-05-08 at 1 46 00 PM

@nickjg231
Copy link
Contributor Author

Are there examples in Storybook to preview for the upload indicator or additional info slot like shown in the ticket's screenshots? I wasn't sure how to reproduce that to test it.

Screenshot 2024-05-08 at 1 46 00 PM

In the engineering channel the other day, we came to the consensus that we actually should not use the progress bar in this component. The upload in our component doesn't upload when the user selects a file, rather when the user submits the form.

When the user selects a file on the page, the input acts as a pointer to the user's file system and has a little bit of metadata. If we wanted to show the progress bar here, it wouldn't really be in an uploading state long enough to even see the progress bar. Then the user generally moves on in the form and the actual file upload happens at the end. This may mean they don't even see the progress bar upload. In addition, within the va-file-input, we have no knowledge of the form we're in or its events, like if it has been submitted. We would need to add extra props to manage the state, then work with the backend to actually have some sort of value returned from the server. At this point, it seems like it won't behave in a way that's intuitive to the user and would be confusing to handle. We can have a further discussion in the engineers channel if you'd like!

@jamigibbs
Copy link
Contributor

A couple other UX things:

  1. This icon doesn't look correct compared to Figma:

Screenshot 2024-05-08 at 2 46 46 PM

  1. The padding in the header and hint text is not matching Figma

Figma
Screenshot 2024-05-08 at 2 49 56 PM

Storybook
Screenshot 2024-05-08 at 2 49 52 PM

  1. I think this text color for the file size might be too dark?

Figma

Screenshot 2024-05-08 at 2 52 18 PM

Storybook

Screenshot 2024-05-08 at 2 52 12 PM

@jamigibbs
Copy link
Contributor

In the engineering channel the other day, we came to the consensus that we actually should not use the progress bar in this component.

@nickjg231 Do we need to update the designs then? Or is it possible then for teams to add the progress component into the va-file-input slot in order to match the designs?

@nickjg231
Copy link
Contributor Author

A couple other UX things:

  1. This icon doesn't look correct compared to Figma:

Screenshot 2024-05-08 at 2 46 46 PM

  1. The padding in the header and hint text is not matching Figma

Figma Screenshot 2024-05-08 at 2 49 56 PM

Storybook Screenshot 2024-05-08 at 2 49 52 PM

  1. I think this text color for the file size might be too dark?

Figma

Screenshot 2024-05-08 at 2 52 18 PM

Storybook

Screenshot 2024-05-08 at 2 52 12 PM

@jamigibbs

  1. I had Lucas look into the icon. He says it's a custom file that Dan used on Figma, and isn't something that exists in our project. The one I chose is the closest icon we have to the one in the mockups, and Lucas seems okay with that.
  2. This padding above the va-card is being updated now
  3. This color difference was a typo, this is fixed now

@nickjg231
Copy link
Contributor Author

In the engineering channel the other day, we came to the consensus that we actually should not use the progress bar in this component.

@nickjg231 Do we need to update the designs then? Or is it possible then for teams to add the progress component into the va-file-input slot in order to match the designs?

@jamigibbs This may require some more discussion with the team, as I didn't think about allowing users to do this with the slot. The only thing I worry is that teams may use slightly different styles across forms so the progress bar could be slightly inconsistent, but otherwise it would take the burden off of us.

For now, I think this should be merged without references to the progress bar in the code, then we can discuss with designers. @LWWright7 what do you think?

@jamigibbs
Copy link
Contributor

I had Lucas look into the icon. He says it's a custom file that Dan used on Figma, and isn't something that exists in our project. The one I chose is the closest icon we have to the one in the mockups, and Lucas seems okay with that.

@LWWright7 Should we create a follow-up ticket to update the icon then? cc @danbrady

Copy link
Contributor

@micahchiang micahchiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@nickjg231 @jamigibbs - I haven't finished my review yet, but there are couple things out there that I think need to be looked at before merging, so I'm requesting changes until those things are resolved. I'll follow up with a longer comment here in a second.

@danbrady
Copy link

danbrady commented May 8, 2024

After a file is attached, the "icon" is actually a preview of that file (like a thumbnail). This functionality exists already in the USWDS File Input as well as the current v3 version that Andrew worked on. I'm not sure of the exact logic behind it, but my understanding is if the file can have a preview (because it is an image of some type) it will. However, it shows alternate preview images if the attachment is a different "non-previewable" file type.

@micahchiang
Copy link
Contributor

@nickjg231 @jamigibbs - I haven't finished my review yet, but I'd like to chime in on some of the thoughts already out there.

Regarding the loading indicator

In the engineering channel the other day, we came to the consensus that we actually should not use the progress bar in this component. The upload in our component doesn't upload when the user selects a file, rather when the user submits the form.

Maybe this was part of the discussion after I had to leave the mob session on Monday, so I'm not sure if I'm missing some additional context here. The loading indicator is definitely part of the file input designs in Figma. It's also functionality that is current on staging. The following screen cap is from the 10-10EZ Form:

Screencast.from.05-08-2024.01.36.28.PM.webm

Because it already exists like this in staging, regardless of how brief it renders, we'll want to add it here.

Regarding the file icon

I'm fine with @LWWright7's sign off here since he's a designer, but I'd like to make sure things are consistent between what's in here and what exists in Figma. So, if we're going with the icon shown in the screenshots here, then I'd appreciate it if the designs in Figma were updated to avoid confusion. If it turns out for some reason that the custom icon @danbrady used was intentional, then we need to add it to va-icon and update the icon used in this component. I'm fine with whatever.

Copy link
Contributor

@micahchiang micahchiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Requesting changes for the following reasons:

  • we should use our design tokens where we can. I left comments where they can be used.
  • we should be supporting loading indicator since it's part of the Figma designs unless @danbrady and @LWWright7 say otherwise.
  • I think we're meant to be displaying preview thumbnails instead of static icons
  • we need to decide how to truncate long file names. i.e. if a file name is longer than 25 characters should we display a truncated version of it?

Comment on lines 130 to 152
private removeFile = () => {
this.file = null;
this.uploadStatus = 'idle';
}

private changeFile = () => {
if (this.fileInputRef) {
this.fileInputRef.click();
}
}

private handleDrop = (event: DragEvent) => {
event.preventDefault();
event.stopPropagation();

const files = event.dataTransfer.files;
if (files.length > 0) {
this.file = files[0];
this.vaChange.emit({ files: [this.file] });
this.uploadStatus = 'success';
}
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if our web component has always been this way so forgive me if I'm missing something, but with file upload, I'd expect to see files stored in a FileList on the input. For some reason it's returning an empty list after upload:

image

* @returns {string} The file size formatted as a string with the appropriate unit.
*/
private formatFileSize = (filesSize): string => {
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I really hope no one tries to upload a file that is x GBs or TBs large lol

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed, that would be quite an edge case! However, it might be wise to consider implementing a limit on file size or handling such scenarios gracefully to prevent potential issues. What are your thoughts?

<va-card class="va-card">
<div class="file-info-section">
<va-icon icon="file_present" size={5} class="file-icon"></va-icon>
<span class="file-label">{file.name}</span>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@danbrady @LWWright7 - We need to decide on how to approach name truncation for files with long names. Would appreciate some design input here, and potentially an update to the figma specs to reflect name truncation.

Currently long names extend past the card:
Screenshot from 2024-05-08 13-15-52

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I think we can handle long file names by splitting the file name and the uploading label / file size to be on different lines. In other words, the file name will be on top line and then either the "Uploading..." label or the file weight on the next line. If the file name is long, it should wrap, and not truncate it, so it does not break outside the boundaries of the card. (This stays inline with what USWDS does.) Some designs below for reference:

Previous design:

(This didn't factor long file names)
image


Updated design:

image

Updated design with long name and in uploading state:

image

Updated design with long name attached:

image

For Reference:
USWDS with Long File Name:
Screenshot 2024-05-13 at 1 56 32 PM

NOTE: The default body text has a line-height that's too much for this component. So instead I used line-height-2 (1.15) for the file name and size text, which renders 16.96px text to have 19.504 line-height.

I've updated the design files with this. Hit my up with any questions!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is great, thanks @danbrady!

Copy link
Contributor

@micahchiang micahchiang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changes look good. Thanks for your work on this @nickjg231 and @danbrady

@nickjg231 nickjg231 merged commit 3c2269a into main May 23, 2024
9 checks passed
@nickjg231 nickjg231 deleted the 2642-file-input-update branch May 23, 2024 15:18
@jamigibbs jamigibbs changed the title 2642 file input update va-file-input: new design variation May 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
minor For a minor Semantic Version change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

File Input - Update v3 component to align with Figma
8 participants