react-linear-gradient-picker
Version:
React linear gradient picker
11 lines (8 loc) • 331 B
text/typescript
import { Color } from '../../../types';
/**
* Formats an rgba into a css rgb/a property
* @param color - The color object to format
* @returns Formatted RGB/RGBA string
*/
const formatRgb = ({ r, g, b, a = 1 }: Color): string => (a !== 1 ? `rgba(${r}, ${g}, ${b}, ${a})` : `rgb(${r}, ${g}, ${b})`);
export default formatRgb;