diff --git a/CHANGELOG.md b/CHANGELOG.md index d96c8ab59dd4..11b1846de71b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add consistent base styles for buttons and form controls ([#15036](https://github.com/tailwindlabs/tailwindcss/pull/15036)) - _Upgrade (experimental)_: Convert `group-[]:flex` to `in-[.group]:flex` ([#15054](https://github.com/tailwindlabs/tailwindcss/pull/15054)) - _Upgrade (experimental)_: Add form reset styles to CSS files for compatibility with v3 ([#15036](https://github.com/tailwindlabs/tailwindcss/pull/15036)) +- _Upgrade (experimental)_: Migrate `ring` to `ring-3` ([#15063](https://github.com/tailwindlabs/tailwindcss/pull/15063)) ### Fixed diff --git a/integrations/upgrade/index.test.ts b/integrations/upgrade/index.test.ts index 438d64cf154e..a1dc7cd2fbb7 100644 --- a/integrations/upgrade/index.test.ts +++ b/integrations/upgrade/index.test.ts @@ -78,6 +78,9 @@ test(
+ + +
`, 'src/input.css': css` @tailwind base; @@ -111,6 +114,9 @@ test(
+ +
+ --- ./src/input.css --- @import 'tailwindcss'; @@ -2512,6 +2518,10 @@ test( DEFAULT: '0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1)', }, + ringWidth: { + DEFAULT: '4px', + }, + extend: { // Changes the "before" class definition. 'blur' -> 'blur-sm' is // not safe because 'blur' has a custom value. @@ -2541,6 +2551,7 @@ test(
+
`, }, @@ -2558,6 +2569,9 @@ test( --shadow-*: initial; --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1); + --ring-width-*: initial; + --ring-width: 4px; + --blur: var(--custom-default-blur); --radius-sm: var(--custom-rounded-sm); @@ -2601,6 +2615,7 @@ test(
+
" `) @@ -2608,7 +2623,7 @@ test( ) test( - 'make suffix-less migrations safe (e.g.: `blur`, `rounded`, `shadow`)', + 'make suffix-less migrations safe (e.g.: `blur`, `rounded`, `shadow`, `ring`)', { fs: { 'package.json': json` @@ -2633,7 +2648,7 @@ test( @tailwind utilities; `, 'index.html': html` -
+
`, 'example-component.tsx': ts` type Star = [ @@ -2643,10 +2658,11 @@ test( blur?: boolean, rounded?: boolean, shadow?: boolean, + ring?: boolean, ] - function Star({ point: [cx, cy, dim, blur, rounded, shadow] }: { point: Star }) { - return + function Star({ point: [cx, cy, dim, blur, rounded, shadow, ring] }: { point: Star }) { + return } `, }, @@ -2694,7 +2710,7 @@ test( } --- index.html --- -
+
--- example-component.tsx --- type Star = [ @@ -2704,10 +2720,11 @@ test( blur?: boolean, rounded?: boolean, shadow?: boolean, + ring?: boolean, ] - function Star({ point: [cx, cy, dim, blur, rounded, shadow] }: { point: Star }) { - return + function Star({ point: [cx, cy, dim, blur, rounded, shadow, ring] }: { point: Star }) { + return } " `) diff --git a/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.test.ts b/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.test.ts index f11a954922b2..62278a6f8f5f 100644 --- a/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.test.ts +++ b/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.test.ts @@ -20,6 +20,8 @@ test.each([ ['blur', 'blur-sm'], ['blur-sm', 'blur-xs'], + ['ring', 'ring-3'], + ['blur!', 'blur-sm!'], ['hover:blur', 'hover:blur-sm'], ['hover:blur!', 'hover:blur-sm!'], @@ -27,7 +29,7 @@ test.each([ ['hover:blur-sm', 'hover:blur-xs'], ['blur-sm!', 'blur-xs!'], ['hover:blur-sm!', 'hover:blur-xs!'], -])('%s => %s', async (candidate, result) => { +])('%s => %s (%#)', async (candidate, result) => { let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', { base: __dirname, }) diff --git a/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.ts b/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.ts index e0f7c6e60992..8d55a9d85fe8 100644 --- a/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.ts +++ b/packages/@tailwindcss-upgrade/src/template/codemods/legacy-classes.ts @@ -28,6 +28,8 @@ const LEGACY_CLASS_MAP = new Map([ ['blur', 'blur-sm'], ['blur-sm', 'blur-xs'], + + ['ring', 'ring-3'], ]) const THEME_KEYS = new Map([ @@ -47,6 +49,9 @@ const THEME_KEYS = new Map([ ['blur', '--blur'], ['blur-sm', '--blur-sm'], ['blur-xs', '--blur-xs'], + + ['ring', '--ring-width'], + ['ring-3', '--ring-width-3'], ]) const DESIGN_SYSTEMS = new DefaultMap((base) => { @@ -134,7 +139,7 @@ export async function legacyClasses( // The new theme value is not defined, which means we can't safely // migrate the utility. - if (customTo === undefined) { + if (customTo === undefined && defaultTo !== undefined) { continue }