Add variant for ::file-selector-button pseudo element (#4936)

* Add variant for file-selector-button pseudo element

* Rename `file-selector-button` variant to `file`

Co-Authored-By: Adam Wathan <4323180+adamwathan@users.noreply.github.com>

Co-authored-by: Jonathan Reinink <jonathan@reinink.ca>
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
This commit is contained in:
Luke Warlow 2021-09-23 20:43:37 +01:00 • committed by GitHub
parent a8836eb093
commit f0ce096d8d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 0 deletions

View file

@ -72,6 +72,15 @@ export let pseudoElementVariants = ({ config, addVariant }) => {
}),
])
addVariant(
'file',
transformAllSelectors((selector) => {
return updateAllClasses(selector, (className, { withPseudo }) => {
return withPseudo(`file${config('separator')}${className}`, '::file-selector-button')
})
})
)
addVariant(
'before',
transformAllSelectors(

View file

@ -52,6 +52,14 @@
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}
.file\:bg-blue-500::file-selector-button {
--tw-bg-opacity: 1;
background-color: rgb(59 130 246 / var(--tw-bg-opacity));
}
.file\:text-white::file-selector-button {
--tw-text-opacity: 1;
color: rgb(255 255 255 / var(--tw-text-opacity));
}
.before\:block::before {
content: '';
display: block;
@ -189,6 +197,10 @@
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
var(--tw-shadow);
}
.file\:hover\:bg-blue-600::file-selector-button:hover {
--tw-bg-opacity: 1;
background-color: rgb(37 99 235 / var(--tw-bg-opacity));
}
.focus\:shadow-md:focus {
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),

View file

@ -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:bg-blue-500 file:text-white"></div>
<div class="before:block before:bg-red-500"></div>
<div class="after:flex after:uppercase"></div>
@ -127,6 +128,7 @@
<div class="2xl:shadow-md"></div>
<!-- Stacked variants -->
<div class="file:hover:bg-blue-600"></div>
<div class="focus:hover:shadow-md"></div>
<div class="sm:active:shadow-md"></div>
<div class="md:group-focus:shadow-md"></div>