-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Restyle file uploads to fit in with modern forms UI #7452
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
66d8916
Init
janfaracik 1a7481e
Merge branch 'master' into style-file-upload
janfaracik 31a74c3
Update file-upload.less
janfaracik fba0f4d
Update style.less
janfaracik c32cdee
Fix text truncation
janfaracik 3cc5cb3
Add margin to the button
janfaracik 61274c3
Add workaround for Firefox not supporting pseudo elements in inputs
janfaracik 429991d
Merge branch 'master' into style-file-upload
timja 6a706cb
Merge branch 'master' into style-file-upload
timja 1dae824
Add jelly tag
timja d05ab4e
Update core/src/main/resources/lib/form/file.jelly
timja File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<!-- | ||
The MIT License | ||
Copyright (c) 2022, Jenkins project contributors | ||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
The above copyright notice and this permission notice shall be included in | ||
all copies or substantial portions of the Software. | ||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
THE SOFTWARE. | ||
--> | ||
|
||
<?jelly escape-by-default='true'?> | ||
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form"> | ||
<st:documentation> | ||
Generates an input field <code><input type="file" ... /></code> | ||
|
||
<st:attribute name="field"> | ||
Used for databinding. | ||
</st:attribute> | ||
<st:attribute name="jsonAware"> | ||
Enable structured form submission. | ||
</st:attribute> | ||
<st:attribute name="accept"> | ||
Defines the file types the file input should accept. This string is a comma-separated list. | ||
</st:attribute> | ||
timja marked this conversation as resolved.
Show resolved
Hide resolved
|
||
@since TODO | ||
</st:documentation> | ||
<f:prepareDatabinding /> | ||
|
||
<j:set var="name" value="${attrs.name ?: attrs.field}"/> | ||
|
||
<input name="${name}" | ||
type="file" | ||
jsonAware="${attrs.jsonAware}" | ||
class="jenkins-file-upload" | ||
accept="${attrs.accept}" | ||
/> | ||
</j:jelly> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
.jenkins-file-upload { | ||
position: relative; | ||
width: 100%; | ||
margin: -10px 0 0 -10px; | ||
padding: 10px 0 10px 10px; | ||
outline: none; | ||
background: transparent; | ||
|
||
&::before { | ||
content: ""; | ||
position: absolute; | ||
display: block; | ||
left: calc(10px + 0.9rem); | ||
width: 1rem; | ||
height: 36px; | ||
background: currentColor; | ||
mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 512 512'%3E%3Cpath d='M320 367.79h76c55 0 100-29.21 100-83.6s-53-81.47-96-83.6c-8.89-85.06-71-136.8-144-136.8-69 0-113.44 45.79-128 91.2-60 5.7-112 43.88-112 106.4s54 106.4 120 106.4h56' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='40'/%3E%3Cpath fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' stroke-width='40' d='M320 255.79l-64-64-64 64M256 448.21V207.79'/%3E%3C/svg%3E"); | ||
mask-position: center; | ||
mask-repeat: no-repeat; | ||
pointer-events: none; | ||
} | ||
|
||
&::file-selector-button { | ||
display: inline-flex; | ||
align-items: center; | ||
justify-content: center; | ||
border: none; | ||
outline: none; | ||
margin: 0 1rem 0 0; | ||
padding: 0.5rem 0.85rem 0.5rem 2.5rem; | ||
// Firefox doesn't support pseudo elements on inputs so don't increase padding to accommodate | ||
@supports (-moz-appearance: none) { | ||
padding: 0.5rem 0.85rem; | ||
} | ||
|
||
font-size: 0.8rem; | ||
font-weight: 500; | ||
color: var(--text-color); | ||
border-radius: 0.66rem; | ||
cursor: pointer; | ||
min-height: 36px; | ||
white-space: nowrap; | ||
background: var(--button-background); | ||
transition: var(--standard-transition); | ||
box-shadow: 0 0 0 10px transparent; | ||
|
||
&:hover { | ||
background: var(--button-background--hover); | ||
} | ||
|
||
&:active { | ||
background: var(--button-background--active); | ||
box-shadow: 0 0 0 5px var(--button-box-shadow--focus); | ||
} | ||
} | ||
|
||
&:focus-visible { | ||
&::file-selector-button { | ||
box-shadow: 0 0 0 0.2rem var(--text-color) !important; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Optional I guess?
You could just copy unknown tag attrs to the HTML tag. There is some Jelly/Stapler trick to do that.
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.
Yes,
use="required"
denotes mandatory.if can you point to it that could be useful although likely unneeded
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.
Second this as it is important for my use case.
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.
jenkins/core/src/main/java/hudson/util/jelly/MorphTagLibrary.java
Lines 24 to 32 in 7c18855
jenkins/core/src/main/resources/lib/form/textbox.jelly
Lines 107 to 113 in 7c18855
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, @strangelookingnerd what is missing that you need?
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.
See https://github.com/jenkinsci/custom-folder-icon-plugin/blob/master/src/main/resources/jenkins/plugins/foldericon/CustomFolderIcon/config.jelly#L34
I'm adapting the size (for visual reasons) and add an ID to add a change event in the following
<script>
sectionhttps://github.com/jenkinsci/custom-folder-icon-plugin/blob/5f60c7af85f7dfd56caca7e6ce392e70442ab616/src/main/resources/jenkins/plugins/foldericon/CustomFolderIcon/config.jelly#L61-L69
Maybe this is the wrong approach but without the ID my use case breaks.
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.
That source file should be
st:adjunct
and probablyBehaviour.specify
but that is another story.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.
Styling should be done via classes and not inline css, I added support for an ID because of your plugin but you could also do that via a CSS class anyway