alpha-string-to-rgba
TypeScript icon, indicating that this package has built-in type declarations

1.5.0 • Public • Published

Alpha String to RGBa

Converts alpha strings (red.5) to rgba (rgba(255, 0, 0, 0.5)).

PRs Welcome Travis Tested with Jest semantic-release Commitizen friendly Conventional Commits styled with prettier license

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

Licence

The MIT License (MIT).

Readme

Keywords

none

Package Sidebar

Install

npm i alpha-string-to-rgba

Weekly Downloads

1

Version

1.5.0

License

MIT

Unpacked Size

41.8 kB

Total Files

13

Last publish

Collaborators

  • vinspee