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

[SPIKE] Dropzone interface for file upload component #3832

Closed
wants to merge 2 commits into from

Conversation

querkmachine
Copy link
Member

@querkmachine querkmachine commented Jun 19, 2023

One of the items flagged in the recent audit of Frontend was the lack of a user interface indicating that files could be dragged and dropped into the File Upload component.

Putting aside that our file upload component is the browser's native control with only light style customisations (and the usability issue is probably the onus of browser vendors, not us), I figured I'd do a technical spike of how we could do something about it in Frontend.

This is principally a technical prototype. It is intentionally very basic and ugly, and probably not as accessible as it could be, but it does (basically) what it says on the tin.

Screenshots

Initial state

Appears as a standard, native file input.

image

With a file dragged over the viewport

A previously hidden div with a dashed grey border and instructions that the user can drop a file here are revealed. The native file input is hidden.

image

With a file dragged over the dropzone

The div with instructions gains a more prominently coloured border when the user's cursor is within the bounds of it, indicating that it is safe to drop the file.

image

After a file is dropped

The component returns to only showing the native file input, with the value correctly set.

image

@querkmachine querkmachine self-assigned this Jun 19, 2023
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3832 June 19, 2023 18:16 Inactive
@querkmachine querkmachine force-pushed the spike-file-upload-drag-and-drop branch from 7e73066 to d5b4d13 Compare June 21, 2023 09:05
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3832 June 21, 2023 09:05 Inactive
@govuk-design-system-ci govuk-design-system-ci temporarily deployed to govuk-frontend-pr-3832 June 28, 2023 10:23 Inactive
@owenatgov
Copy link
Contributor

I'm aware this is in draft however an initial thought: Could the "drag here" UI be on the component by default? That would save the need for js at all. Probably needs a designer to sus this out but this is still just a spike so it's not urgent.

@querkmachine
Copy link
Member Author

querkmachine commented Jun 29, 2023

@owenatgov It absolutely could, that's how I've built them in the past when on greenfield projects. In this case, I was looking to avoid potential breaking changes, but I suppose that's a practicality I shouldn't worry about too much in a spike.

Edit: Actually, you do still need JS if you want to enhance it in certain ways, such as presenting the name of the file(s) back to the user, or applying a visual change when the user drags a file over the droppable area (as opposed to on any kind of hover).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants