Skip to content

Commit e01f144

Browse files
committed
Add prefers-reduced-transparency variants
1 parent a8c54ac commit e01f144

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

Diff for: packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap

+16
Original file line numberDiff line numberDiff line change
@@ -7592,6 +7592,8 @@ exports[`getVariants 1`] = `
75927592
"dark",
75937593
"print",
75947594
"forced-colors",
7595+
"transparency-safe",
7596+
"transparency-reduce",
75957597
],
75967598
},
75977599
{
@@ -8282,5 +8284,19 @@ exports[`getVariants 1`] = `
82828284
"selectors": [Function],
82838285
"values": [],
82848286
},
8287+
{
8288+
"hasDash": true,
8289+
"isArbitrary": false,
8290+
"name": "transparency-safe",
8291+
"selectors": [Function],
8292+
"values": [],
8293+
},
8294+
{
8295+
"hasDash": true,
8296+
"isArbitrary": false,
8297+
"name": "transparency-reduce",
8298+
"selectors": [Function],
8299+
"values": [],
8300+
},
82858301
]
82868302
`;

Diff for: packages/tailwindcss/src/variants.test.ts

+20
Original file line numberDiff line numberDiff line change
@@ -1903,6 +1903,26 @@ test('landscape', async () => {
19031903
expect(await run(['landscape/foo:flex'])).toEqual('')
19041904
})
19051905

1906+
test('transparency-safe', async () => {
1907+
expect(await run(['transparency-safe:flex'])).toMatchInlineSnapshot(`
1908+
"@media (prefers-reduced-transparency: no-preference) {
1909+
.transparency-safe\\:flex {
1910+
display: flex;
1911+
}
1912+
}"
1913+
`)
1914+
})
1915+
1916+
test('transparency-reduce', async () => {
1917+
expect(await run(['transparency-reduce:flex'])).toMatchInlineSnapshot(`
1918+
"@media (prefers-reduced-transparency: reduce) {
1919+
.transparency-reduce\\:flex {
1920+
display: flex;
1921+
}
1922+
}"
1923+
`)
1924+
})
1925+
19061926
test('contrast-more', async () => {
19071927
expect(await run(['contrast-more:flex'])).toMatchInlineSnapshot(`
19081928
"@media (prefers-contrast: more) {

Diff for: packages/tailwindcss/src/variants.ts

+3
Original file line numberDiff line numberDiff line change
@@ -1134,6 +1134,9 @@ export function createVariants(theme: Theme): Variants {
11341134

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

1137+
staticVariant('transparency-safe', ['@media (prefers-reduced-transparency: no-preference)'])
1138+
staticVariant('transparency-reduce', ['@media (prefers-reduced-transparency: reduce)'])
1139+
11371140
return variants
11381141
}
11391142

0 commit comments

Comments
 (0)