All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.src.util.nameClass.js Maven / Gradle / Ivy

There is a newer version: 3.4.15
Show newest version
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}`
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy