mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Make input controls dark in the dark theme
This commit is contained in:
parent
c82c7d1a27
commit
c96a1dc31e
@ -7,6 +7,7 @@ LIGHT = '#F6F3E9'
|
||||
LIGHT_DARKER = '#b6b3a8'
|
||||
LIGHT_GRADIENT = 'linear-gradient(to bottom, {}, {})'.format(LIGHT, LIGHT_DARKER)
|
||||
DT_DARK = '#2d2d2d'
|
||||
DT_DARK_DARKER = 'black'
|
||||
DT_DARK_LIGHTER = '#777'
|
||||
DT_LIGHT = '#ddd'
|
||||
DARK_GRADIENT = 'linear-gradient(to bottom, {}, {})'.format(DT_DARK_LIGHTER, DT_DARK)
|
||||
@ -46,6 +47,10 @@ DEFAULT_COLORS = {
|
||||
'dialog-background': c(LIGHT, DT_DARK),
|
||||
'dialog-background-image': c(LIGHT_GRADIENT, DARK_GRADIENT),
|
||||
'dialog-foreground': c(DARK, DT_LIGHT),
|
||||
|
||||
# Native controls
|
||||
'input-background': c('field', DT_DARK_DARKER),
|
||||
'input-foreground': c('fieldtext', DT_LIGHT),
|
||||
}
|
||||
|
||||
DEFAULT_SIZES = {
|
||||
@ -68,13 +73,14 @@ def set_ui_colors(is_dark_theme):
|
||||
|
||||
|
||||
def css_for_variables():
|
||||
input_css = 'input, textarea { color: var(--calibre-color-input-foreground); background-color: var(--calibre-color-input-background); }'
|
||||
is_dark_theme = window.matchMedia('(prefers-color-scheme: dark)').matches
|
||||
attr = 'dark' if is_dark_theme else 'light'
|
||||
ans = v'[]'
|
||||
for k in DEFAULT_COLORS:
|
||||
val = DEFAULT_COLORS[k][attr]
|
||||
ans.push(f'--calibre-color-{k}: {val};')
|
||||
return ':root { ' + ans.join('\n') + '}'
|
||||
return ':root { ' + ans.join('\n') + '}\n\n' + input_css
|
||||
|
||||
|
||||
def get_color(name):
|
||||
|
Loading…
x
Reference in New Issue
Block a user