Skip to content

Commit 8d1576d

Browse files
committed
Revert "alternative solution: @custom-media"
This reverts commit a1113f8. This is way too experimental and no browser implements this feature yet. See: https://caniuse.com/?search=custom-media We can use lightningcss that transpiles is properly, but in environments such as the CDN we don't have access to lightningcss.
1 parent 1f205f6 commit 8d1576d

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

packages/@tailwindcss-upgrade/src/codemods/migrate-media-screen.test.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,7 @@ it('should migrate a custom max-width screen', async () => {
114114
},
115115
),
116116
).toMatchInlineSnapshot(`
117-
"@custom-media --breakpoint-foo ((123px >= width));
118-
@media (--breakpoint-foo) {
117+
"@media (123px >= width) {
119118
.foo {
120119
color: red;
121120
}
@@ -142,8 +141,7 @@ it('should migrate a custom min and max-width screen', async () => {
142141
},
143142
),
144143
).toMatchInlineSnapshot(`
145-
"@custom-media --breakpoint-foo ((123px >= width >= 100px));
146-
@media (--breakpoint-foo) {
144+
"@media (123px >= width >= 100px) {
147145
.foo {
148146
color: red;
149147
}
@@ -170,8 +168,7 @@ it('should migrate a raw media query', async () => {
170168
},
171169
),
172170
).toMatchInlineSnapshot(`
173-
"@custom-media --breakpoint-foo (only screen and (min-width: 123px));
174-
@media (--breakpoint-foo) {
171+
"@media only screen and (min-width: 123px) {
175172
.foo {
176173
color: red;
177174
}

packages/@tailwindcss-upgrade/src/codemods/migrate-media-screen.ts

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { AtRule, type Plugin, type Root } from 'postcss'
1+
import { type Plugin, type Root } from 'postcss'
22
import type { Config } from 'tailwindcss'
33
import { resolveConfig } from '../../../tailwindcss/src/compat/config/resolve-config'
44
import { buildMediaQuery } from '../../../tailwindcss/src/compat/screens-config'
@@ -21,16 +21,7 @@ export function migrateMediaScreen({
2121
let mediaQueries = new DefaultMap<string, string | null>((name) => {
2222
let value = designSystem?.resolveThemeValue(`--breakpoint-${name}`) ?? screens?.[name]
2323
if (typeof value === 'string') return `(width >= theme(--breakpoint-${name}))`
24-
25-
if (value) {
26-
let query = buildMediaQuery(value)
27-
root.prepend(
28-
new AtRule({ name: 'custom-media', params: `--breakpoint-${name} (${query})` }),
29-
)
30-
return `(--breakpoint-${name})`
31-
}
32-
33-
return null
24+
return value ? buildMediaQuery(value) : null
3425
})
3526

3627
root.walkAtRules((rule) => {

0 commit comments

Comments
 (0)