1.5.0 • Published 5 years ago

alpha-string-to-rgba v1.5.0

Weekly downloads
21
License
MIT
Repository
github
Last release
5 years ago

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).

1.5.0

5 years ago

1.4.1

6 years ago

1.4.0

6 years ago

1.3.0

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.0

6 years ago