-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Bring back max-w-screen-* utilities
#15013
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
eb92690
Bring back `max-w-screen-*` utilities
philipp-spiess 7eb454b
Ensure it works with JS config overwrites
philipp-spiess e8a8c8a
add change log
philipp-spiess d1abe4e
Move utilities compat layer
philipp-spiess e3ffab8
Revert playground change
philipp-spiess 2bb66ff
Don't duplicate deprecated utilities
adamwathan 912c69e
Update CHANGELOG.md
adamwathan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
133 changes: 133 additions & 0 deletions
133
packages/tailwindcss/src/compat/legacy-utilities.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,133 @@ | ||
| import { expect, test } from 'vitest' | ||
| import { compileCss, run } from '../test-utils/run' | ||
|
|
||
| const css = String.raw | ||
|
|
||
| test('bg-gradient-*', async () => { | ||
| expect( | ||
| await compileCss( | ||
| css` | ||
| @tailwind utilities; | ||
| `, | ||
| [ | ||
| 'bg-gradient-to-t', | ||
| 'bg-gradient-to-tr', | ||
| 'bg-gradient-to-r', | ||
| 'bg-gradient-to-br', | ||
| 'bg-gradient-to-b', | ||
| 'bg-gradient-to-bl', | ||
| 'bg-gradient-to-l', | ||
| 'bg-gradient-to-tl', | ||
| ], | ||
| ), | ||
| ).toMatchInlineSnapshot(` | ||
| ".bg-gradient-to-b { | ||
| --tw-gradient-position: to bottom in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-bl { | ||
| --tw-gradient-position: to bottom left in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-br { | ||
| --tw-gradient-position: to bottom right in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-l { | ||
| --tw-gradient-position: to left in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-r { | ||
| --tw-gradient-position: to right in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-t { | ||
| --tw-gradient-position: to top in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-tl { | ||
| --tw-gradient-position: to top left in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| } | ||
|
|
||
| .bg-gradient-to-tr { | ||
| --tw-gradient-position: to top right in oklch, ; | ||
| background-image: linear-gradient(var(--tw-gradient-stops)); | ||
| }" | ||
| `) | ||
| }) | ||
|
|
||
| test('max-w-screen', async () => { | ||
| expect( | ||
| await compileCss( | ||
| css` | ||
| @theme { | ||
| --breakpoint-sm: 40rem; | ||
| --breakpoint-md: 48rem; | ||
| --breakpoint-lg: 64rem; | ||
| --breakpoint-xl: 80rem; | ||
| --breakpoint-2xl: 96rem; | ||
| } | ||
| @tailwind utilities; | ||
| `, | ||
| [ | ||
| 'max-w-screen-sm', | ||
| 'max-w-screen-md', | ||
| 'max-w-screen-lg', | ||
| 'max-w-screen-xl', | ||
| 'max-w-screen-2xl', | ||
| ], | ||
| ), | ||
| ).toMatchInlineSnapshot(` | ||
| ":root { | ||
| --breakpoint-sm: 40rem; | ||
| --breakpoint-md: 48rem; | ||
| --breakpoint-lg: 64rem; | ||
| --breakpoint-xl: 80rem; | ||
| --breakpoint-2xl: 96rem; | ||
| } | ||
|
|
||
| .max-w-screen-2xl { | ||
| max-width: var(--breakpoint-2xl); | ||
| } | ||
|
|
||
| .max-w-screen-lg { | ||
| max-width: var(--breakpoint-lg); | ||
| } | ||
|
|
||
| .max-w-screen-md { | ||
| max-width: var(--breakpoint-md); | ||
| } | ||
|
|
||
| .max-w-screen-sm { | ||
| max-width: var(--breakpoint-sm); | ||
| } | ||
|
|
||
| .max-w-screen-xl { | ||
| max-width: var(--breakpoint-xl); | ||
| }" | ||
| `) | ||
| expect( | ||
| await run([ | ||
| 'max-w-screen-oh', | ||
| 'max-w-screen-4', | ||
| 'max-w-screen-[4px]', | ||
| '-max-w-screen-sm', | ||
| '-max-w-screen-[4px]', | ||
| 'max-w-screen-none/foo', | ||
| 'max-w-screen-full/foo', | ||
| 'max-w-screen-max/foo', | ||
| 'max-w-screen-max/foo', | ||
| 'max-w-screen-fit/foo', | ||
| 'max-w-screen-4/foo', | ||
| 'max-w-screen-xl/foo', | ||
| 'max-w-screen-[4px]/foo', | ||
| ]), | ||
| ).toEqual('') | ||
| }) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| import { decl } from '../ast' | ||
| import type { DesignSystem } from '../design-system' | ||
|
|
||
| export function registerLegacyUtilities(designSystem: DesignSystem) { | ||
| for (let [value, direction] of [ | ||
| ['t', 'top'], | ||
| ['tr', 'top right'], | ||
| ['r', 'right'], | ||
| ['br', 'bottom right'], | ||
| ['b', 'bottom'], | ||
| ['bl', 'bottom left'], | ||
| ['l', 'left'], | ||
| ['tl', 'top left'], | ||
| ]) { | ||
| designSystem.utilities.static(`bg-gradient-to-${value}`, () => [ | ||
| decl('--tw-gradient-position', `to ${direction} in oklch,`), | ||
| decl('background-image', `linear-gradient(var(--tw-gradient-stops))`), | ||
| ]) | ||
| } | ||
|
|
||
| designSystem.utilities.functional('max-w-screen', (candidate) => { | ||
| if (!candidate.value) return | ||
| if (candidate.value.kind === 'arbitrary') return | ||
| let value = designSystem.theme.resolve(candidate.value.value, ['--breakpoint']) | ||
| if (!value) return | ||
| return [decl('max-width', value)] | ||
| }) | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.