From 22493a9072d406500eaf5560c8cb38ed0baa8264 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Alexa=20Valentov=C3=A1?= <git@imaniti.org>
Date: Mon, 24 Feb 2025 22:15:22 +0100
Subject: [PATCH] add has_expanded_navbar

---
 ...08_districthomepage_has_expanded_navbar.py | 18 ++++++++++++++
 ...5_electionshomepage_has_expanded_navbar.py | 18 ++++++++++++++
 main/blocks.py                                | 13 +++++-----
 .../0146_mainhomepage_has_expanded_navbar.py  | 18 ++++++++++++++
 .../0147_alter_mainhomepage_content.py        | 20 ++++++++++++++++
 shared/models/main.py                         | 12 ++++++++++
 .../includes/molecules/menus/carousel.html    | 24 +++++++++++--------
 .../includes/organisms/layout/navbar.html     | 14 +++++++----
 ...0117_uniwebhomepage_has_expanded_navbar.py | 18 ++++++++++++++
 9 files changed, 135 insertions(+), 20 deletions(-)
 create mode 100644 district/migrations/0308_districthomepage_has_expanded_navbar.py
 create mode 100644 elections/migrations/0065_electionshomepage_has_expanded_navbar.py
 create mode 100644 main/migrations/0146_mainhomepage_has_expanded_navbar.py
 create mode 100644 main/migrations/0147_alter_mainhomepage_content.py
 create mode 100644 uniweb/migrations/0117_uniwebhomepage_has_expanded_navbar.py

diff --git a/district/migrations/0308_districthomepage_has_expanded_navbar.py b/district/migrations/0308_districthomepage_has_expanded_navbar.py
new file mode 100644
index 00000000..d3b61891
--- /dev/null
+++ b/district/migrations/0308_districthomepage_has_expanded_navbar.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.7 on 2025-02-24 21:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('district', '0307_alter_districthomepage_content'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='districthomepage',
+            name='has_expanded_navbar',
+            field=models.BooleanField(default=True, help_text='Pokud je toto pole zaškrtlé, navigační lišta bude vždy mít rezervované místo na obrazovce.', verbose_name='Má rozšířený navbar?'),
+        ),
+    ]
diff --git a/elections/migrations/0065_electionshomepage_has_expanded_navbar.py b/elections/migrations/0065_electionshomepage_has_expanded_navbar.py
new file mode 100644
index 00000000..a52099fa
--- /dev/null
+++ b/elections/migrations/0065_electionshomepage_has_expanded_navbar.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.7 on 2025-02-24 21:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('elections', '0064_remove_electionshomepage_menu_button_name_and_more'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='electionshomepage',
+            name='has_expanded_navbar',
+            field=models.BooleanField(default=True, help_text='Pokud je toto pole zaškrtlé, navigační lišta bude vždy mít rezervované místo na obrazovce.', verbose_name='Má rozšířený navbar?'),
+        ),
+    ]
diff --git a/main/blocks.py b/main/blocks.py
index dc9d7f8c..3cb239ad 100644
--- a/main/blocks.py
+++ b/main/blocks.py
@@ -7,6 +7,7 @@ from wagtail.blocks import (
     StructBlock,
     TextBlock,
     URLBlock,
+    BooleanBlock
 )
 from wagtail.images.blocks import ImageChooserBlock
 
@@ -67,12 +68,12 @@ class BoxesBlock(StructBlock):
 
 
 class HomePageCarouseSlideBlock(StructBlock):
-    desktop_line_1 = TextBlock(label="Desktop první řádek")
-    desktop_line_2 = TextBlock(label="Desktop druhý řádek")
+    desktop_line_1 = TextBlock(label="Desktop první řádek", required=False)
+    desktop_line_2 = TextBlock(label="Desktop druhý řádek", required=False)
 
