-
Notifications
You must be signed in to change notification settings - Fork 4.3k
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
Add radius-*
utilities and deprecate rounded-*
utilities
#14912
base: next
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -72,13 +72,16 @@ | |
class="!flex sm:!block bg-gradient-to-t bg-[--my-red] max-w-screen-md ml-[theme(screens.md)]" | ||
></div> | ||
<!-- Migrate to sm --> | ||
<div class="blur shadow rounded inset-shadow drop-shadow"></div> | ||
<div class="blur shadow inset-shadow drop-shadow"></div> | ||
|
||
<!-- Migrate to xs --> | ||
<div class="blur-sm shadow-sm rounded-sm inset-shadow-sm drop-shadow-sm"></div> | ||
<div class="blur-sm shadow-sm inset-shadow-sm drop-shadow-sm"></div> | ||
|
||
<!-- Migrate to 2xs --> | ||
<div class="shadow-xs inset-shadow-xs"></div> | ||
|
||
<!-- Migrate to \`radius-*\` --> | ||
<div class="rounded rounded-sm rounded-xl"></div> | ||
`, | ||
'src/input.css': css` | ||
@tailwind base; | ||
|
@@ -104,14 +107,17 @@ | |
class="flex! sm:block! bg-linear-to-t bg-[var(--my-red)] max-w-[var(--breakpoint-md)] ml-[var(--breakpoint-md)]" | ||
></div> | ||
<!-- Migrate to sm --> | ||
<div class="blur-sm shadow-sm rounded-sm inset-shadow-sm drop-shadow-sm"></div> | ||
<div class="blur-sm shadow-sm inset-shadow-sm drop-shadow-sm"></div> | ||
|
||
<!-- Migrate to xs --> | ||
<div class="blur-xs shadow-xs rounded-xs inset-shadow-xs drop-shadow-xs"></div> | ||
<div class="blur-xs shadow-xs inset-shadow-xs drop-shadow-xs"></div> | ||
|
||
<!-- Migrate to 2xs --> | ||
<div class="shadow-2xs inset-shadow-2xs"></div> | ||
|
||
<!-- Migrate to \`radius-*\` --> | ||
<div class="radius radius-sm radius-xl"></div> | ||
|
||
--- ./src/input.css --- | ||
@import 'tailwindcss'; | ||
|
||
|
@@ -196,7 +202,7 @@ | |
async ({ exec, fs }) => { | ||
await exec('npx @tailwindcss/upgrade') | ||
|
||
expect(await fs.dumpFiles('./src/**/*.{css,html}')).toMatchInlineSnapshot(` | ||
Check failure on line 205 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > upgrades a v3 project with prefixes to v4
Check failure on line 205 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > upgrades a v3 project with prefixes to v4
Check failure on line 205 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > upgrades a v3 project with prefixes to v4
|
||
" | ||
--- ./src/index.html --- | ||
<div | ||
|
@@ -414,7 +420,7 @@ | |
async ({ fs, exec }) => { | ||
await exec('npx @tailwindcss/upgrade') | ||
|
||
expect(await fs.dumpFiles('./src/**/*.css')).toMatchInlineSnapshot(` | ||
Check failure on line 423 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > migrate `@layer utilities` and `@layer components`
Check failure on line 423 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > migrate `@layer utilities` and `@layer components`
Check failure on line 423 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > migrate `@layer utilities` and `@layer components`
|
||
" | ||
--- ./src/index.css --- | ||
@import 'tailwindcss'; | ||
|
@@ -1496,7 +1502,7 @@ | |
async ({ fs, exec }) => { | ||
await exec('npx @tailwindcss/upgrade --force') | ||
|
||
expect(await fs.dumpFiles('./src/**/*.css')).toMatchInlineSnapshot(` | ||
Check failure on line 1505 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > relative imports without a relative path prefix are migrated to include a relative path prefix
Check failure on line 1505 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > relative imports without a relative path prefix are migrated to include a relative path prefix
Check failure on line 1505 in integrations/upgrade/index.test.ts GitHub Actions / tests (20, namespace-profile-default, false)upgrade/index.test.ts > relative imports without a relative path prefix are migrated to include a relative path prefix
|
||
" | ||
--- ./src/index.css --- | ||
@import 'tailwindcss'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { __unstable__loadDesignSystem } from '@tailwindcss/node' | ||
import { expect, test } from 'vitest' | ||
import { radius } from './radius' | ||
|
||
test.each([ | ||
['hover:rounded', 'hover:radius'], | ||
['hover:rounded-sm', 'hover:radius-sm'], | ||
['hover:rounded-md', 'hover:radius-md'], | ||
['hover:rounded-lg', 'hover:radius-lg'], | ||
['hover:rounded-xl', 'hover:radius-xl'], | ||
['hover:rounded-2xl', 'hover:radius-2xl'], | ||
['hover:rounded-3xl', 'hover:radius-3xl'], | ||
['hover:rounded-4xl', 'hover:radius-4xl'], | ||
])('%s => %s', async (candidate, result) => { | ||
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', { | ||
base: __dirname, | ||
}) | ||
|
||
expect(radius(designSystem, {}, candidate)).toEqual(result) | ||
}) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import type { Config } from 'tailwindcss' | ||
import type { DesignSystem } from '../../../../tailwindcss/src/design-system' | ||
import { printCandidate } from '../candidates' | ||
|
||
export function radius( | ||
designSystem: DesignSystem, | ||
_userConfig: Config, | ||
rawCandidate: string, | ||
): string { | ||
for (let candidate of designSystem.parseCandidate(rawCandidate)) { | ||
if (candidate.kind === 'functional' && candidate.root === 'rounded') { | ||
return printCandidate(designSystem, { | ||
...candidate, | ||
root: 'radius', | ||
}) | ||
} | ||
} | ||
return rawCandidate | ||
} |
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.
With the change of moving the old scale to be deprecated as it was, I think we can revert this one, right?
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.
This mostly affects the codemod stuff, I think instead of mapping
rounded
torounded-sm
etc. we should map it to the newradius-*
utilities but leave the values as-is 🤔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.
Ah wait this is more complicated, we can only migrate to
radius-*
when we the value is defined in the JS config, the compat layer only worksrounded-*
utilitiesThere 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.
I guess also only if the theme is overwritten. 🤔
Consider this configuration:
I expect this to create a
--radius-4xl: 2rem
variable (which it does currently) however, the other breakpoints will now be in the--rounded
namespace, causing an inconsistency now becauseradius-4xl
exists butradius-3xl
doesn't.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.
I think the v4 equivalent is actually
if custom happens to be
4xl
: not much we do here I think, although it would be cool if we can convert it toradius-8
but there might be an inherent meaning to the name so that's probably hard to do.