-
Notifications
You must be signed in to change notification settings - Fork 110
Conversation
@toxamiz Thanks for tackling this component! It will probably take us a week or so to go over but face value - looking good 👍 |
"@gov.au/core": "^3.0.0", | ||
"@gov.au/buttons": "^3.0.6" | ||
}, | ||
"devDependencies": { |
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.
We pushed through a pretty large change only yesterday where we significantly bumped up the dependencies we use across all packages / scripts.
It's bad timing I'd say, can you please rebase/merge this branch with the latest develop
Hey @toxamiz this is a great first PR! A few things I picked up:
<div class="au-file-upload">
<label class="au-label">Attach drivers license</label>
<input class="au-file-upload__input" type="file" />
<button class="au-btn au-btn--secondary">Choose file</button>
<span class="No file chosen" />
</div> So it could look something like this in the context of the form: It could even be worth using
We add a .no-js class when javascript is not loaded on a page. You can use a selector that goes something like this: .au-file-upload {
.no-js & {
//insert styles here
} This is a good example as well: design-system-components/packages/side-nav/src/sass/_module.scss Lines 72 to 75 in bb844e3
This can be confusing, especially if this is contained within a form that has a primary button that submits it. I would probably remove that functionality to remove altogether and just stick to the default functionality for this, which replaces the previous files selected with the new files selected. Also we make sure all of our components are supported back to IE8. I'm not sure if multiple file feature is supported in < IE10? If not, do you know of any work arounds?
Let me know if this doesn't make sense. |
|
||
<h1>Test: file-upload</h1> | ||
|
||
<div class="au-file-upload js-upload-1"> |
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.
can we use id instead of class for the js-upload-1
selector
</div> | ||
|
||
|
||
<div class="au-file-upload js-upload-2"> |
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.
<div class="au-file-upload js-upload-2"> | |
<div class="au-file-upload" id="js-upload-2"> |
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.
Sure. It uses querySelector
, you can pass an id selector AU.fileUpload('#js-upload-2')
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.
Yea I saw that, but the main reason is because we won't use the .js-upload-2
selector on another element, so it's better to use #js-upload-2
if that makes sense.
ca54159
to
b8555c6
Compare
Branch rebase on latest @adamzerella Do i need to resolve conflicts in |
I'm not sure. Using label is a native way for associating with input, so don't need to call <div class="au-file-upload" id="js-drivers-license">
<label class="au-label">Attach drivers license</label>
<input class="au-file-upload__input" id="drivers-license" type="file" />
<!-- hide below when no js -->
<label class="au-btn au-btn--secondary au-file-upload__label" for="drivers-license">Choose file</label>
<span class="No file chosen" />
</div>
Yes, thanks, i forgot about hiding elements.
Primary button there only for example :) Unfortunately multiple file feature, accept and drag&drop is not supported in < IE10. You can inform user to choose file one by one and add an new input after user select file. It seem like completely separate package specific for that browsers. Also i think u can't access file data because FileAPI is not supported, so cant count size and etc.
It depends on functionality, it can be even better to have simple and small single select component and multiple select component with different modes, file list management, upload progress bars, other cool fireworks. And some "core" module between them. Of course we could release an alpha version just need to decide features. |
@toxamiz I would accept the latest develop and then do: |
@toxamiz thanks for getting back! If you can find me an examples/research that supports using a label instead of a button for clicking to upload files, I'd be glad to accept this approach. Yes lets split this PR up and focus on releasing a file upload component for a single file. I think that would provide good user value and is a lot more simple to build with fewer edge cases. What do you think? |
@adamzerella OK, thanks
I don't think there are researches "button vs label on input file". If you want add a caption on form control better use label tag than any "label like" element. According to this label for form control actually works like button providing a click events to associated form control. Almost any articles about custom styling file input uses styles on label. Buttons uses for other features.
OK, lets focus on single file upload. So what do we need?
|
But yea sorry I probably didn't word myself properly. What I mean to say is that it's not intuitive to click on text to trigger an action. I know labels are used with a A picture from an article on affordance to better illustrate what I'm trying to say. I would also check out: https://design-system.service.gov.uk/components/file-upload/ |
@sukhrajghuman I think the main accessibility issue with file upload is that native upload provide it's own button and text. I think the better way is without js it should both label and native input. Only with js it converts into button and visually hidden input + some dynamically added element showing which file uploaded. It's not enough to add some css classes for visual appearance |
@toxamiz yes but that above example could potentially be confusing in the context of a form with a primary submit button. Hence why in my first example I used the It's not an easy problem. There are so many edge cases. I will have to talk with our accessibility team for more guidance. Right now I'm thinking we just stick with the browser default file upload, and add some additional styling (fonts, spacing, errors, focus states etc.) That way we don't have to worry about javascript either. |
That would be great.
Good idea. Is there any sketches? |
d005da1
to
62fcdf5
Compare
Not at this stage sorry. I was basing this off the gov uk implementation of the file upload component, as mentioned in my previous post. Will keep you in the loop |
File upload component draft. #613
Contains basic implementation on vanilla module for single file upload and multiple upload with display of selected files.
To do: