Skip to content

Commit 36bf31b

Browse files
committed
Replace color inverter with css variable
1 parent 8702020 commit 36bf31b

File tree

2 files changed

+4
-16
lines changed

2 files changed

+4
-16
lines changed

src/blame_inline.py

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,6 @@ def extra_cli_args(self, line_num):
3333
def _view(self):
3434
return self.view
3535

36-
def get_inline_blame_color(self):
37-
"""
38-
This method inverts the current background color and adds alpha, basically doing:
39-
#ffffff -> rgba(0, 0, 0, 0.3)
40-
The color is than used inside the style template. That is how we make
41-
sure inline blame is visible in both dark and light color schemes.
42-
"""
43-
bg = self.view.style().get("background")[1:]
44-
colors = [int(bg[i : i + 2], 16) for i in range(0, len(bg), 2)]
45-
colors_inverted = [str(255 - i) for i in colors]
46-
return "rgba({}, {}, {}, 0.3)".format(*colors_inverted)
47-
4836
def show_inline_blame(self):
4937
if self.view.is_dirty():
5038
# If there have already been unsaved edits, stop the git child process from being ran at all.
@@ -70,7 +58,7 @@ def show_inline_blame(self):
7058
if not blame:
7159
return
7260
body = blame_inline_phantom_html_template.format(
73-
css=blame_inline_phantom_css.format(color=self.get_inline_blame_color()),
61+
css=blame_inline_phantom_css,
7462
author=blame["author"],
7563
# TODO: add pretty format of the date, like "3 days ago"
7664
date=blame["date"],

src/templates.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,9 @@
100100

101101

102102
blame_inline_phantom_css = """
103-
div.phantom {{
104-
color: {color};
103+
div.phantom {
104+
color: color(var(--bluish) blend(var(--background) 60%));
105105
padding: 0;
106106
margin-left: 50px;
107-
}}
107+
}
108108
"""

0 commit comments

Comments
 (0)