Skip to content
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
migrate negative arbitrary values to negative bare values
  • Loading branch information
RobinMalfait committed Jun 3, 2025
commit 5d142f8d31a09b64d2159a8de599b3f2a17d883e
Original file line number Diff line number Diff line change
Expand Up @@ -159,14 +159,21 @@ export function migrateArbitraryUtilities(
candidate.kind === 'arbitrary' ? candidate.value : (candidate.value?.value ?? null)
if (value === null) return

let spacingMultiplier = spacing.get(designSystem)?.get(value)
let spacingMultiplier = spacing.get(designSystem)?.get(value) ?? null
let rootPrefix = ''
if (spacingMultiplier !== null && spacingMultiplier < 0) {
rootPrefix = '-'
spacingMultiplier = Math.abs(spacingMultiplier)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is also an option 🤔

Suggested change
spacingMultiplier = Math.abs(spacingMultiplier)
spacingMultiplier *= -1

}

for (let root of Array.from(designSystem.utilities.keys('functional')).sort(
// Sort negative roots after positive roots so that we can try
// `mt-*` before `-mt-*`. This is especially useful in situations where
// `-mt-[0px]` can be translated to `mt-[0px]`.
(a, z) => Number(a[0] === '-') - Number(z[0] === '-'),
)) {
if (rootPrefix) root = `${rootPrefix}${root}`

// Try as bare value
for (let replacementCandidate of parseCandidate(designSystem, `${root}-${value}`)) {
yield replacementCandidate
Expand Down