Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add spaces to gradients and grid track names when followed by calc() #12704

Merged
merged 3 commits into from
Jan 3, 2024
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 @@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Fixed

- Don't remove keyframe stops when using important utilities ([#12639](https://github.com/tailwindlabs/tailwindcss/pull/12639))
- Don't add spaces to gradients and grid track names when followed by `calc()` ([#12704](https://github.com/tailwindlabs/tailwindcss/pull/12704))

### Added

Expand Down
12 changes: 12 additions & 0 deletions src/util/dataTypes.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,13 @@ function normalizeMathOperatorSpacing(value) {
'keyboard-inset-left',
'keyboard-inset-width',
'keyboard-inset-height',

'radial-gradient',
'linear-gradient',
'conic-gradient',
'repeating-radial-gradient',
'repeating-linear-gradient',
'repeating-conic-gradient',
]

return value.replace(/(calc|min|max|clamp)\(.+\)/g, (match) => {
Expand Down Expand Up @@ -162,6 +169,11 @@ function normalizeMathOperatorSpacing(value) {
result += consumeUntil([')'])
}

// Don't break CSS grid track names
else if (peek('[')) {
result += consumeUntil([']'])
}

// Handle operators
else if (
['+', '-', '*', '/'].includes(char) &&
Expand Down
10 changes: 10 additions & 0 deletions tests/normalize-data-types.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,16 @@ let table = [
// Prevent formatting keywords
['minmax(min-content,25%)', 'minmax(min-content,25%)'],

// Prevent formatting keywords
[
'radial-gradient(calc(1+2)),radial-gradient(calc(1+2))',
'radial-gradient(calc(1 + 2)),radial-gradient(calc(1 + 2))',
],
[
'[content-start]_calc(100%-1px)_[content-end]_minmax(1rem,1fr)',
'[content-start] calc(100% - 1px) [content-end] minmax(1rem,1fr)',
],

// Misc
['color(0_0_0/1.0)', 'color(0 0 0/1.0)'],
['color(0_0_0_/_1.0)', 'color(0 0 0 / 1.0)'],
Expand Down