Skip to content

Commit 60be2a0

Browse files
committed
Add variant for file-selector-button pseudo element
Also includes fallback styles for -webkit-file-upload-button for fuller browser support.
1 parent fbe5be8 commit 60be2a0

File tree

3 files changed

+36
-0
lines changed

3 files changed

+36
-0
lines changed

src/jit/corePlugins.js

+19
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,25 @@ export default {
6161
}),
6262
])
6363

64+
addVariant('file-selector-button', [
65+
transformAllSelectors((selector) => {
66+
return updateAllClasses(selector, (className, { withPseudo }) => {
67+
return withPseudo(
68+
`file-selector-button${config('separator')}${className}`,
69+
'::file-selector-button'
70+
)
71+
})
72+
}),
73+
transformAllSelectors((selector) => {
74+
return updateAllClasses(selector, (className, { withPseudo }) => {
75+
return withPseudo(
76+
`file-selector-button${config('separator')}${className}`,
77+
'::-webkit-file-upload-button'
78+
)
79+
})
80+
}),
81+
])
82+
6483
addVariant(
6584
'before',
6685
transformAllSelectors(

tests/jit/variants.test.css

+16
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,22 @@
156156
--tw-text-opacity: 1;
157157
color: rgba(255, 255, 255, var(--tw-text-opacity));
158158
}
159+
.file-selector-button\:bg-blue-500::file-selector-button {
160+
--tw-bg-opacity: 1;
161+
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));
162+
}
163+
.file-selector-button\:text-white::file-selector-button {
164+
--tw-text-opacity: 1;
165+
color: rgba(255, 255, 255, var(--tw-text-opacity));
166+
}
167+
.file-selector-button\:bg-blue-500::-webkit-file-upload-button {
168+
--tw-bg-opacity: 1;
169+
background-color: rgba(59, 130, 246, var(--tw-bg-opacity));
170+
}
171+
.file-selector-button\:text-white::-webkit-file-upload-button {
172+
--tw-text-opacity: 1;
173+
color: rgba(255, 255, 255, var(--tw-text-opacity));
174+
}
159175
.before\:block::before {
160176
content: '';
161177
display: block;

tests/jit/variants.test.html

+1
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
<li class="marker:text-red-500 marker:text-lg"></li>
4646
</ul>
4747
<div class="selection:bg-blue-500 selection:text-white"></div>
48+
<div class="file-selector-button:bg-blue-500 file-selector-button:text-white"></div>
4849
<div class="before:block before:bg-red-500"></div>
4950
<div class="after:flex after:uppercase"></div>
5051

0 commit comments

Comments
 (0)