forked from mirrors/bookwyrm
Add dark mode
This commit is contained in:
parent
bf503d370c
commit
b47edc5f0d
2 changed files with 14 additions and 6 deletions
|
@ -196,14 +196,21 @@ def generate_preview_image(texts={}, picture=None, rating=None, show_instance_la
|
|||
|
||||
|
||||
# Color
|
||||
if BG_COLOR == "use_dominant_color":
|
||||
if BG_COLOR in ["use_dominant_color_light", "use_dominant_color_dark"]:
|
||||
image_bg_color = "rgb(%s, %s, %s)" % dominant_color
|
||||
# Lighten color
|
||||
|
||||
# Adjust color
|
||||
image_bg_color_rgb = [x / 255.0 for x in ImageColor.getrgb(image_bg_color)]
|
||||
image_bg_color_hls = colorsys.rgb_to_hls(*image_bg_color_rgb)
|
||||
|
||||
if BG_COLOR == "use_dominant_color_light":
|
||||
lightness = max(0.9, image_bg_color_hls[1])
|
||||
else:
|
||||
lightness = min(0.15, image_bg_color_hls[1])
|
||||
|
||||
image_bg_color_hls = (
|
||||
image_bg_color_hls[0],
|
||||
max(0.9, image_bg_color_hls[1]),
|
||||
lightness,
|
||||
image_bg_color_hls[2],
|
||||
)
|
||||
image_bg_color = tuple(
|
||||
|
|
|
@ -39,11 +39,12 @@ DEFAULT_AUTO_FIELD = "django.db.models.AutoField"
|
|||
|
||||
# Preview image
|
||||
|
||||
# Specify RGB tuple or RGB hex strings, or 'use_dominant_color'
|
||||
PREVIEW_BG_COLOR = "use_dominant_color"
|
||||
# Specify RGB tuple or RGB hex strings,
|
||||
# or "use_dominant_color_light" / "use_dominant_color_dark"
|
||||
PREVIEW_BG_COLOR = "use_dominant_color_dark"
|
||||
PREVIEW_IMG_WIDTH = 1200
|
||||
PREVIEW_IMG_HEIGHT = 630
|
||||
PREVIEW_TEXT_COLOR = "#363636"
|
||||
PREVIEW_TEXT_COLOR = "#FFF"
|
||||
PREVIEW_DEFAULT_COVER_COLOR = "#002549"
|
||||
|
||||
# Quick-start development settings - unsuitable for production
|
||||
|
|
Loading…
Reference in a new issue