From 3bcfbf7edcef484a55688ce6014d669c582a70cc Mon Sep 17 00:00:00 2001 From: LucasWolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Fri, 15 Apr 2022 13:11:20 -0300 Subject: [PATCH 1/9] :tada: Added range based message coloring --- README.md | 2 ++ action.yml | 6 ++++++ index.js | 12 +++++++++++- 3 files changed, 19 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 7582270..9a0ae1d 100644 --- a/README.md +++ b/README.md @@ -80,6 +80,8 @@ Gist Parameter | Description `logoPosition` | The position of the logo. `style` | The style like "flat" or "social". `cacheSeconds` | The cache lifetime in seconds (must be greater than 300). +`maxColorRange` | Maximum value for the value passaed as message. Used to define the message color. +`minColorRange` | Minimum value for the value passaed as message. Used to define the message color. ### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json) diff --git a/action.yml b/action.yml index 36c8fc7..467f186 100644 --- a/action.yml +++ b/action.yml @@ -49,6 +49,12 @@ inputs: cacheSeconds: description: 'The cache lifetime in seconds (must be greater than 300)' required: false + maxColorRange: + description: 'Maximum value for the value passaed as message. Used to define the message color.' + required: false + minColorRange: + description: 'Minimum value for the value passaed as message. Used to define the message color.' + required: false runs: using: 'node12' main: 'index.js' diff --git a/index.js b/index.js index aa402b6..7a542a9 100644 --- a/index.js +++ b/index.js @@ -24,12 +24,22 @@ try { const logoPosition = core.getInput('logoPosition'); const style = core.getInput('style'); const cacheSeconds = core.getInput('cacheSeconds'); + const minColorRange = core.getInput('minColorRange'); + const maxColorRange = core.getInput('maxColorRange'); if (labelColor != '') { content.labelColor = labelColor; } - if (color != '') { + if (minColorRange != '' && maxColorRange != '') { + var max = parseFloat(maxColorRange); + var min = parseFloat(minColorRange); + var val = parseFloat(content.message); + if (val < min) val = min; + if (val > max) val = max; + let hue = Math.floor((val - min) / (max - min) * 100); + content.color = "hsl(" + hue + ", 100%, 50%)"; + } else if (color != '') { content.color = color; } From 517bd6931a52f8fc9c5f299137b3d5de99475f7f Mon Sep 17 00:00:00 2001 From: LucasWolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Fri, 15 Apr 2022 23:55:40 -0300 Subject: [PATCH 2/9] :tada: Added more functionalities to color range Now the Range can be inverted and doesn't use the message anymore --- README.md | 6 ++++-- action.yml | 10 ++++++++-- index.js | 15 ++++++++++++--- 3 files changed, 24 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 9a0ae1d..9f15a86 100644 --- a/README.md +++ b/README.md @@ -80,8 +80,10 @@ Gist Parameter | Description `logoPosition` | The position of the logo. `style` | The style like "flat" or "social". `cacheSeconds` | The cache lifetime in seconds (must be greater than 300). -`maxColorRange` | Maximum value for the value passaed as message. Used to define the message color. -`minColorRange` | Minimum value for the value passaed as message. Used to define the message color. +`valColorRange` | Numerical value used to define the message color. +`maxColorRange` | Maximum value in the range used to define the message color. +`minColorRange` | Minimum value in the range used to define the message color. +`invertColorRange` | If the range should be inverted, causing a smaller value to have green color. ### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json) diff --git a/action.yml b/action.yml index 467f186..bcbb430 100644 --- a/action.yml +++ b/action.yml @@ -49,11 +49,17 @@ inputs: cacheSeconds: description: 'The cache lifetime in seconds (must be greater than 300)' required: false + valColorRange: + description: 'Numerical value used to define the message color.' + required: false maxColorRange: - description: 'Maximum value for the value passaed as message. Used to define the message color.' + description: 'Maximum value in the range used to define the message color.' required: false minColorRange: - description: 'Minimum value for the value passaed as message. Used to define the message color.' + description: 'Minimum value in the range used to define the message color.' + required: false + invertColorRange: + description: 'If the range should be inverted, causing a smaller value to have green color.' required: false runs: using: 'node12' diff --git a/index.js b/index.js index 7a542a9..5e282e8 100644 --- a/index.js +++ b/index.js @@ -24,20 +24,29 @@ try { 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'); if (labelColor != '') { content.labelColor = labelColor; } - if (minColorRange != '' && maxColorRange != '') { + if (minColorRange != '' && maxColorRange != '' && valColorRange != '') { var max = parseFloat(maxColorRange); var min = parseFloat(minColorRange); - var val = parseFloat(content.message); + var val = parseFloat(valColorRange); if (val < min) val = min; if (val > max) val = max; - let hue = Math.floor((val - min) / (max - min) * 100); + var hue = 0 + if (invertColorRange == '') { + hue = Math.floor((val - min) / (max - min) * 100); + message = val + " / " + max + " " + message + } else { + hue = Math.floor((max - val) / (max - min) * 100); + message = val + " " + message + } content.color = "hsl(" + hue + ", 100%, 50%)"; } else if (color != '') { content.color = color; From a690d6b4cb88a68a669fda7ad0521d8ada943d89 Mon Sep 17 00:00:00 2001 From: LucasWolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sat, 16 Apr 2022 01:47:26 -0300 Subject: [PATCH 3/9] :beetle: Fixed empty message bug in range feature Fixed by adding back 'console.' which was removed for testing --- index.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/index.js b/index.js index 5e282e8..496d2da 100644 --- a/index.js +++ b/index.js @@ -42,10 +42,10 @@ try { var hue = 0 if (invertColorRange == '') { hue = Math.floor((val - min) / (max - min) * 100); - message = val + " / " + max + " " + message + content.message = val + " / " + max + " " + content.message } else { hue = Math.floor((max - val) / (max - min) * 100); - message = val + " " + message + content.message = val + " " + content.message } content.color = "hsl(" + hue + ", 100%, 50%)"; } else if (color != '') { From 0ba52741d3ba9a9d752ae33ccb61650a76a45239 Mon Sep 17 00:00:00 2001 From: LucasWolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sat, 16 Apr 2022 02:05:36 -0300 Subject: [PATCH 4/9] :wrench: Improved messages for color range feature --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 496d2da..6bf00df 100644 --- a/index.js +++ b/index.js @@ -45,7 +45,7 @@ try { content.message = val + " / " + max + " " + content.message } else { hue = Math.floor((max - val) / (max - min) * 100); - content.message = val + " " + content.message + content.message = valColorRange + " " + content.message } content.color = "hsl(" + hue + ", 100%, 50%)"; } else if (color != '') { From b71805028343137467438fdfcc09ea987a58754b Mon Sep 17 00:00:00 2001 From: Wolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sat, 16 Apr 2022 10:51:12 -0300 Subject: [PATCH 5/9] Apply suggestions from code review Co-authored-by: Simon Schneegans --- index.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 6bf00df..695a34a 100644 --- a/index.js +++ b/index.js @@ -34,12 +34,12 @@ try { } if (minColorRange != '' && maxColorRange != '' && valColorRange != '') { - var max = parseFloat(maxColorRange); - var min = parseFloat(minColorRange); - var val = parseFloat(valColorRange); + const max = parseFloat(maxColorRange); + const min = parseFloat(minColorRange); + const val = parseFloat(valColorRange); if (val < min) val = min; if (val > max) val = max; - var hue = 0 + let hue = 0 if (invertColorRange == '') { hue = Math.floor((val - min) / (max - min) * 100); content.message = val + " / " + max + " " + content.message From 6d79bf4c0a22ffe0a91d8feb7cd9786928445c97 Mon Sep 17 00:00:00 2001 From: Wolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sun, 17 Apr 2022 11:16:41 -0300 Subject: [PATCH 6/9] Update index.js Removed automatically set message. Co-authored-by: Simon Schneegans --- index.js | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 695a34a..7b45337 100644 --- a/index.js +++ b/index.js @@ -41,11 +41,9 @@ try { if (val > max) val = max; let hue = 0 if (invertColorRange == '') { - hue = Math.floor((val - min) / (max - min) * 100); - content.message = val + " / " + max + " " + content.message + hue = Math.floor((val - min) / (max - min) * 120); } else { - hue = Math.floor((max - val) / (max - min) * 100); - content.message = valColorRange + " " + content.message + hue = Math.floor((max - val) / (max - min) * 120); } content.color = "hsl(" + hue + ", 100%, 50%)"; } else if (color != '') { From f3547450fab91331193d0bc5d7e69e3531be1456 Mon Sep 17 00:00:00 2001 From: Wolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sun, 17 Apr 2022 11:22:56 -0300 Subject: [PATCH 7/9] Update index.js Reduce the lightness from 50% to 40%. --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index 7b45337..df87a9a 100644 --- a/index.js +++ b/index.js @@ -45,7 +45,7 @@ try { } else { hue = Math.floor((max - val) / (max - min) * 120); } - content.color = "hsl(" + hue + ", 100%, 50%)"; + content.color = "hsl(" + hue + ", 100%, 40%)"; } else if (color != '') { content.color = color; } From 6363528813f1d00da4b959721e091bedb31796b1 Mon Sep 17 00:00:00 2001 From: Wolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sun, 17 Apr 2022 11:47:07 -0300 Subject: [PATCH 8/9] :tada: Added saturation and lightness parameters :tada: Added saturation and lightness parameters to ColorRange feature --- README.md | 2 ++ index.js | 14 ++++++++++++-- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 9f15a86..ac784b8 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,8 @@ Gist Parameter | Description `maxColorRange` | Maximum value in the range used to define the message color. `minColorRange` | Minimum value in the range used to define the message color. `invertColorRange` | If the range should be inverted, causing a smaller value to have green color. + `colorRangeSaturation` | Saturation used by the color range feature. Defaults to 100%. + `colorRangeLightness` | Lightness used by the color range feature. Defaults to 40%. ### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json) diff --git a/index.js b/index.js index df87a9a..da92642 100644 --- a/index.js +++ b/index.js @@ -28,6 +28,8 @@ try { 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; @@ -39,13 +41,21 @@ try { const val = parseFloat(valColorRange); if (val < min) val = min; if (val > max) val = max; - let hue = 0 + let hue = 0; if (invertColorRange == '') { hue = Math.floor((val - min) / (max - min) * 120); } else { hue = Math.floor((max - val) / (max - min) * 120); } - content.color = "hsl(" + hue + ", 100%, 40%)"; + let sat = 100; + if(colorRangeSaturation != '') { + sat = colorRangeSaturation; + } + let lig = 40; + if(colorRangeLightness != '') { + lig = colorRangeLightness; + } + content.color = "hsl(" + hue + ", " + sat + "%, " + lig + "%)"; } else if (color != '') { content.color = color; } From 53c821a382b450a702bce010f918b479d862eb56 Mon Sep 17 00:00:00 2001 From: Wolfgang <39681420+LucasWolfgang@users.noreply.github.com> Date: Sun, 17 Apr 2022 11:51:01 -0300 Subject: [PATCH 9/9] :tada: Added saturation and lightness parameters :tada: Added saturation and lightness parameters to ColorRange feature --- README.md | 4 ++-- action.yml | 6 ++++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index ac784b8..a68a5ec 100644 --- a/README.md +++ b/README.md @@ -84,8 +84,8 @@ Gist Parameter | Description `maxColorRange` | Maximum value in the range used to define the message color. `minColorRange` | Minimum value in the range used to define the message color. `invertColorRange` | If the range should be inverted, causing a smaller value to have green color. - `colorRangeSaturation` | Saturation used by the color range feature. Defaults to 100%. - `colorRangeLightness` | Lightness used by the color range feature. Defaults to 40%. +`colorRangeSaturation` | Saturation used by the color range feature. Defaults to 100%. +`colorRangeLightness` | Lightness used by the color range feature. Defaults to 40%. ### Using Environment Variables as Parameters [![badge](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json)](https://img.shields.io/endpoint?url=https://gist.githubusercontent.com/schneegans/2ab8f1d386f13aaebccbd87dac94068d/raw/answer.json) diff --git a/action.yml b/action.yml index bcbb430..2742a53 100644 --- a/action.yml +++ b/action.yml @@ -61,6 +61,12 @@ inputs: invertColorRange: description: 'If the range should be inverted, causing a smaller value to have green color.' required: false + colorRangeSaturation: + description: 'Saturation used by the color range feature. Defaults to 100%.' + required: false + colorRangeLightness: + description: 'Lightness used by the color range feature. Defaults to 40%. + required: false runs: using: 'node12' main: 'index.js'