Skip to content

Commit

Permalink
Upgrade: Align the icons again properly on Moodle 4.4.
Browse files Browse the repository at this point in the history
  • Loading branch information
abias committed Aug 23, 2024
1 parent 11eebfd commit 01e554f
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 30 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 1 addition & 20 deletions styles.css
Original file line number Diff line number Diff line change
@@ -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;
}
16 changes: 8 additions & 8 deletions tests/behat/behat_local_navbarplus.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 . '")]';

Expand All @@ -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 . '")]';

Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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.
Expand All @@ -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 . '"]';

Expand All @@ -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 . '"]';

Expand Down
2 changes: 1 addition & 1 deletion tests/behat/local_navbarplus.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 01e554f

Please sign in to comment.