mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix color application in dark mode
This commit is contained in:
parent
2c8f751455
commit
57bbbf97a8
@ -125,30 +125,28 @@ class HighlightStyle:
|
|||||||
def highlight_style_as_css(s, is_dark, foreground):
|
def highlight_style_as_css(s, is_dark, foreground):
|
||||||
|
|
||||||
def styler(node):
|
def styler(node):
|
||||||
node = node.style
|
def set(name, val):
|
||||||
|
if val:
|
||||||
|
node.style.setProperty(name, val, 'important')
|
||||||
|
|
||||||
if s.kind is 'decoration':
|
if s.kind is 'decoration':
|
||||||
if s.type is 'builtin':
|
if s.type is 'builtin':
|
||||||
keys = builtin_decorations_dark[s.which] if is_dark else builtin_decorations_light[s.which]
|
keys = builtin_decorations_dark[s.which] if is_dark else builtin_decorations_light[s.which]
|
||||||
else:
|
else:
|
||||||
keys = s
|
keys = s
|
||||||
if keys['text-decoration-line']:
|
set('text-decoration-line', keys['text-decoration-line'])
|
||||||
node.textDecorationLine = keys['text-decoration-line']
|
set('text-decoration-color', keys['text-decoration-color'])
|
||||||
if keys['text-decoration-color']:
|
set('text-decoration-style', keys['text-decoration-style'])
|
||||||
node.textDecorationColor = keys['text-decoration-color']
|
|
||||||
if keys['text-decoration-style']:
|
|
||||||
node.textDecorationStyle = keys['text-decoration-style']
|
|
||||||
return
|
return
|
||||||
|
|
||||||
|
bg = fg = None
|
||||||
if s.type is 'builtin':
|
if s.type is 'builtin':
|
||||||
if s.kind is 'color':
|
if s.kind is 'color':
|
||||||
node.backgroundColor = builtin_color(s.which, is_dark)
|
bg = builtin_color(s.which, is_dark)
|
||||||
if foreground:
|
if foreground:
|
||||||
node.color = foreground
|
fg = foreground
|
||||||
return
|
set('background-color', bg or s['background-color'] or default_color(is_dark))
|
||||||
node.backgroundColor = s['background-color'] or default_color(is_dark)
|
set('color', fg or s.color or foreground)
|
||||||
fg = s.color or foreground
|
|
||||||
if fg:
|
|
||||||
node.color = fg
|
|
||||||
|
|
||||||
return styler
|
return styler
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user