Skip to content

Commit

Permalink
Migrate grid-cols-[subgrid] and grid-rows-[subgrid] to `grid-cols…
Browse files Browse the repository at this point in the history
…-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`.
  • Loading branch information
RobinMalfait authored Nov 1, 2024
1 parent cf77420 commit baed3aa
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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%'],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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' &&
Expand Down

0 comments on commit baed3aa

Please sign in to comment.