From 7640db402da95b90add69391c1b8b3a6379e7678 Mon Sep 17 00:00:00 2001 From: Ramon Wenger Date: Thu, 11 May 2023 16:29:03 +0200 Subject: [PATCH] Change colors in editor depending on environment theme Resolves MS-712 #complete --- server/core/settings.py | 1 + server/core/wagtail_hooks.py | 19 +++++++++++++++++-- 2 files changed, 18 insertions(+), 2 deletions(-) diff --git a/server/core/settings.py b/server/core/settings.py index 79af64da..edcf1071 100644 --- a/server/core/settings.py +++ b/server/core/settings.py @@ -25,6 +25,7 @@ TEST = "test" in sys.argv ENABLE_SILKY = bool_value(os.environ.get("ENABLE_SILKY", "")) SERVE_VIA_WEBPACK = bool_value(os.environ.get("SERVE_VIA_WEBPACK", DEBUG)) ENABLE_SENTRY = not DEBUG or bool_value(os.environ.get("ENABLE_SENTRY_DEBUG", "")) +THEME = os.environ.get("THEME", "skillbox") ALLOWED_HOSTS = ["*"] diff --git a/server/core/wagtail_hooks.py b/server/core/wagtail_hooks.py index 3f5dccf8..d1b3ac0e 100644 --- a/server/core/wagtail_hooks.py +++ b/server/core/wagtail_hooks.py @@ -13,9 +13,24 @@ from books.models import ContentBlockSnapshot from books.models.chapter import Chapter from books.models.contentblock import ContentBlock from core.logger import get_logger +from django.conf import settings logger = get_logger(__name__) +theme = settings.THEME +if theme == "my-kv": + primary = "#2075ff" + secondary = "#0ca87d" +elif theme == "my-dha": + primary = "#1bab4e" + secondary = "#139ee0" +elif theme == "my-dhf": + primary = "#139ee0" + secondary = "#1bab4e" +else: + primary = "#17A887" + secondary = "#078CC6" + # 1. Use the register_rich_text_features hook. @hooks.register("register_rich_text_features") @@ -32,7 +47,7 @@ def register_brand_feature(features): "type": type_, "label": "Auszeichung Primär", "description": "Auszeichung Primär", - "style": {"color": "#17A887", "font-weight": "600"}, + "style": {"color": primary, "font-weight": "600"}, } # 3. Call register_editor_plugin to register the configuration for Draftail. @@ -70,7 +85,7 @@ def register_secondary_feature(features): "type": type_, "label": "Auszeichnung sekundär", "description": "Auszeichnung sekundär", - "style": {"color": "#078CC6", "font-weight": "600"}, + "style": {"color": secondary, "font-weight": "600"}, } # 3. Call register_editor_plugin to register the configuration for Draftail.