Migrate grid-cols-[subgrid] and grid-rows-[subgrid] to grid-cols-subgrid and grid-rows-subgrid (#14840)

This PR adds a migration to convert `grid-cols-[subgrid]` to
`grid-cols-subgrid` and `grid-rows-[subgrid]` to `grid-rows-subgrid`.
This commit is contained in:
Robin Malfait 2024-11-01 21:25:53 +01:00 committed by GitHub
parent cf77420b0c
commit baed3aabe2
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 22 additions and 0 deletions

View File

@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
## [Unreleased]
### Added
- _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))
### Fixed
- Detect classes in new files when using `@tailwindcss/postcss` ([#14829](https://github.com/tailwindlabs/tailwindcss/pull/14829))

View File

@ -8,6 +8,9 @@ test.each([
['col-start-[7]', 'col-start-7'],
['flex-[2]', 'flex-2'], // `flex` is implemented as static and functional utilities
['grid-cols-[subgrid]', 'grid-cols-subgrid'],
['grid-rows-[subgrid]', 'grid-rows-subgrid'],
// Only 50-200% (inclusive) are valid:
// https://developer.mozilla.org/en-US/docs/Web/CSS/font-stretch#percentage
['font-stretch-[50%]', 'font-stretch-50%'],

View File

@ -14,6 +14,21 @@ export function arbitraryValueToBareValue(
let clone = structuredClone(candidate)
let changed = false
// Convert [subgrid] to subgrid
if (
clone.kind === 'functional' &&
clone.value?.kind === 'arbitrary' &&
clone.value.value === 'subgrid' &&
(clone.root === 'grid-cols' || clone.root == 'grid-rows')
) {
changed = true
clone.value = {
kind: 'named',
value: 'subgrid',
fraction: null,
}
}
// Convert utilities that accept bare values ending in %
if (
clone.kind === 'functional' &&