Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
31 changes: 24 additions & 7 deletions integrations/upgrade/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,9 @@ test(

<!-- Migrate to 2xs -->
<div class="shadow-xs inset-shadow-xs"></div>

<!-- Migrate to -3 -->
<div class="ring"></div>
`,
'src/input.css': css`
@tailwind base;
Expand Down Expand Up @@ -111,6 +114,9 @@ test(
<!-- Migrate to 2xs -->
<div class="shadow-2xs inset-shadow-2xs"></div>

<!-- Migrate to -3 -->
<div class="ring-3"></div>

--- ./src/input.css ---
@import 'tailwindcss';

Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -2541,6 +2551,7 @@ test(
<div class="shadow shadow-sm shadow-xs"></div>
<div class="blur blur-sm"></div>
<div class="rounded rounded-sm"></div>
<div class="ring"></div>
</div>
`,
},
Expand All @@ -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);
Expand Down Expand Up @@ -2601,14 +2615,15 @@ test(
<div class="shadow shadow-sm shadow-xs"></div>
<div class="blur blur-xs"></div>
<div class="rounded rounded-sm"></div>
<div class="ring"></div>
</div>
"
`)
},
)

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`
Expand All @@ -2633,7 +2648,7 @@ test(
@tailwind utilities;
`,
'index.html': html`
<div class="rounded blur shadow"></div>
<div class="rounded blur shadow ring"></div>
`,
'example-component.tsx': ts`
type Star = [
Expand All @@ -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 <svg class="rounded shadow blur" filter={blur ? 'url(…)' : undefined} />
function Star({ point: [cx, cy, dim, blur, rounded, shadow, ring] }: { point: Star }) {
return <svg class="rounded shadow blur ring" filter={blur ? 'url(…)' : undefined} />
}
`,
},
Expand Down Expand Up @@ -2694,7 +2710,7 @@ test(
}

--- index.html ---
<div class="rounded-sm blur-sm shadow-sm"></div>
<div class="rounded-sm blur-sm shadow-sm ring-3"></div>

--- example-component.tsx ---
type Star = [
Expand All @@ -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 <svg class="rounded-sm shadow-sm blur-sm" filter={blur ? 'url(…)' : undefined} />
function Star({ point: [cx, cy, dim, blur, rounded, shadow, ring] }: { point: Star }) {
return <svg class="rounded-sm shadow-sm blur-sm ring-3" filter={blur ? 'url(…)' : undefined} />
}
"
`)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,16 @@ 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!'],

['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,
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand All @@ -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) => {
Expand Down Expand Up @@ -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
}

Expand Down