mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 20:38:41 -09:00
* Use parent xo config in app/ * lint: Fix xo 0.17 errors * app: add missing semver dependency
13 lines
429 B
JavaScript
13 lines
429 B
JavaScript
const Color = require('color');
|
|
|
|
// returns a background color that's in hex
|
|
// format including the alpha channel (e.g.: `#00000050`)
|
|
// input can be any css value (rgb, hsl, string…)
|
|
module.exports = bgColor => {
|
|
const color = Color(bgColor);
|
|
if (color.alpha() === 1) {
|
|
return color.hexString();
|
|
}
|
|
// (╯°□°)╯︵ ┻━┻
|
|
return '#' + Math.floor(color.alpha() * 100) + color.hexString().substr(1);
|
|
};
|