Skip to content

Commit

Permalink
Add print variant
Browse files Browse the repository at this point in the history
Co-Authored-By: Adam Wathan <4323180+adamwathan@users.noreply.github.com>
  • Loading branch information
2 people authored and RobinMalfait committed Oct 27, 2021
1 parent fd9dbe1 commit 80c1961
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/corePlugins.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ export let variantPlugins = {
}
},

printVariant: ({ addVariant }) => {
addVariant('print', '@media print')
},

screenVariants: ({ theme, addVariant }) => {
for (let screen in theme('screens')) {
let size = theme('screens')[screen]
Expand Down
1 change: 1 addition & 0 deletions src/lib/setupContextUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,7 @@ function resolvePlugins(context, root) {
variantPlugins['directionVariants'],
variantPlugins['reducedMotionVariants'],
variantPlugins['darkVariants'],
variantPlugins['printVariant'],
variantPlugins['screenVariants'],
]

Expand Down
6 changes: 6 additions & 0 deletions tests/variants.test.css
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,12 @@
box-shadow: var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000),
var(--tw-shadow);
}
@media print {
.print\:bg-yellow-300 {
--tw-bg-opacity: 1;
background-color: rgb(253 224 71 / var(--tw-bg-opacity));
}
}
@media (min-width: 640px) {
.sm\:shadow-md {
--tw-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -1px rgb(0 0 0 / 0.06);
Expand Down
3 changes: 3 additions & 0 deletions tests/variants.test.html
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@
<!-- Dark mode variants -->
<div class="dark:shadow-md"></div>

<!-- Print variant -->
<div class="print:bg-yellow-300"></div>

<!-- Screen variants -->
<div class="sm:shadow-md"></div>
<div class="md:shadow-md"></div>
Expand Down

0 comments on commit 80c1961

Please sign in to comment.