From 703b1415e23b79e0103889cce88884b4e2c02bfd Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Tue, 4 Mar 2025 08:21:34 +0100
Subject: [PATCH] Add show_transparent_header opt.

---
 .../organisms/header/photo_header.html         |  2 +-
 .../organisms/header/simple_header.html        |  4 +++-
 ...niwebflexiblepage_show_tansparent_header.py | 18 ++++++++++++++++++
 uniweb/models.py                               | 10 ++++++++++
 .../templates/uniweb/uniweb_flexible_page.html |  2 +-
 5 files changed, 33 insertions(+), 3 deletions(-)
 create mode 100644 uniweb/migrations/0118_uniwebflexiblepage_show_tansparent_header.py

diff --git a/shared/templates/styleguide2/includes/organisms/header/photo_header.html b/shared/templates/styleguide2/includes/organisms/header/photo_header.html
index 9b2452aa..09d7fa4b 100644
--- a/shared/templates/styleguide2/includes/organisms/header/photo_header.html
+++ b/shared/templates/styleguide2/includes/organisms/header/photo_header.html
@@ -14,7 +14,7 @@
     bg-no-repeat bg-cover bg-center bg-blend-darken bg-[top_right_-7rem]
 
     {% if background_image %}
-      bg-[#00000088]
+      {% if not show_tansparent_header %}bg-[#00000088]{% endif %}
     {% else %}
       bg-black
     {% endif %}
diff --git a/shared/templates/styleguide2/includes/organisms/header/simple_header.html b/shared/templates/styleguide2/includes/organisms/header/simple_header.html
index f6769383..6e51d606 100644
--- a/shared/templates/styleguide2/includes/organisms/header/simple_header.html
+++ b/shared/templates/styleguide2/includes/organisms/header/simple_header.html
@@ -27,7 +27,9 @@
         {% block extra_classes %}{% endblock %}
 
         {% if background_image %}
-          bg-[#00000088] bg-no-repeat bg-cover bg-center bg-blend-darken bg-[top_right_-7rem]
+          {% if not show_tansparent_header %}bg-[#00000088]{% endif %}
+          
+          bg-no-repeat bg-cover bg-center bg-blend-darken bg-[top_right_-7rem]
         {% else %}
           bg-black
         {% endif %}
diff --git a/uniweb/migrations/0118_uniwebflexiblepage_show_tansparent_header.py b/uniweb/migrations/0118_uniwebflexiblepage_show_tansparent_header.py
new file mode 100644
index 00000000..457de51c
--- /dev/null
+++ b/uniweb/migrations/0118_uniwebflexiblepage_show_tansparent_header.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.7 on 2025-03-04 07:10
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('uniweb', '0117_uniwebhomepage_has_expanded_navbar'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='uniwebflexiblepage',
+            name='show_tansparent_header',
+            field=models.BooleanField(default=False, help_text='Pokud je toto pole zaškrtlé, obrázek na pozadí hlavičky se neztmaví.', verbose_name='Průhledná hlavička?'),
+        ),
+    ]
diff --git a/uniweb/models.py b/uniweb/models.py
index 36af722c..3186a74b 100644
--- a/uniweb/models.py
+++ b/uniweb/models.py
@@ -256,6 +256,15 @@ class UniwebFlexiblePage(
 ):
     ### FIELDS
 
+    show_tansparent_header = models.BooleanField(
+        default=False,
+        verbose_name="Průhledná hlavička?",
+        help_text=(
+            "Pokud je toto pole zaškrtlé, obrázek na pozadí hlavičky "
+            "se neztmavĂ­."
+        )
+    )
+
     main_image = models.ForeignKey(
         "wagtailimages.Image",
         on_delete=models.PROTECT,
@@ -279,6 +288,7 @@ class UniwebFlexiblePage(
     content_panels = Page.content_panels + [
         FieldPanel("content"),
         FieldPanel("main_image"),
+        FieldPanel("show_tansparent_header"),
     ]
 
     edit_handler = TabbedInterface(
diff --git a/uniweb/templates/uniweb/uniweb_flexible_page.html b/uniweb/templates/uniweb/uniweb_flexible_page.html
index 02403c08..13ec6ac3 100644
--- a/uniweb/templates/uniweb/uniweb_flexible_page.html
+++ b/uniweb/templates/uniweb/uniweb_flexible_page.html
@@ -5,5 +5,5 @@
 {% endblock %}
 
 {% block header %}
-  {% include 'styleguide2/includes/organisms/header/photo_header.html' with title=page.title main_image=page.main_image show_scroll_progress=page.show_scroll_progress %}
+  {% include 'styleguide2/includes/organisms/header/photo_header.html' with show_tansparent_header=page.show_tansparent_header title=page.title main_image=page.main_image show_scroll_progress=page.show_scroll_progress %}
 {% endblock %}
-- 
GitLab