From 01e554f35f0c8d68313c37039ced691dabb6c38a Mon Sep 17 00:00:00 2001 From: Alexander Bias Date: Thu, 22 Aug 2024 13:05:29 +0200 Subject: [PATCH] Upgrade: Align the icons again properly on Moodle 4.4. --- CHANGES.md | 1 + lib.php | 4 +++- styles.css | 21 +-------------------- tests/behat/behat_local_navbarplus.php | 16 ++++++++-------- tests/behat/local_navbarplus.feature | 2 +- 5 files changed, 14 insertions(+), 30 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index dfc6077..ea3f227 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -6,6 +6,7 @@ Changes ### Unreleased +* 2024-08-22 - Upgrade: Align the icons again properly on Moodle 4.4. * 2024-08-20 - Prepare compatibility for Moodle 4.4. ### v4.3-r2 diff --git a/lib.php b/lib.php index 1b5db60..4355997 100644 --- a/lib.php +++ b/lib.php @@ -135,8 +135,10 @@ function local_navbarplus_render_navbar_output() { $linkattributes['target'] = '_blank'; $linkattributes['rel'] = 'noopener noreferrer'; } + // Set classes. + $linkattributes['class'] = 'nav-link position-relative icon-no-margin'; // Define classes for all icons. - $itemclasses = 'localnavbarplus nav-link'; + $itemclasses = 'localnavbarplus'; // Add optional individual classes. if (!empty($itemadditionalclasses)) { $itemclasses .= ' ' . $itemadditionalclasses; diff --git a/styles.css b/styles.css index 3a2c231..d89e7fb 100644 --- a/styles.css +++ b/styles.css @@ -1,23 +1,4 @@ -/* Float the icons left to be placed next to the existing icons "messages" and "notifications". */ -.navbar .localnavbarplus.nav-link { - float: left; -} - -/* Remove the right margin from each but the last icon to achieve the same margins for moodle and navbarplus icons. */ -.navbar .localnavbarplus.nav-link .icon { - margin-right: 0; -} -.navbar .localnavbarplus.nav-link:last-child .icon { - margin-right: .5rem; -} - -/* Do not display the icon if a user has disabled Javascript in his browser. */ +/* Do not display the reset user tour icon if a user has disabled Javascript in his browser. */ body:not(.jsenabled) #localnavbarplus-resetusertour { display: none; } - -/* Inherit the colors. */ -.navbar .localnavbarplus a, -.navbar .localnavbarplus .icon { - color: inherit; -} diff --git a/tests/behat/behat_local_navbarplus.php b/tests/behat/behat_local_navbarplus.php index eb87c0f..b6fb256 100644 --- a/tests/behat/behat_local_navbarplus.php +++ b/tests/behat/behat_local_navbarplus.php @@ -55,7 +55,7 @@ public function assert_element_in_navbar_contains_title_iconclass_link($title, $ // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"][contains(@href, "' . $link . '")]'; $elementxpath .= '/descendant::i[contains(@class, "' . $icon . '")]'; @@ -78,7 +78,7 @@ public function assert_element_in_navbar_not_contains_title_iconclass_link($titl // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"][contains(@href, "' . $link . '")]'; $elementxpath .= '/descendant::i[contains(@class, "' . $icon . '")]'; @@ -98,7 +98,7 @@ public function assert_element_in_navbar_contains_title($title) { // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"]'; // Check if the element exists. @@ -117,7 +117,7 @@ public function assert_element_in_navbar_not_contains_title($title) { // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"]'; // Check if the element does not exist. @@ -136,7 +136,7 @@ public function assert_element_in_navbar_has_new_window_attribute($title) { // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"][contains(@target, "_blank")]'; // Check if the element exists. @@ -155,7 +155,7 @@ public function assert_element_in_navbar_not_has_new_window_attribute($title) { // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"][contains(@target, "_blank")]'; // Check if the element exists. @@ -176,7 +176,7 @@ public function assert_element_in_navbar_has_additional_class($title, $class) { // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '[contains(@class, "' . $class . '")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"]'; @@ -198,7 +198,7 @@ public function assert_element_in_navbar_has_additional_id($title, $id) { // We are searching for our icons in the navbar. $elementxpath = '//div[@id="usernavigation"]'; - $elementxpath .= '/div[contains(@class, "nav-link")]'; + $elementxpath .= '/div[contains(@class, "localnavbarplus")]'; $elementxpath .= '[contains(@id, "' . $id . '")]'; $elementxpath .= '/descendant-or-self::a[@title="'. $title . '"]'; diff --git a/tests/behat/local_navbarplus.feature b/tests/behat/local_navbarplus.feature index c3993cd..192ee4c 100644 --- a/tests/behat/local_navbarplus.feature +++ b/tests/behat/local_navbarplus.feature @@ -74,7 +74,7 @@ Feature: Configuring the navbarplus plugin When I navigate to "Appearance > Navbar Plus" in site administration And I set the field "id_s_local_navbarplus_inserticonswithlinks" to "fa-sign-out|/login/logout.php|Logout" And I press "Save" - Then "div.localnavbarplus.nav-link" "css_element" should appear after "div[data-region='popover-region-messages']" "css_element" + Then "div.localnavbarplus" "css_element" should appear after "div[data-region='popover-region-messages']" "css_element" # The steps to create and use the tour were copied from the @tool_usertours Behat feature. # This scenario just differs in the aspect which button is used to reset the tour.