-    mobile_line_1 = TextBlock(label="První mobilní řádek")
-    mobile_line_2 = TextBlock(label="Druhý mobilní řádek")
-    mobile_line_3 = TextBlock(label="Třetí mobilní řádek")
+    mobile_line_1 = TextBlock(label="První mobilní řádek", required=False)
+    mobile_line_2 = TextBlock(label="Druhý mobilní řádek", required=False)
+    mobile_line_3 = TextBlock(label="Třetí mobilní řádek", required=False)
 
     desktop_image = ImageChooserBlock(
         label="Obrázek nahrazující animaci (desktop)", required=False
@@ -91,7 +92,7 @@ class HomePageCarouseSlideBlock(StructBlock):
         help_text="Odkaz funguje i bez tlačítka. Pokud chceš tlačítko skrýt, nevyplňuj text.",
         required=False,
     )
-
+    
     class Meta:
         template = "styleguide2/includes/molecules/menus/carousel.html"
         icon = "form"
diff --git a/main/migrations/0146_mainhomepage_has_expanded_navbar.py b/main/migrations/0146_mainhomepage_has_expanded_navbar.py
new file mode 100644
index 00000000..43a5fbd2
--- /dev/null
+++ b/main/migrations/0146_mainhomepage_has_expanded_navbar.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.7 on 2025-02-24 21:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('main', '0145_alter_mainhomepage_content'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='mainhomepage',
+            name='has_expanded_navbar',
+            field=models.BooleanField(default=True, help_text='Pokud je toto pole zaškrtlé, navigační lišta bude vždy mít rezervované místo na obrazovce.', verbose_name='Má rozšířený navbar?'),
+        ),
+    ]
diff --git a/main/migrations/0147_alter_mainhomepage_content.py b/main/migrations/0147_alter_mainhomepage_content.py
new file mode 100644
index 00000000..a8dec082
--- /dev/null
+++ b/main/migrations/0147_alter_mainhomepage_content.py
@@ -0,0 +1,20 @@
+# Generated by Django 5.0.7 on 2025-02-24 21:14
+
+import shared.blocks.children.misc
+import wagtail.fields
+from django.db import migrations
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('main', '0146_mainhomepage_has_expanded_navbar'),
+    ]
+
+    operations = [
+        migrations.AlterField(
+            model_name='mainhomepage',
+            name='content',
+            field=wagtail.fields.StreamField([('carousel', 9), ('news', 12), ('people', 16), ('regions', 18), ('boxes', 26)], blank=True, block_lookup={0: ('wagtail.blocks.TextBlock', (), {'label': 'Desktop první řádek', 'required': False}), 1: ('wagtail.blocks.TextBlock', (), {'label': 'Desktop druhý řádek', 'required': False}), 2: ('wagtail.blocks.TextBlock', (), {'label': 'První mobilní řádek', 'required': False}), 3: ('wagtail.blocks.TextBlock', (), {'label': 'Druhý mobilní řádek', 'required': False}), 4: ('wagtail.blocks.TextBlock', (), {'label': 'Třetí mobilní řádek', 'required': False}), 5: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'Obrázek nahrazující animaci (desktop)', 'required': False}), 6: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'Obrázek nahrazující animaci (mobil / tablet)', 'required': False}), 7: ('wagtail.blocks.URLBlock', (), {'help_text': 'Bez odkazu tlačítko nebude viditelné.', 'label': 'Odkaz tlačítka', 'required': False}), 8: ('wagtail.blocks.CharBlock', (), {'help_text': 'Odkaz funguje i bez tlačítka. Pokud chceš tlačítko skrýt, nevyplňuj text.', 'label': 'Text tlačítka', 'required': False}), 9: ('wagtail.blocks.StructBlock', [[('desktop_line_1', 0), ('desktop_line_2', 1), ('mobile_line_1', 2), ('mobile_line_2', 3), ('mobile_line_3', 4), ('desktop_image', 5), ('mobile_image', 6), ('button_url', 7), ('button_text', 8)]], {}), 10: ('wagtail.blocks.CharBlock', (), {'help_text': 'Nejnovější články se načtou automaticky', 'label': 'Titulek'}), 11: ('wagtail.blocks.TextBlock', (), {'label': 'Popis', 'required': False}), 12: ('wagtail.blocks.StructBlock', [[('title', 10), ('description', 11)]], {'template': 'styleguide2/includes/organisms/articles/articles_section.html'}), 13: ('wagtail.blocks.CharBlock', (), {'label': 'První řádek titulku'}), 14: ('wagtail.blocks.CharBlock', (), {'label': 'Druhý řádek titulku', 'required': False}), 15: ('wagtail.blocks.ListBlock', (shared.blocks.children.misc.PersonBoxBlock,), {'label': 'Boxíky'}), 16: ('wagtail.blocks.StructBlock', [[('title_line_1', 13), ('title_line_2', 14), ('description', 11), ('list', 15)]], {}), 17: ('wagtail.blocks.CharBlock', (), {'help_text': 'Články pro regiony se načtou automaticky', 'label': 'Titulek'}), 18: ('wagtail.blocks.StructBlock', [[('title', 17)]], {}), 19: ('wagtail.blocks.CharBlock', (), {'label': 'Nadpis'}), 20: ('wagtail.blocks.URLBlock', (), {'label': 'Odkaz tlačítka'}), 21: ('wagtail.blocks.CharBlock', (), {'label': 'Text tlačítka'}), 22: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'Logo/obrázek'}), 23: ('wagtail.blocks.StructBlock', [[('button_link', 20), ('button_text', 21), ('title', 19), ('image', 22)]], {}), 24: ('wagtail.blocks.ListBlock', (23,), {'label': 'Boxíky'}), 25: ('wagtail.images.blocks.ImageChooserBlock', (), {'label': 'Obrázek pozadí', 'required': False}), 26: ('wagtail.blocks.StructBlock', [[('title', 19), ('list', 24), ('image', 25)]], {})}, verbose_name='Hlavní obsah'),
+        ),
+    ]
diff --git a/shared/models/main.py b/shared/models/main.py
index 390d51a4..070a4041 100644
--- a/shared/models/main.py
+++ b/shared/models/main.py
@@ -1069,6 +1069,17 @@ class MainHomePageMixin(
         "Matomo ID pro sledování návštěvnosti", blank=True, null=True
     )
 
