diff options
Diffstat (limited to 'node_modules/tailwindcss/src/util/nameClass.js')
| -rw-r--r-- | node_modules/tailwindcss/src/util/nameClass.js | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/node_modules/tailwindcss/src/util/nameClass.js b/node_modules/tailwindcss/src/util/nameClass.js new file mode 100644 index 0000000..cb37dba --- /dev/null +++ b/node_modules/tailwindcss/src/util/nameClass.js @@ -0,0 +1,30 @@ +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}` +} |