mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* Change `matchVariant` API to use positional arguments * Fix CS wip * Change match variant wrap modifier in an object Needed for compat w/ some group and peer plugins * Add modifier support to matchUtilities * refactor * Hoist utility modifier splitting * Rename fn * refactor * Add support for generic utility modifiers * Fix CS * wip * update types * Warn when using modifiers without the option * Allow modifiers to be a config object * Make sure we can return null from matchUtilities to omit rules * Feature flag generalized modifiers We’re putting a flag for modifiers in front of matchVariant and matchUtilities * cleanup * Update changelog * Properly flag variants using modifiers * Fix test
31 lines
634 B
JavaScript
31 lines
634 B
JavaScript
import escapeClassName from './escapeClassName'
|
|
import escapeCommas from './escapeCommas'
|
|
|
|
export 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}`
|
|
}
|
|
|
|
if (key.startsWith('/')) {
|
|
return `${classPrefix}${key}`
|
|
}
|
|
|
|
return `${classPrefix}-${key}`
|
|
}
|