@primer/primitives
Version:
Typography, spacing, and color primitives for Primer design system
21 lines (20 loc) • 519 B
JavaScript
// check if a value is an rgba float object
export const isRgbaFloat = (value) => {
if (value &&
typeof value === `object` &&
'r' in value &&
typeof value.r === `number` &&
'g' in value &&
typeof value.g === `number` &&
'b' in value &&
typeof value.b === `number` &&
value.r >= 0 &&
value.r <= 1 &&
value.g >= 0 &&
value.g <= 1 &&
value.b >= 0 &&
value.b <= 1) {
return true;
}
return false;
};