-
Notifications
You must be signed in to change notification settings - Fork 12
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
Conversation
…Update more styles
…instead of the base label
# Conflicts: # packages/web-components/package.json
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.
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; |
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.
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?
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.
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.
packages/web-components/src/components/va-file-input/va-file-input.tsx
Outdated
Show resolved
Hide resolved
@@ -114,6 +127,29 @@ export class VaFileInput { | |||
this.el.shadowRoot.getElementById('fileInputField').click(); | |||
}; | |||
|
|||
private removeFile = () => { | |||
this.file = undefined; |
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.
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> |
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.
I think that we can still use the USWDS module for usa-sr-only
. That is not specific to file input.
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.
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> |
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.
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?
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.
I am using the USWDS styles for hint and error again
@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. |
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. |
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! |
A couple other UX things:
Figma Storybook |
@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? |
@LWWright7 Should we create a follow-up ticket to update the icon then? cc @danbrady |
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.
@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.
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. |
@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
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.webmBecause it already exists like this in staging, regardless of how brief it renders, we'll want to add it here. Regarding the file iconI'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 |
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.
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?
packages/web-components/src/components/va-file-input/va-file-input.scss
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/va-file-input/va-file-input.scss
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/va-file-input/va-file-input.scss
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/va-file-input/va-file-input.scss
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/va-file-input/va-file-input.scss
Outdated
Show resolved
Hide resolved
packages/web-components/src/components/va-file-input/va-file-input.scss
Outdated
Show resolved
Hide resolved
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'; | ||
} | ||
} | ||
|
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.
packages/web-components/src/components/va-file-input/va-file-input.tsx
Outdated
Show resolved
Hide resolved
* @returns {string} The file size formatted as a string with the appropriate unit. | ||
*/ | ||
private formatFileSize = (filesSize): string => { | ||
const units = ['B', 'KB', 'MB', 'GB', 'TB']; |
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.
I really hope no one tries to upload a file that is x GBs or TBs large lol
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.
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> |
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.
@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.
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.
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)
Updated design:
Updated design with long name and in uploading state:
Updated design with long name attached:
For Reference:
USWDS with Long File Name:
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!
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 is great, thanks @danbrady!
…ame and file size as 2 separate lines
… show as default icon for other file types
… from shifting when switching files
# Conflicts: # packages/web-components/package.json # packages/web-components/src/components/va-file-input/va-file-input.scss
# Conflicts: # packages/web-components/package.json
# Conflicts: # packages/web-components/package.json
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.
Changes look good. Thanks for your work on this @nickjg231 and @danbrady
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
Screenshots
Base component:
File uploaded:
Error message:
Different size header:
Additional Info:
Acceptance criteria
Definition of done