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 variants for orientation media feature #6046

Merged
merged 2 commits into from Nov 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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('portrait', '@media (orientation: portrait)')
addVariant('landscape', '@media (orientation: landscape)')
},
}

export let corePlugins = {
Expand Down
1 change: 1 addition & 0 deletions src/lib/setupContextUtils.js
Expand Up @@ -575,6 +575,7 @@ function resolvePlugins(context, root) {
variantPlugins['darkVariants'],
variantPlugins['printVariant'],
variantPlugins['screenVariants'],
variantPlugins['orientationVariants'],
]

return [...corePluginList, ...beforeVariants, ...userPlugins, ...afterVariants, ...layerPlugins]
Expand Down
5 changes: 0 additions & 5 deletions tests/kitchen-sink.test.css
Expand Up @@ -509,11 +509,6 @@ div {
}
}
}
@media (orientation: portrait) {
.portrait\:text-center {
text-align: center;
}
}
@media (min-width: 1280px) and (max-width: 1535px) {
.range\:text-right {
text-align: right;
Expand Down
2 changes: 1 addition & 1 deletion tests/kitchen-sink.test.html
Expand Up @@ -8,7 +8,7 @@
<link rel="stylesheet" href="./tailwind.css" />
</head>
<body>
<div class="portrait:text-center range:text-right multi:text-left"></div>
<div class="range:text-right multi:text-left"></div>
<div
class="container hover:container sm:container md:container text-center sm:text-center md:text-center"
></div>
Expand Down
1 change: 0 additions & 1 deletion tests/kitchen-sink.test.js
Expand Up @@ -11,7 +11,6 @@ test('it works', () => {
theme: {
extend: {
screens: {
portrait: { raw: '(orientation: portrait)' },
range: { min: '1280px', max: '1535px' },
multi: [{ min: '640px', max: '767px' }, { max: '868px' }],
},
Expand Down
12 changes: 12 additions & 0 deletions tests/variants.test.css
Expand Up @@ -899,3 +899,15 @@
}
}
}
@media (orientation: portrait) {
.portrait\:bg-yellow-300 {
--tw-bg-opacity: 1;
background-color: rgb(253 224 71 / var(--tw-bg-opacity));
}
}
@media (orientation: landscape) {
.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="portrait:bg-yellow-300"></div>
<div class="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