From 6d74187718f0577b30b194e251556f1b3780eba2 Mon Sep 17 00:00:00 2001 From: Luke Warlow Date: Wed, 17 Apr 2024 22:59:32 +0200 Subject: [PATCH] add `inverted-colors` variant --- .../src/__snapshots__/intellisense.test.ts.snap | 8 ++++++++ packages/tailwindcss/src/variants.test.ts | 10 ++++++++++ packages/tailwindcss/src/variants.ts | 2 ++ 3 files changed, 20 insertions(+) diff --git a/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap b/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap index 3f95c9fafcb1..5bc3d0df6021 100644 --- a/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap +++ b/packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap @@ -7592,6 +7592,7 @@ exports[`getVariants 1`] = ` "dark", "print", "forced-colors", + "inverted-colors", ], }, { @@ -8282,5 +8283,12 @@ exports[`getVariants 1`] = ` "selectors": [Function], "values": [], }, + { + "hasDash": true, + "isArbitrary": false, + "name": "inverted-colors", + "selectors": [Function], + "values": [], + }, ] `; diff --git a/packages/tailwindcss/src/variants.test.ts b/packages/tailwindcss/src/variants.test.ts index e70970a92bed..0381e089b493 100644 --- a/packages/tailwindcss/src/variants.test.ts +++ b/packages/tailwindcss/src/variants.test.ts @@ -1936,6 +1936,16 @@ test('forced-colors', async () => { expect(await run(['forced-colors/foo:flex'])).toEqual('') }) +test('inverted-colors', async () => { + expect(await run(['inverted-colors:flex'])).toMatchInlineSnapshot(` + "@media (inverted-colors: inverted) { + .inverted-colors\\:flex { + display: flex; + } + }" + `) +}) + test('nth', async () => { expect( await run([ diff --git a/packages/tailwindcss/src/variants.ts b/packages/tailwindcss/src/variants.ts index d7a1ab5b1390..b1615c8c8b18 100644 --- a/packages/tailwindcss/src/variants.ts +++ b/packages/tailwindcss/src/variants.ts @@ -1134,6 +1134,8 @@ export function createVariants(theme: Theme): Variants { staticVariant('forced-colors', ['@media (forced-colors: active)']) + staticVariant('inverted-colors', ['@media (inverted-colors: inverted)']) + return variants }