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

[Form] file input styles #105

Closed
y0hami opened this issue Sep 4, 2018 · 18 comments
Closed

[Form] file input styles #105

y0hami opened this issue Sep 4, 2018 · 18 comments
Assignees
Labels
lang/css Anything involving CSS tag/new-component New UI components type/feat Any feature requests or improvements
Milestone

Comments

@y0hami
Copy link
Member

y0hami commented Sep 4, 2018

Add file upload input styles as mentioned here Semantic-Org/Semantic-UI#403, would also be cool to implement as a module and have drag & drop functionality.

@y0hami y0hami added type/feat Any feature requests or improvements lang/css Anything involving CSS lang/javascript Anything involving JavaScript labels Sep 4, 2018
@lubber-de
Copy link
Member

Any preferences or ideas where we can probably adopt the functionality from an existing open source library?

https://www.sitepoint.com/10-jquery-file-uploads/ lists the (even today) most used libraries afaik.

@y0hami
Copy link
Member Author

y0hami commented Oct 4, 2018

@lubber-de We had a talk about making the upload input into a module instead of just a style in the form. Therefore we can make drag and drop support along with some nice functions for doing uploads.

@Foorack
Copy link

Foorack commented May 15, 2019

At this point even a simple style would be sufficient. Anything is better than nothing at all. 🙂

@lubber-de
Copy link
Member

The absolute minimum is only to hide the file input element itself, as you can design your fileupload button using form labels as you desire for the time being

<form class="ui form">
  <label for="textupload" class="ui icon button">
    <i class="file icon"></i>
      Open any file
  </label>
  <input type="file" id="textupload" class="ui file input">
</form>
.ui.file.input {
  display: none;
}

See https://jsfiddle.net/jsagx3v9/1/

@y0hami y0hami added the Hacktoberfest Issues for Hacktoberfest! label Oct 3, 2019
@aexvir
Copy link
Contributor

aexvir commented Oct 18, 2019

@hammy2899 @lubber-de I can take this one. What would be the acceptable PR for this?

@y0hami
Copy link
Member Author

y0hami commented Oct 18, 2019

@aexvir Go for it 👍

We just want basic styles for the file input button like the comment from @lubber-de above

@y0hami
Copy link
Member Author

y0hami commented Oct 18, 2019

@aexvir We want to add this as a module but adding the styles will be a start.

@aexvir
Copy link
Contributor

aexvir commented Oct 18, 2019

Alright, so I'll go just for styles on the first PR and afterwards we can make an issue for adding more functionality to it, with specific requirements that will be added as another PR. Does that make sense?

@y0hami
Copy link
Member Author

y0hami commented Oct 18, 2019

@aexvir Yeah that's fine 👍

@aexvir
Copy link
Contributor

aexvir commented Oct 19, 2019

So... I'm not that sure about this tbh. I can't get anything much better than @lubber-de 's solution, which is literally just a three line code change, as all the work is done in the label and not the input itself.

Webkit does allow some more fantasy with the input styling but I don't think that's an acceptable solution.

For all the rest of the stuff we'll need javascript, even for the basic stuff as showing the uploaded filename.

Should I just submit the PR with this three line change for hiding the file input?

If not, let's define a specification for the upload input, which features we'd like to have from the beginning and I'll work on that.

@lubber-de lubber-de removed the Hacktoberfest Issues for Hacktoberfest! label Oct 31, 2019
@ioOiOiOoi
Copy link

ioOiOiOoi commented Feb 18, 2020

I use the following method.

<div class="ui grid">
<div class="column">
<label class="file-upload">
       <input name="file" type="file" id="files" class="file-input">
       <span class="ui button">Choose file</span>
</label>
</div>
</div>
.file-input {
    position: absolute;
    top: 0;
    left: 0;
    opacity: 0;
    outline: 0;
    width: 100%;
    height: 100%;
}

@andrewleith
Copy link

This may not be accessible - I am not able to use the keyboard with this solution.

@ko2in
Copy link
Member

ko2in commented Jul 3, 2020

This will also attempt to select the file when you click anywhere next to the button unless you set position: relative to label.

@lubber-de already suggested the better method.

@andrewleith
Copy link

You mean https://jsfiddle.net/jsagx3v9/1/? That one isn't keyboard accessible either. I'm trying to figure out if I can make it be though.

@ko2in
Copy link
Member

ko2in commented Jul 3, 2020

@andrewleith No. I am not talking about keyboard accessibility. The method @ioOiOiOoi will trigger the file input by clicking anywhere next to the label as the same height as the label.

@lubber-de
Copy link
Member

lubber-de commented Jul 3, 2020

@andrewleith Here is the same fiddle but now it's accessible to keyboard strokes 🙂
The only difference: Put the file input off canvas instead of hiding it.
So instead of display:none;, you use top:-99999px;
This way the focus of the label will automatically focus the (still visible, thus focussable, but moved off screen) fileinput. When you now press space/enter the file explorer opens as expected
https://jsfiddle.net/lubber/eah9pr4q/38/

@andrewleith
Copy link

Amazing! Thank you!

@lubber-de lubber-de self-assigned this Sep 15, 2021
@lubber-de lubber-de added this to the 2.9.0 milestone Sep 15, 2021
@lubber-de
Copy link
Member

File input styling is now prepared by #2145

@lubber-de lubber-de added state/has-pr An issue which has a related PR open and removed lang/javascript Anything involving JavaScript labels Oct 29, 2021
@lubber-de lubber-de added tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build and removed state/has-pr An issue which has a related PR open labels Nov 2, 2021
@lubber-de lubber-de removed the tag/next-release/nightly Any issue which has a corresponding PR which has been merged and is available in the nightly build label Oct 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lang/css Anything involving CSS tag/new-component New UI components type/feat Any feature requests or improvements
Projects
None yet
Development

No branches or pull requests

7 participants