hyper/app/utils/to-electron-background-color.js
Guillermo Rauch 8a01f8a48b Add window bgcolor updates (#524)
* transparent + reactive background colors

* refactor header to not set its own background color

* make terms not set background color

* dramatically improve tab borders

* remove background color from electron windows

* Revert "remove background color from electron windows"

This reverts commit ca4de3c5dc28095f1a598f7ac79d4dff4b66ccd5.

* put alpha first for electron

* remove initial bg color setting, but maintain reactive one

* fix
2016-09-19 08:47:33 +02:00

14 lines
478 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 = function toElectronBackgroundColor (bgColor) {
const color = Color(bgColor);
if (1 !== color.alpha()) {
// (╯°□°)╯︵ ┻━┻
return '#' + Math.floor(color.alpha() * 100) + color.hexString().substr(1);
} else {
return color.hexString();
}
};