mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* WIP * Add failing test for negating default values * Add dynamic negative value opt-in (#5713) * Add `supportsNegativeValues` plugin option * Update `getClassList` to support dynamic negative values * Add test for using a negative scale value with a plugin that does not support dynamic negative values * Support dynamic negation of `DEFAULT` values (#5718) * Add test case Co-authored-by: Brad Cornes <bradlc41@gmail.com>
27 lines
559 B
JavaScript
27 lines
559 B
JavaScript
import escapeClassName from './escapeClassName'
|
|
import escapeCommas from './escapeCommas'
|
|
|
|
function asClass(name) {
|
|
return escapeCommas(`.${escapeClassName(name)}`)
|
|
}
|
|
|
|
export default function nameClass(classPrefix, key) {
|
|
return asClass(formatClass(classPrefix, key))
|
|
}
|
|
|
|
export function formatClass(classPrefix, key) {
|
|
if (key === 'DEFAULT') {
|
|
return classPrefix
|
|
}
|
|
|
|
if (key === '-' || key === '-DEFAULT') {
|
|
return `-${classPrefix}`
|
|
}
|
|
|
|
if (key.startsWith('-')) {
|
|
return `-${classPrefix}${key}`
|
|
}
|
|
|
|
return `${classPrefix}-${key}`
|
|
}
|