How to use the jss.createGenerateClassName function in jss

To help you get started, we’ve selected a few jss examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github rambler-digital-solutions / rambler-ui / src / theme / index.js View on Github external
export const createGenerateClassName = (themeId = 0) => {
  const generateClassName = originalCreateGenerateClassName()
  return (rule, sheet) => {
    const displayNamePrefix = sheet
      ? sheet.options[RAMBLER_UI_CLASS_NAME_PREFIX]
      : ''
    if (!displayNamePrefix) return generateClassName(rule, sheet)
    const jssId = sheet ? sheet.options.jss.id : globalJss.id
    const jssCounter = jssId === globalJss.id ? '' : `-${jssId}`
    const themeCounter = themeId === 0 ? '' : `-${themeId}`
    return ruiPrefix + displayNamePrefix + rule.key + jssCounter + themeCounter
  }
}