philipp-spiess fc261bdcf7 Upgrade: Migrate max-w-screen-* candidates (#14754)
This PR migrates `max-w-screen-*` candidates to the v4 equivalent relying on the breakpoint var: `max-w-[var(--breakpoint-*)]`
2024-10-22 16:40:42 +00:00

27 lines
741 B
TypeScript

import type { Config } from 'tailwindcss'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'
import { printCandidate } from '../candidates'
export function maxWidthScreen(
designSystem: DesignSystem,
_userConfig: Config,
rawCandidate: string,
): string {
for (let candidate of designSystem.parseCandidate(rawCandidate)) {
if (
candidate.kind === 'functional' &&
candidate.root === 'max-w' &&
candidate.value?.value.startsWith('screen-')
) {
return printCandidate(designSystem, {
...candidate,
value: {
...candidate.value,
value: `[theme(screens.${candidate.value.value.slice(7)})]`,
},
})
}
}
return rawCandidate
}