styled-components
Version:
Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
13 lines (10 loc) • 421 B
JavaScript
// @flow
const chars = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'.split('')
/* Some high number, usually 9-digit base-10. Map it to base-😎 */
const generateAlphabeticName = (code: number) => {
const lastDigit = chars[code % chars.length]
return code > chars.length
? `${generateAlphabeticName(Math.floor(code / chars.length))}${lastDigit}`
: lastDigit
}
export default generateAlphabeticName