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 9e69a2b
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",
"noscript",
"scripting",
],
},
{
Expand Down Expand Up @@ -8282,5 +8284,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', async () => {
expect(await run(['noscript:flex'])).toMatchInlineSnapshot(`
"@media (scripting: none) {
.noscript\\:flex {
display: flex;
}
}"
`)
})

test('scripting', async () => {
expect(await run(['scripting:flex'])).toMatchInlineSnapshot(`
"@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 9e69a2b

Please sign in to comment.