From 4c7f3166d4d46535d5b1e0adb46de80c2d135b9e Mon Sep 17 00:00:00 2001 From: bgamard Date: Sat, 15 Feb 2020 23:00:35 +0100 Subject: [PATCH] Closes #332: tag text color legibility --- .../src/app/docs/directive/InvertTextColor.js | 25 +++++++++++++++++++ docs-web/src/main/webapp/src/index.html | 1 + .../src/partial/docs/directive.selecttag.html | 2 +- .../webapp/src/partial/docs/document.html | 2 +- .../src/partial/docs/document.view.html | 2 +- 5 files changed, 29 insertions(+), 3 deletions(-) create mode 100644 docs-web/src/main/webapp/src/app/docs/directive/InvertTextColor.js diff --git a/docs-web/src/main/webapp/src/app/docs/directive/InvertTextColor.js b/docs-web/src/main/webapp/src/app/docs/directive/InvertTextColor.js new file mode 100644 index 00000000..986c5049 --- /dev/null +++ b/docs-web/src/main/webapp/src/app/docs/directive/InvertTextColor.js @@ -0,0 +1,25 @@ +'use strict'; + +/** + * Invert text color for more legibility directive. + */ +angular.module('docs').directive('invertTextColor', function () { + return { + restrict: 'A', + link: function(scope, element, attrs) { + attrs.$observe('invertTextColor', function(hex) { + if (!hex || hex.length !== 7) { + return; + } + + hex = hex.slice(1); + var r = parseInt(hex.slice(0, 2), 16), + g = parseInt(hex.slice(2, 4), 16), + b = parseInt(hex.slice(4, 6), 16); + element.css('color', (r * 0.299 + g * 0.587 + b * 0.114) > 186 + ? '#000000' + : '#FFFFFF'); + }); + } + } +}); \ No newline at end of file diff --git a/docs-web/src/main/webapp/src/index.html b/docs-web/src/main/webapp/src/index.html index 1accf21a..69bbd935 100644 --- a/docs-web/src/main/webapp/src/index.html +++ b/docs-web/src/main/webapp/src/index.html @@ -107,6 +107,7 @@ + diff --git a/docs-web/src/main/webapp/src/partial/docs/directive.selecttag.html b/docs-web/src/main/webapp/src/partial/docs/directive.selecttag.html index 2c333a44..d74716f0 100644 --- a/docs-web/src/main/webapp/src/partial/docs/directive.selecttag.html +++ b/docs-web/src/main/webapp/src/partial/docs/directive.selecttag.html @@ -1,7 +1,7 @@
- + {{ tag.name }}
diff --git a/docs-web/src/main/webapp/src/partial/docs/document.view.html b/docs-web/src/main/webapp/src/partial/docs/document.view.html index d4d3905e..5b61db02 100644 --- a/docs-web/src/main/webapp/src/partial/docs/document.view.html +++ b/docs-web/src/main/webapp/src/partial/docs/document.view.html @@ -63,7 +63,7 @@