You've already forked dynamic-badges-action
✨ Tweak formatting of the code
This commit is contained in:
41
index.js
41
index.js
@@ -13,17 +13,8 @@ try {
|
|||||||
message: core.getInput('message')
|
message: core.getInput('message')
|
||||||
};
|
};
|
||||||
|
|
||||||
// Get all optional attributes and add them to the content object if given.
|
// Compute the message color based on the given inputs.
|
||||||
const labelColor = core.getInput('labelColor');
|
|
||||||
const color = core.getInput('color');
|
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 valColorRange = core.getInput('valColorRange');
|
||||||
const minColorRange = core.getInput('minColorRange');
|
const minColorRange = core.getInput('minColorRange');
|
||||||
const maxColorRange = core.getInput('maxColorRange');
|
const maxColorRange = core.getInput('maxColorRange');
|
||||||
@@ -31,35 +22,53 @@ try {
|
|||||||
const colorRangeSaturation = core.getInput('colorRangeSaturation');
|
const colorRangeSaturation = core.getInput('colorRangeSaturation');
|
||||||
const colorRangeLightness = core.getInput('colorRangeLightness');
|
const colorRangeLightness = core.getInput('colorRangeLightness');
|
||||||
|
|
||||||
if (labelColor != '') {
|
|
||||||
content.labelColor = labelColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (minColorRange != '' && maxColorRange != '' && valColorRange != '') {
|
if (minColorRange != '' && maxColorRange != '' && valColorRange != '') {
|
||||||
const max = parseFloat(maxColorRange);
|
const max = parseFloat(maxColorRange);
|
||||||
const min = parseFloat(minColorRange);
|
const min = parseFloat(minColorRange);
|
||||||
const val = parseFloat(valColorRange);
|
const val = parseFloat(valColorRange);
|
||||||
|
|
||||||
if (val < min) val = min;
|
if (val < min) val = min;
|
||||||
if (val > max) val = max;
|
if (val > max) val = max;
|
||||||
|
|
||||||
let hue = 0;
|
let hue = 0;
|
||||||
if (invertColorRange == '') {
|
if (invertColorRange == '') {
|
||||||
hue = Math.floor((val - min) / (max - min) * 120);
|
hue = Math.floor((val - min) / (max - min) * 120);
|
||||||
} else {
|
} else {
|
||||||
hue = Math.floor((max - val) / (max - min) * 120);
|
hue = Math.floor((max - val) / (max - min) * 120);
|
||||||
}
|
}
|
||||||
|
|
||||||
let sat = 100;
|
let sat = 100;
|
||||||
if (colorRangeSaturation != '') {
|
if (colorRangeSaturation != '') {
|
||||||
sat = colorRangeSaturation;
|
sat = parseFloat(colorRangeSaturation);
|
||||||
}
|
}
|
||||||
|
|
||||||
let lig = 40;
|
let lig = 40;
|
||||||
if (colorRangeLightness != '') {
|
if (colorRangeLightness != '') {
|
||||||
lig = colorRangeLightness;
|
lig = parseFloat(colorRangeLightness);
|
||||||
}
|
}
|
||||||
|
|
||||||
content.color = 'hsl(' + hue + ', ' + sat + '%, ' + lig + '%)';
|
content.color = 'hsl(' + hue + ', ' + sat + '%, ' + lig + '%)';
|
||||||
|
|
||||||
} else if (color != '') {
|
} else if (color != '') {
|
||||||
|
|
||||||
content.color = 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 != '') {
|
if (isError != '') {
|
||||||
content.isError = isError;
|
content.isError = isError;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user