Skip to content

Commit

Permalink
add scripting variants
Browse files Browse the repository at this point in the history
  • Loading branch information
lukewarlow committed Jan 23, 2025
1 parent a8c54ac commit 164954d
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 0 deletions.
14 changes: 14 additions & 0 deletions packages/tailwindcss/src/__snapshots__/intellisense.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -8282,5 +8282,19 @@ exports[`getVariants 1`] = `
"selectors": [Function],
"values": [],
},
{
"hasDash": true,
"isArbitrary": false,
"name": "noscript",
"selectors": [Function],
"values": [],
},
{
"hasDash": true,
"isArbitrary": false,
"name": "scripting",
"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 @@ -1936,6 +1936,26 @@ test('forced-colors', async () => {
expect(await run(['forced-colors/foo:flex'])).toEqual('')
})

test('noscript', () => {
expect(run(['noscript:flex'])).toMatchInlineSnapshot(`

Check failure on line 1940 in packages/tailwindcss/src/variants.test.ts

View workflow job for this annotation

GitHub Actions / Linux

src/variants.test.ts > noscript

Error: Snapshot `noscript 1` mismatched - Expected + Received - "@media (scripting: none) { - .noscript\:flex { - display: flex; - } - }" + Promise {} ❯ src/variants.test.ts:1940:36
"@media (scripting: none) {
.noscript\\:flex {
display: flex;
}
}"
`)
})

test('scripting', () => {
expect(run(['scripting:flex'])).toMatchInlineSnapshot(`

Check failure on line 1950 in packages/tailwindcss/src/variants.test.ts

View workflow job for this annotation

GitHub Actions / Linux

src/variants.test.ts > scripting

Error: Snapshot `scripting 1` mismatched - Expected + Received - "@media (scripting: enabled) { - .scripting\:flex { - display: flex; - } - }" + Promise {} ❯ src/variants.test.ts:1950:37
"@media (scripting: enabled) {
.scripting\\:flex {
display: flex;
}
}"
`)
})

test('nth', async () => {
expect(
await run([
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('noscript', ['@media (scripting: none)'])
staticVariant('scripting', ['@media (scripting: enabled)'])

return variants
}

Expand Down

0 comments on commit 164954d

Please sign in to comment.