all files / lib/utils/ build-selector.js

100% Statements 1/1
100% Branches 0/0
100% Functions 1/1
100% Lines 1/1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15                           
import hash from 'string-hash'
 
/**
 * Build a css selector with hashes.
 * @param {string} className - A class name.
 * @param {Object} declarationsObj - A object of css declarations.
 * @returns {string} a class name with hashes.
 * @example
 * // returns 'app_1nlygtv'
 * buildSelector('app', {borderRadius: '2px', width: '100%'})
 */
export default (className, declarationsObj) => {
  return className + '_' + hash(JSON.stringify(declarationsObj)).toString(36)
}