Add theme color support via instance.yaml

Allow instances to override primary CSS color variables
through theme section in instance.yaml config.
This commit is contained in:
Petr 2026-03-11 00:42:10 +01:00
parent e35e602c59
commit 954aa0f17e
3 changed files with 23 additions and 0 deletions

View file

@ -107,6 +107,11 @@ class Config:
INSTANCE_SUBTITLE = _get(_instance, "instance", "subtitle", default="")
INSTANCE_COPYRIGHT = _get(_instance, "instance", "copyright", default="")
# Theme colors (optional overrides from instance config)
THEME_PRIMARY = _get(_instance, "theme", "primary", default="")
THEME_PRIMARY_DARK = _get(_instance, "theme", "primary_dark", default="")
THEME_PRIMARY_LIGHT = _get(_instance, "theme", "primary_light", default="")
# Telegram bot
TELEGRAM_BOT_USERNAME = _get(_instance, "telegram", "bot_username", default="")

View file

@ -6,6 +6,15 @@
<title>{% block title %}Data Analyst Portal{% endblock %}</title>
<link rel="stylesheet" href="{{ static_url('style.css') }}">
<link rel="stylesheet" href="{{ static_url('style-custom.css') }}">
{% if config.THEME_PRIMARY %}
<style>
:root {
--primary: {{ config.THEME_PRIMARY }};
{% if config.THEME_PRIMARY_DARK %}--primary-dark: {{ config.THEME_PRIMARY_DARK }};{% endif %}
{% if config.THEME_PRIMARY_LIGHT %}--primary-light: {{ config.THEME_PRIMARY_LIGHT }};{% endif %}
}
</style>
{% endif %}
</head>
<body>
<div class="container">

View file

@ -6,6 +6,15 @@
<title>{% block title %}Data Analyst Portal{% endblock %}</title>
<link rel="stylesheet" href="{{ static_url('style.css') }}">
<link rel="stylesheet" href="{{ static_url('style-custom.css') }}">
{% if config.THEME_PRIMARY %}
<style>
:root {
--primary: {{ config.THEME_PRIMARY }};
{% if config.THEME_PRIMARY_DARK %}--primary-dark: {{ config.THEME_PRIMARY_DARK }};{% endif %}
{% if config.THEME_PRIMARY_LIGHT %}--primary-light: {{ config.THEME_PRIMARY_LIGHT }};{% endif %}
}
</style>
{% endif %}
</head>
<body>
{% with messages = get_flashed_messages(with_categories=true) %}