Skip to content

Commit

Permalink
Add prefers-reduced-transparency variants
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarlow committed Jan 23, 2025
1 parent a8c54ac commit e01f144
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -7592,6 +7592,8 @@ exports[`getVariants 1`] = `
"dark",
"print",
"forced-colors",
"transparency-safe",
"transparency-reduce",
],
},
{
Expand Down Expand Up @@ -8282,5 +8284,19 @@ exports[`getVariants 1`] = `
"selectors": [Function],
"values": [],
},
{
"hasDash": true,
"isArbitrary": false,
"name": "transparency-safe",
"selectors": [Function],
"values": [],
},
{
"hasDash": true,
"isArbitrary": false,
"name": "transparency-reduce",
"selectors": [Function],
"values": [],
},
]
`;
20 changes: 20 additions & 0 deletions packages/tailwindcss/src/variants.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1903,6 +1903,26 @@ test('landscape', async () => {
expect(await run(['landscape/foo:flex'])).toEqual('')
})

test('transparency-safe', async () => {
expect(await run(['transparency-safe:flex'])).toMatchInlineSnapshot(`
"@media (prefers-reduced-transparency: no-preference) {
.transparency-safe\\:flex {
display: flex;
}
}"
`)
})

test('transparency-reduce', async () => {
expect(await run(['transparency-reduce:flex'])).toMatchInlineSnapshot(`
"@media (prefers-reduced-transparency: reduce) {
.transparency-reduce\\:flex {
display: flex;
}
}"
`)
})

test('contrast-more', async () => {
expect(await run(['contrast-more:flex'])).toMatchInlineSnapshot(`
"@media (prefers-contrast: more) {
Expand Down
3 changes: 3 additions & 0 deletions packages/tailwindcss/src/variants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1134,6 +1134,9 @@ export function createVariants(theme: Theme): Variants {

staticVariant('forced-colors', ['@media (forced-colors: active)'])

staticVariant('transparency-safe', ['@media (prefers-reduced-transparency: no-preference)'])
staticVariant('transparency-reduce', ['@media (prefers-reduced-transparency: reduce)'])

return variants
}

Expand Down

0 comments on commit e01f144

Please sign in to comment.