alpha-string-to-rgba
v1.5.0
Published
Converts alpha strings (`red.5`) to rgba (`rgba(255, 0, 0, 0.5)`).
Downloads
3
Readme
Alpha String to RGBa
Converts alpha strings (red.5
) to rgba (rgba(255, 0, 0, 0.5)
).
Features
Takes a colors object and a value, returning a new string which is the rgba, hex, or css color name representation calculated from the given value.
import aToRGBa from 'alpha-string-to-rgba';
const colorMap = {
aqua: '#7fdbff',
blue: '#0074d9',
lime: '#01ff70',
navy: '#001f3f',
teal: '#39cccc',
olive: '#3d9970',
green: '#2ecc40',
red: '#ff4136',
maroon: '#85144b',
orange: '#ff851b',
purple: '#b10dc9',
yellow: '#ffdc00',
fuchsia: '#f012be',
gray: '#aaaaaa',
white: '#ffffff',
black: '#111111',
silver: '#dddddd'
};
const getColor = aToRGBa(colorMap);
getColor('red'); // '#ff4136';
getColor('red.5') // 'rgba(255, 65, 54, 0.5)'
Getting Started
❯ yarn add alpha-string-to-rgba