MCPcopy Create free account
hub / github.com/ambassify/react-avatar / getRandomColor

Function getRandomColor

src/utils.js:79–94  ·  view source on GitHub ↗
(value, colors = defaultColors)

Source from the content-addressed store, hash-verified

77
78export
79function getRandomColor(value, colors = defaultColors)
80{
81 // if no value is passed, always return transparent color otherwise
82 // a rerender would show a new color which would will
83 // give strange effects when an interface is loading
84 // and gets rerendered a few consequent times
85 if(!value)
86 return 'transparent';
87
88 // value based random color index
89 // the reason we don't just use a random number is to make sure that
90 // a certain value will always get the same color assigned given
91 // a fixed set of colors
92 const colorIndex = _stringAsciiPRNG(value, colors.length);
93 return colors[colorIndex];
94}
95
96export
97function parseSize(size) {

Callers 2

IconSourceClass · 0.90
getColorMethod · 0.90

Calls 1

_stringAsciiPRNGFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…