Skip to content

Commit d099f8b

Browse files
authored
Migrate default utilities to have a value suffix (#14875)
This PR adds a migration for migrating the changes we implemented in #14849 This is the migration we perform: | Old | New | | ----------------- | ------------------ | | `shadow` | `shadow-sm` | | `shadow-sm` | `shadow-xs` | | `shadow-xs` | `shadow-2xs` | | `inset-shadow` | `inset-shadow-sm` | | `inset-shadow-sm` | `inset-shadow-xs` | | `inset-shadow-xs` | `inset-shadow-2xs` | | `drop-shadow` | `drop-shadow-sm` | | `drop-shadow-sm` | `drop-shadow-xs` | | `rounded` | `rounded-sm` | | `rounded-sm` | `rounded-xs` | | `blur` | `blur-sm` | | `blur-sm` | `blur-xs` | Also added an integration test to ensure that `shadow` is properly migrated to `shadow-sm`, and doesn't get migrated to `shadow-xs` (because `shadow-sm` is migrated to `shadow-xs`).
1 parent 4e16410 commit d099f8b

File tree

4 files changed

+55
-0
lines changed

4 files changed

+55
-0
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
1313
- Add `svh`, `dvh`, `svw`, `dvw`, and `auto` values to all width/height/size utilities ([#14857](https://github.com/tailwindlabs/tailwindcss/pull/14857))
1414
- _Upgrade (experimental)_: Migrate `grid-cols-[subgrid]` and `grid-rows-[subgrid]` to `grid-cols-subgrid` and `grid-rows-subgrid` ([#14840](https://github.com/tailwindlabs/tailwindcss/pull/14840))
1515
- _Upgrade (experimental)_: Support migrating projects with multiple config files ([#14863](https://github.com/tailwindlabs/tailwindcss/pull/14863))
16+
- _Upgrade (experimental)_: Rename `shadow` to `shadow-sm`, `shadow-sm` to `shadow-xs`, and `shadow-xs` to `shadow-2xs` ([#14875](https://github.com/tailwindlabs/tailwindcss/pull/14875))
17+
- _Upgrade (experimental)_: Rename `inset-shadow` to `inset-shadow-sm`, `inset-shadow-sm` to `inset-shadow-xs`, and `inset-shadow-xs` to `inset-shadow-2xs` ([#14875](https://github.com/tailwindlabs/tailwindcss/pull/14875))
18+
- _Upgrade (experimental)_: Rename `drop-shadow` to `drop-shadow-sm` and `drop-shadow-sm` to `drop-shadow-xs` ([#14875](https://github.com/tailwindlabs/tailwindcss/pull/14875))
19+
- _Upgrade (experimental)_: Rename `rounded` to `rounded-sm` and `rounded-sm` to `rounded-xs` ([#14875](https://github.com/tailwindlabs/tailwindcss/pull/14875))
20+
- _Upgrade (experimental)_: Rename `blur` to `blur-sm` and `blur-sm` to `blur-xs` ([#14875](https://github.com/tailwindlabs/tailwindcss/pull/14875))
1621

1722
### Fixed
1823

integrations/upgrade/index.test.ts

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ test(
7171
<div
7272
class="!flex sm:!block bg-gradient-to-t bg-[--my-red] max-w-screen-md ml-[theme(screens.md)]"
7373
></div>
74+
<!-- Migrate to sm -->
75+
<div class="blur shadow rounded inset-shadow drop-shadow"></div>
76+
77+
<!-- Migrate to xs -->
78+
<div class="blur-sm shadow-sm rounded-sm inset-shadow-sm drop-shadow-sm"></div>
79+
80+
<!-- Migrate to 2xs -->
81+
<div class="shadow-xs inset-shadow-xs"></div>
7482
`,
7583
'src/input.css': css`
7684
@tailwind base;
@@ -95,6 +103,14 @@ test(
95103
<div
96104
class="flex! sm:block! bg-linear-to-t bg-[var(--my-red)] max-w-[var(--breakpoint-md)] ml-[var(--breakpoint-md)]"
97105
></div>
106+
<!-- Migrate to sm -->
107+
<div class="blur-sm shadow-sm rounded-sm inset-shadow-sm drop-shadow-sm"></div>
108+
109+
<!-- Migrate to xs -->
110+
<div class="blur-xs shadow-xs rounded-xs inset-shadow-xs drop-shadow-xs"></div>
111+
112+
<!-- Migrate to 2xs -->
113+
<div class="shadow-2xs inset-shadow-2xs"></div>
98114
99115
--- ./src/input.css ---
100116
@import 'tailwindcss';

packages/@tailwindcss-upgrade/src/template/codemods/simple-legacy-classes.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,23 @@ test.each([
1515
['max-lg:hover:decoration-slice', 'max-lg:hover:box-decoration-slice'],
1616
['max-lg:hover:decoration-slice!', 'max-lg:hover:box-decoration-slice!'],
1717
['max-lg:hover:!decoration-slice', 'max-lg:hover:box-decoration-slice!'],
18+
19+
['shadow', 'shadow-sm'],
20+
['shadow-sm', 'shadow-xs'],
21+
['shadow-xs', 'shadow-2xs'],
22+
23+
['inset-shadow', 'inset-shadow-sm'],
24+
['inset-shadow-sm', 'inset-shadow-xs'],
25+
['inset-shadow-xs', 'inset-shadow-2xs'],
26+
27+
['drop-shadow', 'drop-shadow-sm'],
28+
['drop-shadow-sm', 'drop-shadow-xs'],
29+
30+
['rounded', 'rounded-sm'],
31+
['rounded-sm', 'rounded-xs'],
32+
33+
['blur', 'blur-sm'],
34+
['blur-sm', 'blur-xs'],
1835
])('%s => %s', async (candidate, result) => {
1936
let designSystem = await __unstable__loadDesignSystem('@import "tailwindcss";', {
2037
base: __dirname,

packages/@tailwindcss-upgrade/src/template/codemods/simple-legacy-classes.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,23 @@ const LEGACY_CLASS_MAP = {
1313
'flex-shrink-0': 'shrink-0',
1414
'decoration-clone': 'box-decoration-clone',
1515
'decoration-slice': 'box-decoration-slice',
16+
17+
shadow: 'shadow-sm',
18+
'shadow-sm': 'shadow-xs',
19+
'shadow-xs': 'shadow-2xs',
20+
21+
'inset-shadow': 'inset-shadow-sm',
22+
'inset-shadow-sm': 'inset-shadow-xs',
23+
'inset-shadow-xs': 'inset-shadow-2xs',
24+
25+
'drop-shadow': 'drop-shadow-sm',
26+
'drop-shadow-sm': 'drop-shadow-xs',
27+
28+
rounded: 'rounded-sm',
29+
'rounded-sm': 'rounded-xs',
30+
31+
blur: 'blur-sm',
32+
'blur-sm': 'blur-xs',
1633
}
1734

1835
const SEEDED = new WeakSet<DesignSystem>()

0 commit comments

Comments
 (0)