Skip to content

Commit

Permalink
Add :popover-open variant
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarlow committed Oct 5, 2023
1 parent 614c7e2 commit c0dd091
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
- Don’t crash when important and parent selectors are equal in `@apply` ([#12112](https://github.com/tailwindlabs/tailwindcss/pull/12112))
- Eliminate irrelevant rules when applying variants ([#12113](https://github.com/tailwindlabs/tailwindcss/pull/12113))
- Improve RegEx parser, reduce possibilities as the key for arbitrary properties ([#12121](https://github.com/tailwindlabs/tailwindcss/pull/12121))
- Add `:popover-open` variant ([#12148](https://github.com/tailwindlabs/tailwindcss/pull/12148))

### Added

Expand Down
4 changes: 4 additions & 0 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,10 @@ export let variantPlugins = {
addVariant('contrast-more', '@media (prefers-contrast: more)')
addVariant('contrast-less', '@media (prefers-contrast: less)')
},

popoverOpenVariant: ({ addVariant }) => {
addVariant('popover-open', '&:popover-open')
},
}

let cssTransformValue = [
Expand Down
1 change: 1 addition & 0 deletions src/lib/setupContextUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ function resolvePlugins(context, root) {
variantPlugins['printVariant'],
variantPlugins['screenVariants'],
variantPlugins['orientationVariants'],
variantPlugins['popoverOpenVariant'],
]

return [...corePluginList, ...beforeVariants, ...userPlugins, ...afterVariants, ...layerPlugins]
Expand Down
7 changes: 7 additions & 0 deletions tests/plugins/variants/popoverOpenVariant.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { css, quickVariantPluginTest } from '../../util/run'

quickVariantPluginTest('popoverOpenVariant').toMatchFormattedCss(css`
.popover-open\:flex:popover-open {
display: flex;
}
`)

0 comments on commit c0dd091

Please sign in to comment.