Skip to content

Commit

Permalink
Add variants for orientation media feature
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarlow committed Nov 10, 2021
1 parent 4e21639 commit 767a91c
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/corePlugins.js
Expand Up @@ -163,6 +163,11 @@ export let variantPlugins = {
addVariant(screen, `@media ${query}`)
}
},

orientationVariants: ({ addVariant }) => {
addVariant('orientation-portrait', '@media (orientation: portrait)')
addVariant('orientation-landscape', '@media (orientation: landscape)')
},
}

export let corePlugins = {
Expand Down
12 changes: 12 additions & 0 deletions tests/variants.test.css
Expand Up @@ -899,3 +899,15 @@
}
}
}
@media (orientation: portrait) {
.orientation-portrait\:bg-yellow-300 {
--tw-bg-opacity: 1;
background-color: rgb(253 224 71 / var(--tw-bg-opacity));
}
}
@media (orientation: landscape) {
.orientation-landscape\:bg-yellow-300 {
--tw-bg-opacity: 1;
background-color: rgb(253 224 71 / var(--tw-bg-opacity));
}
}
4 changes: 4 additions & 0 deletions tests/variants.test.html
Expand Up @@ -134,6 +134,10 @@
<div class="lg:animate-spin"></div>
<div class="hover:animate-spin"></div>

<!-- Orientation variants -->
<div class="orientation-portrait:bg-yellow-300"></div>
<div class="orientation-landscape:bg-yellow-300"></div>

<!-- Stacked variants -->
<div class="open:hover:bg-red-200"></div>
<div class="file:hover:bg-blue-600"></div>
Expand Down

0 comments on commit 767a91c

Please sign in to comment.