From 2df1f3f326d1abd82e8281f9f55552c5289039fb Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1=C5=A1=20Valenta?= <tomas@imaniti.org>
Date: Sat, 1 Jun 2024 13:36:00 +0200
Subject: [PATCH] move dropdown to separate blocks

---
 .../atoms/dropdown/dropdown_item.html         |  5 ++++
 .../patterns/molecules/dropdown/dropdown.html | 18 +++++++++++++++
 .../organisms/layout/district/navbar.html     | 23 +------------------
 3 files changed, 24 insertions(+), 22 deletions(-)
 create mode 100644 majak_uistyleguide/templates/patterns/atoms/dropdown/dropdown_item.html
 create mode 100644 majak_uistyleguide/templates/patterns/molecules/dropdown/dropdown.html

diff --git a/majak_uistyleguide/templates/patterns/atoms/dropdown/dropdown_item.html b/majak_uistyleguide/templates/patterns/atoms/dropdown/dropdown_item.html
new file mode 100644
index 0000000..177c7ec
--- /dev/null
+++ b/majak_uistyleguide/templates/patterns/atoms/dropdown/dropdown_item.html
@@ -0,0 +1,5 @@
+<li>
+  <a href="{{ url }}">
+    {{ name }}
+  </a>
+</li>
\ No newline at end of file
diff --git a/majak_uistyleguide/templates/patterns/molecules/dropdown/dropdown.html b/majak_uistyleguide/templates/patterns/molecules/dropdown/dropdown.html
new file mode 100644
index 0000000..a602989
--- /dev/null
+++ b/majak_uistyleguide/templates/patterns/molecules/dropdown/dropdown.html
@@ -0,0 +1,18 @@
+<div
+  class="dropdown nav-link js-scroll-anchor"
+  tabindex="0"
+>
+  <div class="dropbtn">
+    {{ name }}
+
+    <span class="drop-arrow">
+      <i class="ico--chevron-down"></i>
+    </span>
+  </div>
+
+  <ul class="dropdown-content">
+    {% for nested_item in menu_items %}
+      {% include "patterns/atoms/dropdown/dropdown_item.html" with name=nested_item.name url=nested_item.url %}
+    {% endfor %}
+  </ul>
+</div>
\ No newline at end of file
diff --git a/majak_uistyleguide/templates/patterns/organisms/layout/district/navbar.html b/majak_uistyleguide/templates/patterns/organisms/layout/district/navbar.html
index a64d85d..aec6282 100644
--- a/majak_uistyleguide/templates/patterns/organisms/layout/district/navbar.html
+++ b/majak_uistyleguide/templates/patterns/organisms/layout/district/navbar.html
@@ -66,27 +66,6 @@
   {% endfor %}
 
   {% for parent in menu_parents %}
-    <div
-      class="dropdown nav-link js-scroll-anchor"
-      tabindex="0"
-    >
-      <div class="dropbtn">
-        {{ parent.name }}
-
-        <span class="drop-arrow">
-          <i class="ico--chevron-down"></i>
-        </span>
-      </div>
-
-      <div class="dropdown-content">
-        {% for nested_item in parent.menu_items %}
-          <li>
-            <a href="{{ nested_item.url }}">
-              {{ nested_item.name }}
-            </a>
-          </li>
-        {% endfor %}
-      </div>
-    </div>
+    {% include "patterns/molecules/dropdown/dropdown.html" with name=parent.name menu_items=parent.menu_items %}
   {% endfor %}
 {% endblock %}
\ No newline at end of file
-- 
GitLab