Skip to content

Commit

Permalink
Add variant for file-selector-button pseudo element
Browse files Browse the repository at this point in the history
Also includes fallback styles for -webkit-file-upload-button for fuller browser support.
  • Loading branch information
lukewarlow committed Jul 9, 2021
1 parent fbe5be8 commit 3b5d12e
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions src/jit/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,25 @@ export default {
}),
])

addVariant('file-selector-button', [
transformAllSelectors((selector) => {
return updateAllClasses(selector, (className, { withPseudo }) => {
return withPseudo(
`file-selector-button${config('separator')}${className}`,
'::-webkit-file-upload-button'
)
})
}),
transformAllSelectors((selector) => {
return updateAllClasses(selector, (className, { withPseudo }) => {
return withPseudo(
`file-selector-button${config('separator')}${className}`,
'::file-selector-button'
)
})
}),
])

addVariant(
'before',
transformAllSelectors(
Expand Down
16 changes: 16 additions & 0 deletions tests/jit/variants.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,22 @@
--tw-text-opacity: 1;
color: rgba(255, 255, 255, var(--tw-text-opacity));
}
.file-selector-button\:bg-blue-500::-webkit-file-upload-button {
--tw-bg-opacity: 1;
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));
}
.file-selector-button\:text-white::-webkit-file-upload-button {
--tw-text-opacity: 1;
color: rgba(255, 255, 255, var(--tw-text-opacity));
}
.file-selector-button\:bg-blue-500::file-selector-button {
--tw-bg-opacity: 1;
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));
}
.file-selector-button\:text-white::file-selector-button {
--tw-text-opacity: 1;
color: rgba(255, 255, 255, var(--tw-text-opacity));
}
.before\:block::before {
content: '';
display: block;
Expand Down
1 change: 1 addition & 0 deletions tests/jit/variants.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
<li class="marker:text-red-500 marker:text-lg"></li>
</ul>
<div class="selection:bg-blue-500 selection:text-white"></div>
<div class="file-selector-button:bg-blue-500 file-selector-button:text-white"></div>
<div class="before:block before:bg-red-500"></div>
<div class="after:flex after:uppercase"></div>

Expand Down

0 comments on commit 3b5d12e

Please sign in to comment.