-
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
Only generate Preflight compatibility styles when Preflight is used #14773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
005edae
195ac50
3a91299
8754b6c
ac358ff
c3e42b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
…ected in the correct spot
- Loading branch information
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -992,4 +992,178 @@ describe('border compatibility', () => { | |
| `) | ||
| }, | ||
| ) | ||
|
|
||
| test( | ||
| 'migrate border compatibility in the file that uses the `@import "tailwindcss"` import', | ||
| { | ||
| fs: { | ||
| 'package.json': json` | ||
| { | ||
| "dependencies": { | ||
| "@tailwindcss/upgrade": "workspace:^" | ||
| } | ||
| } | ||
| `, | ||
| 'tailwind.config.ts': ts` | ||
| import { type Config } from 'tailwindcss' | ||
|
|
||
| export default { | ||
| theme: {}, | ||
| } satisfies Config | ||
| `, | ||
| 'src/input.css': css`@import './tailwind.css';`, | ||
| 'src/tailwind.css': css` | ||
| @tailwind base; | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| `, | ||
| }, | ||
| }, | ||
| async ({ exec, fs }) => { | ||
| await exec('npx @tailwindcss/upgrade') | ||
|
|
||
| expect(await fs.dumpFiles('src/**/*.css')).toMatchInlineSnapshot(` | ||
| " | ||
| --- src/input.css --- | ||
| @import './tailwind.css'; | ||
|
|
||
| --- src/tailwind.css --- | ||
| @import 'tailwindcss'; | ||
|
|
||
| /* | ||
| The default border color has changed to \`currentColor\` in Tailwind CSS v4, | ||
| so we've added these compatibility styles to make sure everything still | ||
| looks the same as it did with Tailwind CSS v3. | ||
|
|
||
| If we ever want to remove these styles, we need to add an explicit border | ||
| color utility to any element that depends on these defaults. | ||
| */ | ||
| @layer base { | ||
| *, | ||
| ::after, | ||
| ::before, | ||
| ::backdrop, | ||
| ::file-selector-button { | ||
| border-color: var(--color-gray-200, currentColor); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| Form elements have a 1px border by default in Tailwind CSS v4, so we've | ||
| added these compatibility styles to make sure everything still looks the | ||
| same as it did with Tailwind CSS v3. | ||
|
|
||
| If we ever want to remove these styles, we need to add \`border-0\` to | ||
| any form elements that shouldn't have a border. | ||
| */ | ||
| @layer base { | ||
| input:where(:not([type='button'], [type='reset'], [type='submit'])), | ||
| select, | ||
| textarea { | ||
| border-width: 0; | ||
| } | ||
| } | ||
| " | ||
| `) | ||
| }, | ||
| ) | ||
|
|
||
| test( | ||
| 'migrate border compatibility in the file that uses the `@import "tailwindcss/preflight"` import', | ||
| { | ||
| fs: { | ||
| 'package.json': json` | ||
| { | ||
| "dependencies": { | ||
| "@tailwindcss/upgrade": "workspace:^" | ||
| } | ||
| } | ||
| `, | ||
| 'tailwind.config.ts': ts` | ||
| import { type Config } from 'tailwindcss' | ||
|
|
||
| export default { | ||
| theme: {}, | ||
| } satisfies Config | ||
| `, | ||
| 'src/input.css': css` | ||
| @import './base.css'; | ||
| @import './my-base.css'; | ||
| @import './utilities.css'; | ||
| `, | ||
| 'src/base.css': css`@tailwind base;`, | ||
| 'src/utilities.css': css` | ||
| @tailwind components; | ||
| @tailwind utilities; | ||
| `, | ||
| 'src/my-base.css': css` | ||
| @layer base { | ||
| html { | ||
| color: black; | ||
| } | ||
| } | ||
| `, | ||
| }, | ||
| }, | ||
| async ({ exec, fs }) => { | ||
| await exec('npx @tailwindcss/upgrade') | ||
|
|
||
| expect(await fs.dumpFiles('src/**/*.css')).toMatchInlineSnapshot(` | ||
| " | ||
| --- src/base.css --- | ||
| @import 'tailwindcss/theme' layer(theme); | ||
| @import 'tailwindcss/preflight' layer(base); | ||
|
|
||
| /* | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Injected the border compatibility CSS because |
||
| The default border color has changed to \`currentColor\` in Tailwind CSS v4, | ||
| so we've added these compatibility styles to make sure everything still | ||
| looks the same as it did with Tailwind CSS v3. | ||
|
|
||
| If we ever want to remove these styles, we need to add an explicit border | ||
| color utility to any element that depends on these defaults. | ||
| */ | ||
| @layer base { | ||
| *, | ||
| ::after, | ||
| ::before, | ||
| ::backdrop, | ||
| ::file-selector-button { | ||
| border-color: var(--color-gray-200, currentColor); | ||
| } | ||
| } | ||
|
|
||
| /* | ||
| Form elements have a 1px border by default in Tailwind CSS v4, so we've | ||
| added these compatibility styles to make sure everything still looks the | ||
| same as it did with Tailwind CSS v3. | ||
|
|
||
| If we ever want to remove these styles, we need to add \`border-0\` to | ||
| any form elements that shouldn't have a border. | ||
| */ | ||
| @layer base { | ||
| input:where(:not([type='button'], [type='reset'], [type='submit'])), | ||
| select, | ||
| textarea { | ||
| border-width: 0; | ||
| } | ||
| } | ||
|
|
||
| --- src/input.css --- | ||
| @import './base.css'; | ||
| @import './my-base.css'; | ||
| @import './utilities.css'; | ||
|
|
||
| --- src/my-base.css --- | ||
| @layer base { | ||
| html { | ||
| color: black; | ||
| } | ||
| } | ||
|
|
||
| --- src/utilities.css --- | ||
| @import 'tailwindcss/utilities' layer(utilities); | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No border compatibility CSS was injected because we only have |
||
| " | ||
| `) | ||
| }, | ||
| ) | ||
| }) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Injected the border compatibility CSS because
@import "tailwindcss"exists