+    has_expanded_navbar = models.BooleanField(
+        "Má rozšířený navbar?",
+        help_text=(
+            "Pokud je toto pole zaškrtlé, navigační lišta bude vždy "
+            "mít rezervované místo na obrazovce."
+        ),
+        default=True,
+        null=False,
+        blank=False
+    )
+
     content_panels = Page.content_panels + [
         FieldPanel("content"),
     ]
@@ -1091,6 +1102,7 @@ class MainHomePageMixin(
     settings_panels = [
         PageChooserPanel("gdpr_and_cookies_page"),
         FieldPanel("matomo_id"),
+        FieldPanel("has_expanded_navbar"),
         FieldPanel("fallback_image"),
     ]
 
diff --git a/shared/templates/styleguide2/includes/molecules/menus/carousel.html b/shared/templates/styleguide2/includes/molecules/menus/carousel.html
index 01eacf36..7f3c27a5 100644
--- a/shared/templates/styleguide2/includes/molecules/menus/carousel.html
+++ b/shared/templates/styleguide2/includes/molecules/menus/carousel.html
@@ -6,7 +6,7 @@
     <{% if self.button_url %}a{% else %}div{% endif %}
       class="
         {% block wrapper_classes %}
-          block h-[700px] xl:h-[70vh] relative
+          block relative xl:h-screen h-[70vh]
         {% endblock %}
 
         {% if self.button_url %}group cursor-pointer{% endif %}
@@ -79,16 +79,20 @@
           style="box-sizing: border-box"
         >
 
-          <h1 class="__header-carousel-mobile-text mb-4 px-5 flex-col text-black flex lg:hidden">
-            <div>{{ self.mobile_line_1 }}</div>
-            <div>{{ self.mobile_line_2 }}</div>
-            <div>{{ self.mobile_line_3 }}</div>
-          </h1>
+          {% if self.mobile_line_1 or self.mobile_line_2 or self.mobile_line_3 %}
+            <h1 class="__header-carousel-mobile-text mb-4 px-5 flex-col text-black flex lg:hidden">
+              <div>{{ self.mobile_line_1 }}</div>
+              <div>{{ self.mobile_line_2 }}</div>
+              <div>{{ self.mobile_line_3 }}</div>
+            </h1>
+          {% endif %}
 
-          <h1 class="__header-carousel-desktop-text mb-4 px-5 flex-col text-black hidden lg:flex">
-            <div>{{ self.desktop_line_1 }}</div>
-            <div>{{ self.desktop_line_2 }}</div>
-          </h1>
+          {% if self.desktop_line_1 or self.desktop_line_2 %}
+            <h1 class="__header-carousel-desktop-text mb-4 px-5 flex-col text-black hidden lg:flex">
+              <div>{{ self.desktop_line_1 }}</div>
+              <div>{{ self.desktop_line_2 }}</div>
+            </h1>
+          {% endif %}
 
           {% if self.button_url and self.button_text %}
             <div class="__header-carousel-button-wrapper ml-4 text-lg group">
diff --git a/shared/templates/styleguide2/includes/organisms/layout/navbar.html b/shared/templates/styleguide2/includes/organisms/layout/navbar.html
index bbd36994..4b544250 100644
--- a/shared/templates/styleguide2/includes/organisms/layout/navbar.html
+++ b/shared/templates/styleguide2/includes/organisms/layout/navbar.html
@@ -14,7 +14,11 @@
   class="
     fixed left-0 top-[-1px] z-20 w-full duration-200 navbar
 
-    {% if is_transparent %}xl:sticky{% else %}xl:absolute{% endif %}
+    {% if is_transparent and page.root_page.has_expanded_navbar %}
+      xl:sticky
+    {% else %}
+      xl:absolute
+    {% endif %}
 
     {% block extra_classes %}
       {% if is_transparent %}navbar--transparent{% endif %}
@@ -339,9 +343,11 @@
     window.onscroll = () => {
       const screenWidth = Math.max(document.documentElement.clientWidth || 0, window.innerWidth || 0)
 
-      /* if (screenWidth > 1199) {
-        return
-      } */
+      {% if not page.root_page.has_expanded_navbar %}
+        if (screenWidth > 1199) {
+          return
+        }
+      {% endif %}
 
       if (window.scrollY === 0) {
         if (initiallyHadTransparentClass) {
diff --git a/uniweb/migrations/0117_uniwebhomepage_has_expanded_navbar.py b/uniweb/migrations/0117_uniwebhomepage_has_expanded_navbar.py
new file mode 100644
index 00000000..2b5341db
--- /dev/null
+++ b/uniweb/migrations/0117_uniwebhomepage_has_expanded_navbar.py
@@ -0,0 +1,18 @@
+# Generated by Django 5.0.7 on 2025-02-24 21:04
+
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+
+    dependencies = [
+        ('uniweb', '0116_alter_uniwebhomepage_menu_button_content'),
+    ]
+
+    operations = [
+        migrations.AddField(
+            model_name='uniwebhomepage',
+            name='has_expanded_navbar',
+            field=models.BooleanField(default=True, help_text='Pokud je toto pole zaškrtlé, navigační lišta bude vždy mít rezervované místo na obrazovce.', verbose_name='Má rozšířený navbar?'),
+        ),
+    ]
-- 
GitLab