From 5e0ee813959146b250109530d0fffaf93e71f2c2 Mon Sep 17 00:00:00 2001 From: b3z Date: Sat, 23 Jan 2021 14:40:12 +0100 Subject: [PATCH] Complementary lang colors (#76) --- README.md | 2 +- source/plugins/languages/index.mjs | 5 ++++- tests/metrics.test.js | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 4a613927..ae73f56c 100644 --- a/README.md +++ b/README.md @@ -1067,7 +1067,7 @@ It is possible to use custom colors for languages if those provided by GitHub do You can specify either an index with a color, or a language name (case insensitive) with a color. Colors can be either in hexadecimal format or a [named color](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value). -Use the special value `rainbow` to use rainbow colors. +Use the special value `rainbow` to use rainbow colors. Use `complementary` to use [complementary colors](https://en.wikipedia.org/wiki/Complementary_colors). diff --git a/source/plugins/languages/index.mjs b/source/plugins/languages/index.mjs index fed20962..36d0fc28 100644 --- a/source/plugins/languages/index.mjs +++ b/source/plugins/languages/index.mjs @@ -14,6 +14,9 @@ //Custom colors if (`${colors}` === "rainbow") colors = ["0:#ff0000", "1:#ffa500", "2:#ffff00", "3:#008000", "4:#0000ff", "5:#4b0082", "6:#ee82ee", "7:#162221"] + if (`${colors}` === "complementary") + colors = ["0:#ff0000", "1:#008000", "2:#ffa500", "3:#0000ff", "4:#ffff00", "5:#4b0082", "6:#162221", "7:#ee82ee"] + colors = Object.fromEntries(decodeURIComponent(colors).split(",").map(x => x.trim().toLocaleLowerCase()).filter(x => x).map(x => x.split(":").map(x => x.trim()))) console.debug(`metrics/compute/${login}/plugins > languages > custom colors ${JSON.stringify(colors)}`) //Iterate through user's repositories and retrieve languages data @@ -54,4 +57,4 @@ catch (error) { throw {error:{message:"An error occured", instance:error}} } - } \ No newline at end of file + } diff --git a/tests/metrics.test.js b/tests/metrics.test.js index b064ba28..b881c877 100644 --- a/tests/metrics.test.js +++ b/tests/metrics.test.js @@ -149,7 +149,7 @@ }], ["Language plugin (custom color set)", { plugin_languages:true, - plugin_languages_colors:"rainbow", + plugin_languages_colors:"complementary", }], ["Language plugin (complete)", { plugin_languages:true,