Skip to content

Commit

Permalink
Add prefers-reduced-transparency variants
Browse files Browse the repository at this point in the history
Co-authored-by: Luke Warlow <luke@warlow.dev>
  • Loading branch information
RobinMalfait and lukewarlow committed Apr 17, 2024
1 parent cc8c069 commit 233aca0
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap
Expand Up @@ -2382,6 +2382,20 @@ 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": [],
},
{
"hasDash": true,
"isArbitrary": false,
Expand Down
20 changes: 20 additions & 0 deletions packages/tailwindcss/src/variants.test.ts
Expand Up @@ -1516,6 +1516,26 @@ test('landscape', () => {
`)
})

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

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

test('contrast-more', () => {
expect(run(['contrast-more:flex'])).toMatchInlineSnapshot(`
"@media (prefers-contrast: more) {
Expand Down
7 changes: 7 additions & 0 deletions packages/tailwindcss/src/variants.ts
Expand Up @@ -690,6 +690,13 @@ export function createVariants(theme: Theme): Variants {
staticVariant('portrait', ['@media (orientation: portrait)'], { compounds: false })
staticVariant('landscape', ['@media (orientation: landscape)'], { compounds: false })

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

staticVariant('ltr', ['&:where([dir="ltr"], [dir="ltr"] *)'])
staticVariant('rtl', ['&:where([dir="rtl"], [dir="rtl"] *)'])

Expand Down

0 comments on commit 233aca0

Please sign in to comment.