Skip to content

Commit

Permalink
✨ Tweak formatting of the code
Browse files Browse the repository at this point in the history
  • Loading branch information
Schneegans committed Apr 18, 2022
1 parent 3dd7c22 commit e43bdee
Showing 1 changed file with 25 additions and 16 deletions.
41 changes: 25 additions & 16 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,53 +13,62 @@ try {
message: core.getInput('message')
};

// Get all optional attributes and add them to the content object if given.
const labelColor = core.getInput('labelColor');
// Compute the message color based on the given inputs.
const color = core.getInput('color');
const isError = core.getInput('isError');
const namedLogo = core.getInput('namedLogo');
const logoSvg = core.getInput('logoSvg');
const logoColor = core.getInput('logoColor');
const logoWidth = core.getInput('logoWidth');
const logoPosition = core.getInput('logoPosition');
const style = core.getInput('style');
const cacheSeconds = core.getInput('cacheSeconds');
const valColorRange = core.getInput('valColorRange');
const minColorRange = core.getInput('minColorRange');
const maxColorRange = core.getInput('maxColorRange');
const invertColorRange = core.getInput('invertColorRange');
const colorRangeSaturation = core.getInput('colorRangeSaturation');
const colorRangeLightness = core.getInput('colorRangeLightness');

if (labelColor != '') {
content.labelColor = labelColor;
}

if (minColorRange != '' && maxColorRange != '' && valColorRange != '') {
const max = parseFloat(maxColorRange);
const min = parseFloat(minColorRange);
const val = parseFloat(valColorRange);

if (val < min) val = min;
if (val > max) val = max;

let hue = 0;
if (invertColorRange == '') {
hue = Math.floor((val - min) / (max - min) * 120);
} else {
hue = Math.floor((max - val) / (max - min) * 120);
}

let sat = 100;
if (colorRangeSaturation != '') {
sat = colorRangeSaturation;
sat = parseFloat(colorRangeSaturation);
}

let lig = 40;
if (colorRangeLightness != '') {
lig = colorRangeLightness;
lig = parseFloat(colorRangeLightness);
}

content.color = 'hsl(' + hue + ', ' + sat + '%, ' + lig + '%)';

} else if (color != '') {

content.color = color;
}

// Get all optional attributes and add them to the content object if given.
const labelColor = core.getInput('labelColor');
const isError = core.getInput('isError');
const namedLogo = core.getInput('namedLogo');
const logoSvg = core.getInput('logoSvg');
const logoColor = core.getInput('logoColor');
const logoWidth = core.getInput('logoWidth');
const logoPosition = core.getInput('logoPosition');
const style = core.getInput('style');
const cacheSeconds = core.getInput('cacheSeconds');

if (labelColor != '') {
content.labelColor = labelColor;
}

if (isError != '') {
content.isError = isError;
}
Expand Down

0 comments on commit e43bdee

Please sign in to comment.