Skip to content

Commit

Permalink
small fix to make it work for odd browsers
Browse files Browse the repository at this point in the history
Make the code work when browser don't support @Property
and --color don't is parsed as color by the browser
  • Loading branch information
jcubic committed Feb 19, 2024
1 parent 2fc573e commit 23edba9
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/js/terminal.js
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ var terminal = (function($) {
tooltip.css({
'--left': left,
'--top': top,
'--color': contrast_color(color),
'--color': contrast_color(color) || 'black',
'--background': color,
'--right': right
}).addClass(cls.join(' '));
Expand All @@ -258,6 +258,9 @@ var terminal = (function($) {
// ref: https://codepen.io/ikarium/pen/yXPQpo MIT
function contrast_color(rgba){
rgba = rgba.match(/\d+/g);
if (!rgba) {
return;
}
if ((rgba[0] * 0.299) + (rgba[1] * 0.587) + (rgba[2] * 0.114) > 186) {
return 'black';
} else {
Expand Down

0 comments on commit 23edba9

Please sign in to comment.