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

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

Merged
merged 2 commits into from
Sep 23, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
12 changes: 12 additions & 0 deletions tests/variants.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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),
Expand Down
2 changes: 2 additions & 0 deletions tests/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:bg-blue-500 file:text-white"></div>
<div class="before:block before:bg-red-500"></div>
<div class="after:flex after:uppercase"></div>

Expand Down Expand Up @@ -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>
Expand Down