From 5892ba6b39af47211606ad4e08ee4ef2b3c1d401 Mon Sep 17 00:00:00 2001
From: Gaurav Mahlawat <gauravmahlawat@Gauravs-MacBook-Pro.local>
Date: Wed, 15 Feb 2023 14:07:15 +0530
Subject: [PATCH 1/2] Multi class array used in all templates in olivero theme

---
 .../templates/block/block--search-form-block.html.twig   | 8 +++++++-
 core/themes/olivero/templates/content/node.html.twig     | 8 +++++++-
 .../olivero/templates/content/search-result.html.twig    | 9 ++++++++-
 .../olivero/templates/navigation/book-tree.html.twig     | 9 ++++++++-
 .../templates/navigation/menu--primary-menu.html.twig    | 9 ++++++++-
 .../templates/navigation/menu--secondary-menu.html.twig  | 9 ++++++++-
 .../templates/navigation/menu-local-task.html.twig       | 8 +++++++-
 core/themes/olivero/templates/navigation/menu.html.twig  | 9 ++++++++-
 8 files changed, 61 insertions(+), 8 deletions(-)

diff --git a/core/themes/olivero/templates/block/block--search-form-block.html.twig b/core/themes/olivero/templates/block/block--search-form-block.html.twig
index c9e10583f1e..abd9004a53f 100644
--- a/core/themes/olivero/templates/block/block--search-form-block.html.twig
+++ b/core/themes/olivero/templates/block/block--search-form-block.html.twig
@@ -20,6 +20,12 @@
     'block-search',
   ]
 %}
+{%
+  set wrapper_classes = [
+    'content',
+    'container-inline',
+  ]
+%}
 <div{{ attributes.addClass(classes) }}>
   {{ title_prefix }}
   {% if label %}
@@ -27,7 +33,7 @@
   {% endif %}
   {{ title_suffix }}
   {% block content %}
-    <div{{ content_attributes.addClass('content', 'container-inline') }}>
+    <div{{ content_attributes.addClass(wrapper_classes) }}>
       {{ content }}
     </div>
   {% endblock %}
diff --git a/core/themes/olivero/templates/content/node.html.twig b/core/themes/olivero/templates/content/node.html.twig
index b8b3e2bbcf9..7cb92e35213 100644
--- a/core/themes/olivero/templates/content/node.html.twig
+++ b/core/themes/olivero/templates/content/node.html.twig
@@ -80,6 +80,12 @@
     view_mode ? 'node--view-mode-' ~ view_mode|clean_class,
   ]
 %}
+{%
+  set wrapper_classes = [
+    'node__content',
+    layout,
+  ]
+%}
 <article{{ attributes.addClass(classes) }}>
   <header class="{{ layout }}">
     {{ title_prefix }}
@@ -103,7 +109,7 @@
       </div>
     {% endif %}
   </header>
-  <div{{ content_attributes.addClass('node__content', layout) }}>
+  <div{{ content_attributes.addClass(wrapper_classes) }}>
     {# Comments not part of content, so they won't inherit .text-content styles. #}
     {{ content|without('comment') }}
   </div>
diff --git a/core/themes/olivero/templates/content/search-result.html.twig b/core/themes/olivero/templates/content/search-result.html.twig
index ae2207e3dfa..6cfcf643a6b 100644
--- a/core/themes/olivero/templates/content/search-result.html.twig
+++ b/core/themes/olivero/templates/content/search-result.html.twig
@@ -55,6 +55,13 @@
  * @see template_preprocess_search_result()
  */
 #}
+{%
+  set classes = [
+    'search-result__snippet',
+    layout,
+    'text-content',
+  ]
+%}
 {{ attach_library('olivero/search-results') }}
 {% if info_split %}
   <div class="search-result__meta">
@@ -76,5 +83,5 @@
   {{ title_suffix }}
 {% endif %}
 {% if snippet %}
-  <div{{ content_attributes.addClass('search-result__snippet', layout, 'text-content') }}>{{ snippet }}</div>
+  <div{{ content_attributes.addClass(classes) }}>{{ snippet }}</div>
 {% endif %}
diff --git a/core/themes/olivero/templates/navigation/book-tree.html.twig b/core/themes/olivero/templates/navigation/book-tree.html.twig
index bc16f5acce2..99d879fb201 100644
--- a/core/themes/olivero/templates/navigation/book-tree.html.twig
+++ b/core/themes/olivero/templates/navigation/book-tree.html.twig
@@ -20,6 +20,13 @@
 #}
 {% import _self as book_tree %}
 
+{%
+  set wrapper_classes = [
+    'book-navigation__menu menu',
+    'menu--level-' ~ (menu_level + 1),
+  ]
+%}
+
 {#
   We call a macro which calls itself to render the full tree.
   @see https://twig.symfony.com/doc/3.x/tags/macro.html
@@ -30,7 +37,7 @@
   {% import _self as book_tree %}
   {% if items %}
     {% if menu_level == 0 %}
-      <ul{{ attributes.addClass('book-navigation__menu menu', 'menu--level-' ~ (menu_level + 1)) }}>
+      <ul{{ attributes.addClass(wrapper_classes) }}>
     {% else %}
       <ul class='menu menu--level-{{ menu_level + 1 }}'>
     {% endif %}
diff --git a/core/themes/olivero/templates/navigation/menu--primary-menu.html.twig b/core/themes/olivero/templates/navigation/menu--primary-menu.html.twig
index 0338c1a1acd..eab23a2ff30 100644
--- a/core/themes/olivero/templates/navigation/menu--primary-menu.html.twig
+++ b/core/themes/olivero/templates/navigation/menu--primary-menu.html.twig
@@ -31,6 +31,13 @@
 {% set attributes = attributes.addClass('menu') %}
 {{ menus.menu_links(items, attributes, 0, 'primary-menu-item-') }}
 
+{%
+  set wrapper_classes = [
+    'primary-nav__menu',
+    primary_nav_level,
+  ]
+%}
+
 {% macro menu_links(items, attributes, menu_level, aria_id) %}
   {% set primary_nav_level = 'primary-nav__menu--level-' ~ (menu_level + 1) %}
   {% set drupal_selector_primary_nav_level = menu_level <= 1 ? 'primary-nav-menu--level-' ~ (menu_level + 1) : false %}
@@ -46,7 +53,7 @@
       <span data-drupal-selector="primary-nav-menu-🥕" class="primary-nav__menu-🥕"></span>
     {% endif %}
 
-    <ul {{ attributes.addClass('primary-nav__menu', primary_nav_level).setAttribute('data-drupal-selector', drupal_selector_primary_nav_level) }}>
+    <ul {{ attributes.addClass(wrapper_classes).setAttribute('data-drupal-selector', drupal_selector_primary_nav_level) }}>
       {% set attributes = attributes.removeClass(primary_nav_level) %}
       {% for item in items %}
 
diff --git a/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig b/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig
index 68d1b25b7d1..eb4e985a3dd 100644
--- a/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig
+++ b/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig
@@ -24,6 +24,13 @@
 
 {% import _self as menus %}
 
+{%
+  set wrapper_classes = [
+    'csecondary-nav__menu',
+    secondary_nav_level,
+  ]
+%}
+
 {#
   We call a macro which calls itself to render the full tree.
   @see https://twig.symfony.com/doc/3.x/tags/macro.html
@@ -35,7 +42,7 @@
   {% set secondary_nav_level = 'secondary-nav__menu--level-' ~ (menu_level + 1) %}
   {% import _self as menus %}
   {% if items %}
-    <ul{{ attributes.addClass('secondary-nav__menu', secondary_nav_level) }}>
+    <ul{{ attributes.addClass(wrapper_classes) }}>
       {% set attributes = attributes.removeClass(secondary_nav_level) %}
       {% for item in items %}
 
diff --git a/core/themes/olivero/templates/navigation/menu-local-task.html.twig b/core/themes/olivero/templates/navigation/menu-local-task.html.twig
index 34bbb1c44d4..49139617453 100644
--- a/core/themes/olivero/templates/navigation/menu-local-task.html.twig
+++ b/core/themes/olivero/templates/navigation/menu-local-task.html.twig
@@ -15,7 +15,13 @@
  * @see template_preprocess_menu_local_task()
  */
 #}
-<li{{ attributes.addClass('tabs__tab', is_active ? 'is-active') }}>
+{%
+  set wrapper_classes = [
+    'tabs__tab',
+    is_active ? 'is-active',
+  ]
+%}
+<li{{ attributes.addClass(wrapper_classes) }}>
   {{ link }}
   {% if is_active and level == 'primary' %}
     <button class="tabs__trigger" aria-label="{{ 'Tabs display toggle'|t }}" aria-expanded="false">
diff --git a/core/themes/olivero/templates/navigation/menu.html.twig b/core/themes/olivero/templates/navigation/menu.html.twig
index 1f7eda20267..926b9065dd8 100644
--- a/core/themes/olivero/templates/navigation/menu.html.twig
+++ b/core/themes/olivero/templates/navigation/menu.html.twig
@@ -22,6 +22,13 @@
 #}
 {% import _self as menus %}
 
+{%
+  set wrapper_classes = [
+    'menu',
+    primary_nav_level,
+  ]
+%}
+
 {#
   We call a macro which calls itself to render the full tree.
   @see https://twig.symfony.com/doc/3.x/tags/macro.html
@@ -33,7 +40,7 @@
   {% set primary_nav_level = 'menu--level-' ~ (menu_level + 1) %}
   {% import _self as menus %}
   {% if items %}
-    <ul {{ attributes.addClass('menu', primary_nav_level) }}>
+    <ul {{ attributes.addClass(wrapper_classes) }}>
       {% set attributes = attributes.removeClass(primary_nav_level) %}
       {% for item in items %}
 
-- 
GitLab


From 8eed571c15adb1c596763fe073421c05d1ce09f3 Mon Sep 17 00:00:00 2001
From: Gaurav Mahlawat <gauravmahlawat@Gauravs-MacBook-Pro.local>
Date: Thu, 16 Feb 2023 11:08:28 +0530
Subject: [PATCH 2/2] Fixed spelling mistake in classname

---
 .../olivero/templates/navigation/menu--secondary-menu.html.twig | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig b/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig
index eb4e985a3dd..7fe0f314104 100644
--- a/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig
+++ b/core/themes/olivero/templates/navigation/menu--secondary-menu.html.twig
@@ -26,7 +26,7 @@
 
 {%
   set wrapper_classes = [
-    'csecondary-nav__menu',
+    'secondary-nav__menu',
     secondary_nav_level,
   ]
 %}
-- 
GitLab

